app.js 1.8 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697
  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. //
  1697. //
  1698. //
  1699. //
  1700. //
  1701. //
  1702. //
  1703. //
  1704. //
  1705. //
  1706. //
  1707. //
  1708. //
  1709. //
  1710. //
  1711. //
  1712. /* harmony default export */ __webpack_exports__["default"] = ({
  1713. props: ['initialnotes', 'authusername'],
  1714. data: function data() {
  1715. return {
  1716. notes: this.initialnotes
  1717. };
  1718. }
  1719. });
  1720. /***/ }),
  1721. /***/ "./node_modules/babel-loader/lib/index.js?!./node_modules/vue-loader/lib/index.js?!./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  1722. /*!*****************************************************************************************************************************************************************!*\
  1723. !*** ./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& ***!
  1724. \*****************************************************************************************************************************************************************/
  1725. /*! exports provided: default */
  1726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1727. "use strict";
  1728. __webpack_require__.r(__webpack_exports__);
  1729. /* harmony import */ var _mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mixins/dateMixin */ "./resources/js/mixins/dateMixin.js");
  1730. //
  1731. //
  1732. //
  1733. //
  1734. //
  1735. //
  1736. //
  1737. //
  1738. //
  1739. //
  1740. //
  1741. //
  1742. //
  1743. //
  1744. //
  1745. //
  1746. //
  1747. //
  1748. /* harmony default export */ __webpack_exports__["default"] = ({
  1749. mixins: [_mixins_dateMixin__WEBPACK_IMPORTED_MODULE_0__["default"]],
  1750. props: ['workOrder'],
  1751. data: function data() {
  1752. return {
  1753. data: JSON.parse(this.workOrder)
  1754. };
  1755. },
  1756. mounted: function mounted() {
  1757. var _this = this;
  1758. Echo.channel('work-orders').listen('WorkOrderUpdated', function (e) {
  1759. _this.data = JSON.parse(e.data);
  1760. });
  1761. }
  1762. });
  1763. /***/ }),
  1764. /***/ "./node_modules/base64-js/index.js":
  1765. /*!*****************************************!*\
  1766. !*** ./node_modules/base64-js/index.js ***!
  1767. \*****************************************/
  1768. /*! no static exports found */
  1769. /***/ (function(module, exports, __webpack_require__) {
  1770. "use strict";
  1771. exports.byteLength = byteLength
  1772. exports.toByteArray = toByteArray
  1773. exports.fromByteArray = fromByteArray
  1774. var lookup = []
  1775. var revLookup = []
  1776. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  1777. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  1778. for (var i = 0, len = code.length; i < len; ++i) {
  1779. lookup[i] = code[i]
  1780. revLookup[code.charCodeAt(i)] = i
  1781. }
  1782. // Support decoding URL-safe base64 strings, as Node.js does.
  1783. // See: https://en.wikipedia.org/wiki/Base64#URL_applications
  1784. revLookup['-'.charCodeAt(0)] = 62
  1785. revLookup['_'.charCodeAt(0)] = 63
  1786. function getLens (b64) {
  1787. var len = b64.length
  1788. if (len % 4 > 0) {
  1789. throw new Error('Invalid string. Length must be a multiple of 4')
  1790. }
  1791. // Trim off extra bytes after placeholder bytes are found
  1792. // See: https://github.com/beatgammit/base64-js/issues/42
  1793. var validLen = b64.indexOf('=')
  1794. if (validLen === -1) validLen = len
  1795. var placeHoldersLen = validLen === len
  1796. ? 0
  1797. : 4 - (validLen % 4)
  1798. return [validLen, placeHoldersLen]
  1799. }
  1800. // base64 is 4/3 + up to two characters of the original data
  1801. function byteLength (b64) {
  1802. var lens = getLens(b64)
  1803. var validLen = lens[0]
  1804. var placeHoldersLen = lens[1]
  1805. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1806. }
  1807. function _byteLength (b64, validLen, placeHoldersLen) {
  1808. return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
  1809. }
  1810. function toByteArray (b64) {
  1811. var tmp
  1812. var lens = getLens(b64)
  1813. var validLen = lens[0]
  1814. var placeHoldersLen = lens[1]
  1815. var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
  1816. var curByte = 0
  1817. // if there are placeholders, only get up to the last complete 4 chars
  1818. var len = placeHoldersLen > 0
  1819. ? validLen - 4
  1820. : validLen
  1821. var i
  1822. for (i = 0; i < len; i += 4) {
  1823. tmp =
  1824. (revLookup[b64.charCodeAt(i)] << 18) |
  1825. (revLookup[b64.charCodeAt(i + 1)] << 12) |
  1826. (revLookup[b64.charCodeAt(i + 2)] << 6) |
  1827. revLookup[b64.charCodeAt(i + 3)]
  1828. arr[curByte++] = (tmp >> 16) & 0xFF
  1829. arr[curByte++] = (tmp >> 8) & 0xFF
  1830. arr[curByte++] = tmp & 0xFF
  1831. }
  1832. if (placeHoldersLen === 2) {
  1833. tmp =
  1834. (revLookup[b64.charCodeAt(i)] << 2) |
  1835. (revLookup[b64.charCodeAt(i + 1)] >> 4)
  1836. arr[curByte++] = tmp & 0xFF
  1837. }
  1838. if (placeHoldersLen === 1) {
  1839. tmp =
  1840. (revLookup[b64.charCodeAt(i)] << 10) |
  1841. (revLookup[b64.charCodeAt(i + 1)] << 4) |
  1842. (revLookup[b64.charCodeAt(i + 2)] >> 2)
  1843. arr[curByte++] = (tmp >> 8) & 0xFF
  1844. arr[curByte++] = tmp & 0xFF
  1845. }
  1846. return arr
  1847. }
  1848. function tripletToBase64 (num) {
  1849. return lookup[num >> 18 & 0x3F] +
  1850. lookup[num >> 12 & 0x3F] +
  1851. lookup[num >> 6 & 0x3F] +
  1852. lookup[num & 0x3F]
  1853. }
  1854. function encodeChunk (uint8, start, end) {
  1855. var tmp
  1856. var output = []
  1857. for (var i = start; i < end; i += 3) {
  1858. tmp =
  1859. ((uint8[i] << 16) & 0xFF0000) +
  1860. ((uint8[i + 1] << 8) & 0xFF00) +
  1861. (uint8[i + 2] & 0xFF)
  1862. output.push(tripletToBase64(tmp))
  1863. }
  1864. return output.join('')
  1865. }
  1866. function fromByteArray (uint8) {
  1867. var tmp
  1868. var len = uint8.length
  1869. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  1870. var parts = []
  1871. var maxChunkLength = 16383 // must be multiple of 3
  1872. // go through the array every three bytes, we'll deal with trailing stuff later
  1873. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  1874. parts.push(encodeChunk(
  1875. uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
  1876. ))
  1877. }
  1878. // pad the end with zeros, but make sure to not forget the extra bytes
  1879. if (extraBytes === 1) {
  1880. tmp = uint8[len - 1]
  1881. parts.push(
  1882. lookup[tmp >> 2] +
  1883. lookup[(tmp << 4) & 0x3F] +
  1884. '=='
  1885. )
  1886. } else if (extraBytes === 2) {
  1887. tmp = (uint8[len - 2] << 8) + uint8[len - 1]
  1888. parts.push(
  1889. lookup[tmp >> 10] +
  1890. lookup[(tmp >> 4) & 0x3F] +
  1891. lookup[(tmp << 2) & 0x3F] +
  1892. '='
  1893. )
  1894. }
  1895. return parts.join('')
  1896. }
  1897. /***/ }),
  1898. /***/ "./node_modules/bootstrap/dist/js/bootstrap.js":
  1899. /*!*****************************************************!*\
  1900. !*** ./node_modules/bootstrap/dist/js/bootstrap.js ***!
  1901. \*****************************************************/
  1902. /*! no static exports found */
  1903. /***/ (function(module, exports, __webpack_require__) {
  1904. /*!
  1905. * Bootstrap v4.4.1 (https://getbootstrap.com/)
  1906. * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  1907. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1908. */
  1909. (function (global, factory) {
  1910. true ? factory(exports, __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js"), __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")) :
  1911. undefined;
  1912. }(this, (function (exports, $, Popper) { 'use strict';
  1913. $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
  1914. Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
  1915. function _defineProperties(target, props) {
  1916. for (var i = 0; i < props.length; i++) {
  1917. var descriptor = props[i];
  1918. descriptor.enumerable = descriptor.enumerable || false;
  1919. descriptor.configurable = true;
  1920. if ("value" in descriptor) descriptor.writable = true;
  1921. Object.defineProperty(target, descriptor.key, descriptor);
  1922. }
  1923. }
  1924. function _createClass(Constructor, protoProps, staticProps) {
  1925. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  1926. if (staticProps) _defineProperties(Constructor, staticProps);
  1927. return Constructor;
  1928. }
  1929. function _defineProperty(obj, key, value) {
  1930. if (key in obj) {
  1931. Object.defineProperty(obj, key, {
  1932. value: value,
  1933. enumerable: true,
  1934. configurable: true,
  1935. writable: true
  1936. });
  1937. } else {
  1938. obj[key] = value;
  1939. }
  1940. return obj;
  1941. }
  1942. function ownKeys(object, enumerableOnly) {
  1943. var keys = Object.keys(object);
  1944. if (Object.getOwnPropertySymbols) {
  1945. var symbols = Object.getOwnPropertySymbols(object);
  1946. if (enumerableOnly) symbols = symbols.filter(function (sym) {
  1947. return Object.getOwnPropertyDescriptor(object, sym).enumerable;
  1948. });
  1949. keys.push.apply(keys, symbols);
  1950. }
  1951. return keys;
  1952. }
  1953. function _objectSpread2(target) {
  1954. for (var i = 1; i < arguments.length; i++) {
  1955. var source = arguments[i] != null ? arguments[i] : {};
  1956. if (i % 2) {
  1957. ownKeys(Object(source), true).forEach(function (key) {
  1958. _defineProperty(target, key, source[key]);
  1959. });
  1960. } else if (Object.getOwnPropertyDescriptors) {
  1961. Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
  1962. } else {
  1963. ownKeys(Object(source)).forEach(function (key) {
  1964. Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
  1965. });
  1966. }
  1967. }
  1968. return target;
  1969. }
  1970. function _inheritsLoose(subClass, superClass) {
  1971. subClass.prototype = Object.create(superClass.prototype);
  1972. subClass.prototype.constructor = subClass;
  1973. subClass.__proto__ = superClass;
  1974. }
  1975. /**
  1976. * --------------------------------------------------------------------------
  1977. * Bootstrap (v4.4.1): util.js
  1978. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  1979. * --------------------------------------------------------------------------
  1980. */
  1981. /**
  1982. * ------------------------------------------------------------------------
  1983. * Private TransitionEnd Helpers
  1984. * ------------------------------------------------------------------------
  1985. */
  1986. var TRANSITION_END = 'transitionend';
  1987. var MAX_UID = 1000000;
  1988. var MILLISECONDS_MULTIPLIER = 1000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
  1989. function toType(obj) {
  1990. return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
  1991. }
  1992. function getSpecialTransitionEndEvent() {
  1993. return {
  1994. bindType: TRANSITION_END,
  1995. delegateType: TRANSITION_END,
  1996. handle: function handle(event) {
  1997. if ($(event.target).is(this)) {
  1998. return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params
  1999. }
  2000. return undefined; // eslint-disable-line no-undefined
  2001. }
  2002. };
  2003. }
  2004. function transitionEndEmulator(duration) {
  2005. var _this = this;
  2006. var called = false;
  2007. $(this).one(Util.TRANSITION_END, function () {
  2008. called = true;
  2009. });
  2010. setTimeout(function () {
  2011. if (!called) {
  2012. Util.triggerTransitionEnd(_this);
  2013. }
  2014. }, duration);
  2015. return this;
  2016. }
  2017. function setTransitionEndSupport() {
  2018. $.fn.emulateTransitionEnd = transitionEndEmulator;
  2019. $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
  2020. }
  2021. /**
  2022. * --------------------------------------------------------------------------
  2023. * Public Util Api
  2024. * --------------------------------------------------------------------------
  2025. */
  2026. var Util = {
  2027. TRANSITION_END: 'bsTransitionEnd',
  2028. getUID: function getUID(prefix) {
  2029. do {
  2030. // eslint-disable-next-line no-bitwise
  2031. prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
  2032. } while (document.getElementById(prefix));
  2033. return prefix;
  2034. },
  2035. getSelectorFromElement: function getSelectorFromElement(element) {
  2036. var selector = element.getAttribute('data-target');
  2037. if (!selector || selector === '#') {
  2038. var hrefAttr = element.getAttribute('href');
  2039. selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
  2040. }
  2041. try {
  2042. return document.querySelector(selector) ? selector : null;
  2043. } catch (err) {
  2044. return null;
  2045. }
  2046. },
  2047. getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
  2048. if (!element) {
  2049. return 0;
  2050. } // Get transition-duration of the element
  2051. var transitionDuration = $(element).css('transition-duration');
  2052. var transitionDelay = $(element).css('transition-delay');
  2053. var floatTransitionDuration = parseFloat(transitionDuration);
  2054. var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
  2055. if (!floatTransitionDuration && !floatTransitionDelay) {
  2056. return 0;
  2057. } // If multiple durations are defined, take the first
  2058. transitionDuration = transitionDuration.split(',')[0];
  2059. transitionDelay = transitionDelay.split(',')[0];
  2060. return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
  2061. },
  2062. reflow: function reflow(element) {
  2063. return element.offsetHeight;
  2064. },
  2065. triggerTransitionEnd: function triggerTransitionEnd(element) {
  2066. $(element).trigger(TRANSITION_END);
  2067. },
  2068. // TODO: Remove in v5
  2069. supportsTransitionEnd: function supportsTransitionEnd() {
  2070. return Boolean(TRANSITION_END);
  2071. },
  2072. isElement: function isElement(obj) {
  2073. return (obj[0] || obj).nodeType;
  2074. },
  2075. typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) {
  2076. for (var property in configTypes) {
  2077. if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
  2078. var expectedTypes = configTypes[property];
  2079. var value = config[property];
  2080. var valueType = value && Util.isElement(value) ? 'element' : toType(value);
  2081. if (!new RegExp(expectedTypes).test(valueType)) {
  2082. throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
  2083. }
  2084. }
  2085. }
  2086. },
  2087. findShadowRoot: function findShadowRoot(element) {
  2088. if (!document.documentElement.attachShadow) {
  2089. return null;
  2090. } // Can find the shadow root otherwise it'll return the document
  2091. if (typeof element.getRootNode === 'function') {
  2092. var root = element.getRootNode();
  2093. return root instanceof ShadowRoot ? root : null;
  2094. }
  2095. if (element instanceof ShadowRoot) {
  2096. return element;
  2097. } // when we don't find a shadow root
  2098. if (!element.parentNode) {
  2099. return null;
  2100. }
  2101. return Util.findShadowRoot(element.parentNode);
  2102. },
  2103. jQueryDetection: function jQueryDetection() {
  2104. if (typeof $ === 'undefined') {
  2105. throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.');
  2106. }
  2107. var version = $.fn.jquery.split(' ')[0].split('.');
  2108. var minMajor = 1;
  2109. var ltMajor = 2;
  2110. var minMinor = 9;
  2111. var minPatch = 1;
  2112. var maxMajor = 4;
  2113. if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
  2114. throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0');
  2115. }
  2116. }
  2117. };
  2118. Util.jQueryDetection();
  2119. setTransitionEndSupport();
  2120. /**
  2121. * ------------------------------------------------------------------------
  2122. * Constants
  2123. * ------------------------------------------------------------------------
  2124. */
  2125. var NAME = 'alert';
  2126. var VERSION = '4.4.1';
  2127. var DATA_KEY = 'bs.alert';
  2128. var EVENT_KEY = "." + DATA_KEY;
  2129. var DATA_API_KEY = '.data-api';
  2130. var JQUERY_NO_CONFLICT = $.fn[NAME];
  2131. var Selector = {
  2132. DISMISS: '[data-dismiss="alert"]'
  2133. };
  2134. var Event = {
  2135. CLOSE: "close" + EVENT_KEY,
  2136. CLOSED: "closed" + EVENT_KEY,
  2137. CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
  2138. };
  2139. var ClassName = {
  2140. ALERT: 'alert',
  2141. FADE: 'fade',
  2142. SHOW: 'show'
  2143. };
  2144. /**
  2145. * ------------------------------------------------------------------------
  2146. * Class Definition
  2147. * ------------------------------------------------------------------------
  2148. */
  2149. var Alert =
  2150. /*#__PURE__*/
  2151. function () {
  2152. function Alert(element) {
  2153. this._element = element;
  2154. } // Getters
  2155. var _proto = Alert.prototype;
  2156. // Public
  2157. _proto.close = function close(element) {
  2158. var rootElement = this._element;
  2159. if (element) {
  2160. rootElement = this._getRootElement(element);
  2161. }
  2162. var customEvent = this._triggerCloseEvent(rootElement);
  2163. if (customEvent.isDefaultPrevented()) {
  2164. return;
  2165. }
  2166. this._removeElement(rootElement);
  2167. };
  2168. _proto.dispose = function dispose() {
  2169. $.removeData(this._element, DATA_KEY);
  2170. this._element = null;
  2171. } // Private
  2172. ;
  2173. _proto._getRootElement = function _getRootElement(element) {
  2174. var selector = Util.getSelectorFromElement(element);
  2175. var parent = false;
  2176. if (selector) {
  2177. parent = document.querySelector(selector);
  2178. }
  2179. if (!parent) {
  2180. parent = $(element).closest("." + ClassName.ALERT)[0];
  2181. }
  2182. return parent;
  2183. };
  2184. _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
  2185. var closeEvent = $.Event(Event.CLOSE);
  2186. $(element).trigger(closeEvent);
  2187. return closeEvent;
  2188. };
  2189. _proto._removeElement = function _removeElement(element) {
  2190. var _this = this;
  2191. $(element).removeClass(ClassName.SHOW);
  2192. if (!$(element).hasClass(ClassName.FADE)) {
  2193. this._destroyElement(element);
  2194. return;
  2195. }
  2196. var transitionDuration = Util.getTransitionDurationFromElement(element);
  2197. $(element).one(Util.TRANSITION_END, function (event) {
  2198. return _this._destroyElement(element, event);
  2199. }).emulateTransitionEnd(transitionDuration);
  2200. };
  2201. _proto._destroyElement = function _destroyElement(element) {
  2202. $(element).detach().trigger(Event.CLOSED).remove();
  2203. } // Static
  2204. ;
  2205. Alert._jQueryInterface = function _jQueryInterface(config) {
  2206. return this.each(function () {
  2207. var $element = $(this);
  2208. var data = $element.data(DATA_KEY);
  2209. if (!data) {
  2210. data = new Alert(this);
  2211. $element.data(DATA_KEY, data);
  2212. }
  2213. if (config === 'close') {
  2214. data[config](this);
  2215. }
  2216. });
  2217. };
  2218. Alert._handleDismiss = function _handleDismiss(alertInstance) {
  2219. return function (event) {
  2220. if (event) {
  2221. event.preventDefault();
  2222. }
  2223. alertInstance.close(this);
  2224. };
  2225. };
  2226. _createClass(Alert, null, [{
  2227. key: "VERSION",
  2228. get: function get() {
  2229. return VERSION;
  2230. }
  2231. }]);
  2232. return Alert;
  2233. }();
  2234. /**
  2235. * ------------------------------------------------------------------------
  2236. * Data Api implementation
  2237. * ------------------------------------------------------------------------
  2238. */
  2239. $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
  2240. /**
  2241. * ------------------------------------------------------------------------
  2242. * jQuery
  2243. * ------------------------------------------------------------------------
  2244. */
  2245. $.fn[NAME] = Alert._jQueryInterface;
  2246. $.fn[NAME].Constructor = Alert;
  2247. $.fn[NAME].noConflict = function () {
  2248. $.fn[NAME] = JQUERY_NO_CONFLICT;
  2249. return Alert._jQueryInterface;
  2250. };
  2251. /**
  2252. * ------------------------------------------------------------------------
  2253. * Constants
  2254. * ------------------------------------------------------------------------
  2255. */
  2256. var NAME$1 = 'button';
  2257. var VERSION$1 = '4.4.1';
  2258. var DATA_KEY$1 = 'bs.button';
  2259. var EVENT_KEY$1 = "." + DATA_KEY$1;
  2260. var DATA_API_KEY$1 = '.data-api';
  2261. var JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
  2262. var ClassName$1 = {
  2263. ACTIVE: 'active',
  2264. BUTTON: 'btn',
  2265. FOCUS: 'focus'
  2266. };
  2267. var Selector$1 = {
  2268. DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
  2269. DATA_TOGGLES: '[data-toggle="buttons"]',
  2270. DATA_TOGGLE: '[data-toggle="button"]',
  2271. DATA_TOGGLES_BUTTONS: '[data-toggle="buttons"] .btn',
  2272. INPUT: 'input:not([type="hidden"])',
  2273. ACTIVE: '.active',
  2274. BUTTON: '.btn'
  2275. };
  2276. var Event$1 = {
  2277. CLICK_DATA_API: "click" + EVENT_KEY$1 + DATA_API_KEY$1,
  2278. FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY$1 + DATA_API_KEY$1 + " " + ("blur" + EVENT_KEY$1 + DATA_API_KEY$1),
  2279. LOAD_DATA_API: "load" + EVENT_KEY$1 + DATA_API_KEY$1
  2280. };
  2281. /**
  2282. * ------------------------------------------------------------------------
  2283. * Class Definition
  2284. * ------------------------------------------------------------------------
  2285. */
  2286. var Button =
  2287. /*#__PURE__*/
  2288. function () {
  2289. function Button(element) {
  2290. this._element = element;
  2291. } // Getters
  2292. var _proto = Button.prototype;
  2293. // Public
  2294. _proto.toggle = function toggle() {
  2295. var triggerChangeEvent = true;
  2296. var addAriaPressed = true;
  2297. var rootElement = $(this._element).closest(Selector$1.DATA_TOGGLES)[0];
  2298. if (rootElement) {
  2299. var input = this._element.querySelector(Selector$1.INPUT);
  2300. if (input) {
  2301. if (input.type === 'radio') {
  2302. if (input.checked && this._element.classList.contains(ClassName$1.ACTIVE)) {
  2303. triggerChangeEvent = false;
  2304. } else {
  2305. var activeElement = rootElement.querySelector(Selector$1.ACTIVE);
  2306. if (activeElement) {
  2307. $(activeElement).removeClass(ClassName$1.ACTIVE);
  2308. }
  2309. }
  2310. } else if (input.type === 'checkbox') {
  2311. if (this._element.tagName === 'LABEL' && input.checked === this._element.classList.contains(ClassName$1.ACTIVE)) {
  2312. triggerChangeEvent = false;
  2313. }
  2314. } else {
  2315. // if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
  2316. triggerChangeEvent = false;
  2317. }
  2318. if (triggerChangeEvent) {
  2319. input.checked = !this._element.classList.contains(ClassName$1.ACTIVE);
  2320. $(input).trigger('change');
  2321. }
  2322. input.focus();
  2323. addAriaPressed = false;
  2324. }
  2325. }
  2326. if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
  2327. if (addAriaPressed) {
  2328. this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName$1.ACTIVE));
  2329. }
  2330. if (triggerChangeEvent) {
  2331. $(this._element).toggleClass(ClassName$1.ACTIVE);
  2332. }
  2333. }
  2334. };
  2335. _proto.dispose = function dispose() {
  2336. $.removeData(this._element, DATA_KEY$1);
  2337. this._element = null;
  2338. } // Static
  2339. ;
  2340. Button._jQueryInterface = function _jQueryInterface(config) {
  2341. return this.each(function () {
  2342. var data = $(this).data(DATA_KEY$1);
  2343. if (!data) {
  2344. data = new Button(this);
  2345. $(this).data(DATA_KEY$1, data);
  2346. }
  2347. if (config === 'toggle') {
  2348. data[config]();
  2349. }
  2350. });
  2351. };
  2352. _createClass(Button, null, [{
  2353. key: "VERSION",
  2354. get: function get() {
  2355. return VERSION$1;
  2356. }
  2357. }]);
  2358. return Button;
  2359. }();
  2360. /**
  2361. * ------------------------------------------------------------------------
  2362. * Data Api implementation
  2363. * ------------------------------------------------------------------------
  2364. */
  2365. $(document).on(Event$1.CLICK_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2366. var button = event.target;
  2367. if (!$(button).hasClass(ClassName$1.BUTTON)) {
  2368. button = $(button).closest(Selector$1.BUTTON)[0];
  2369. }
  2370. if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
  2371. event.preventDefault(); // work around Firefox bug #1540995
  2372. } else {
  2373. var inputBtn = button.querySelector(Selector$1.INPUT);
  2374. if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
  2375. event.preventDefault(); // work around Firefox bug #1540995
  2376. return;
  2377. }
  2378. Button._jQueryInterface.call($(button), 'toggle');
  2379. }
  2380. }).on(Event$1.FOCUS_BLUR_DATA_API, Selector$1.DATA_TOGGLE_CARROT, function (event) {
  2381. var button = $(event.target).closest(Selector$1.BUTTON)[0];
  2382. $(button).toggleClass(ClassName$1.FOCUS, /^focus(in)?$/.test(event.type));
  2383. });
  2384. $(window).on(Event$1.LOAD_DATA_API, function () {
  2385. // ensure correct active class is set to match the controls' actual values/states
  2386. // find all checkboxes/readio buttons inside data-toggle groups
  2387. var buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLES_BUTTONS));
  2388. for (var i = 0, len = buttons.length; i < len; i++) {
  2389. var button = buttons[i];
  2390. var input = button.querySelector(Selector$1.INPUT);
  2391. if (input.checked || input.hasAttribute('checked')) {
  2392. button.classList.add(ClassName$1.ACTIVE);
  2393. } else {
  2394. button.classList.remove(ClassName$1.ACTIVE);
  2395. }
  2396. } // find all button toggles
  2397. buttons = [].slice.call(document.querySelectorAll(Selector$1.DATA_TOGGLE));
  2398. for (var _i = 0, _len = buttons.length; _i < _len; _i++) {
  2399. var _button = buttons[_i];
  2400. if (_button.getAttribute('aria-pressed') === 'true') {
  2401. _button.classList.add(ClassName$1.ACTIVE);
  2402. } else {
  2403. _button.classList.remove(ClassName$1.ACTIVE);
  2404. }
  2405. }
  2406. });
  2407. /**
  2408. * ------------------------------------------------------------------------
  2409. * jQuery
  2410. * ------------------------------------------------------------------------
  2411. */
  2412. $.fn[NAME$1] = Button._jQueryInterface;
  2413. $.fn[NAME$1].Constructor = Button;
  2414. $.fn[NAME$1].noConflict = function () {
  2415. $.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
  2416. return Button._jQueryInterface;
  2417. };
  2418. /**
  2419. * ------------------------------------------------------------------------
  2420. * Constants
  2421. * ------------------------------------------------------------------------
  2422. */
  2423. var NAME$2 = 'carousel';
  2424. var VERSION$2 = '4.4.1';
  2425. var DATA_KEY$2 = 'bs.carousel';
  2426. var EVENT_KEY$2 = "." + DATA_KEY$2;
  2427. var DATA_API_KEY$2 = '.data-api';
  2428. var JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
  2429. var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key
  2430. var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key
  2431. var TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch
  2432. var SWIPE_THRESHOLD = 40;
  2433. var Default = {
  2434. interval: 5000,
  2435. keyboard: true,
  2436. slide: false,
  2437. pause: 'hover',
  2438. wrap: true,
  2439. touch: true
  2440. };
  2441. var DefaultType = {
  2442. interval: '(number|boolean)',
  2443. keyboard: 'boolean',
  2444. slide: '(boolean|string)',
  2445. pause: '(string|boolean)',
  2446. wrap: 'boolean',
  2447. touch: 'boolean'
  2448. };
  2449. var Direction = {
  2450. NEXT: 'next',
  2451. PREV: 'prev',
  2452. LEFT: 'left',
  2453. RIGHT: 'right'
  2454. };
  2455. var Event$2 = {
  2456. SLIDE: "slide" + EVENT_KEY$2,
  2457. SLID: "slid" + EVENT_KEY$2,
  2458. KEYDOWN: "keydown" + EVENT_KEY$2,
  2459. MOUSEENTER: "mouseenter" + EVENT_KEY$2,
  2460. MOUSELEAVE: "mouseleave" + EVENT_KEY$2,
  2461. TOUCHSTART: "touchstart" + EVENT_KEY$2,
  2462. TOUCHMOVE: "touchmove" + EVENT_KEY$2,
  2463. TOUCHEND: "touchend" + EVENT_KEY$2,
  2464. POINTERDOWN: "pointerdown" + EVENT_KEY$2,
  2465. POINTERUP: "pointerup" + EVENT_KEY$2,
  2466. DRAG_START: "dragstart" + EVENT_KEY$2,
  2467. LOAD_DATA_API: "load" + EVENT_KEY$2 + DATA_API_KEY$2,
  2468. CLICK_DATA_API: "click" + EVENT_KEY$2 + DATA_API_KEY$2
  2469. };
  2470. var ClassName$2 = {
  2471. CAROUSEL: 'carousel',
  2472. ACTIVE: 'active',
  2473. SLIDE: 'slide',
  2474. RIGHT: 'carousel-item-right',
  2475. LEFT: 'carousel-item-left',
  2476. NEXT: 'carousel-item-next',
  2477. PREV: 'carousel-item-prev',
  2478. ITEM: 'carousel-item',
  2479. POINTER_EVENT: 'pointer-event'
  2480. };
  2481. var Selector$2 = {
  2482. ACTIVE: '.active',
  2483. ACTIVE_ITEM: '.active.carousel-item',
  2484. ITEM: '.carousel-item',
  2485. ITEM_IMG: '.carousel-item img',
  2486. NEXT_PREV: '.carousel-item-next, .carousel-item-prev',
  2487. INDICATORS: '.carousel-indicators',
  2488. DATA_SLIDE: '[data-slide], [data-slide-to]',
  2489. DATA_RIDE: '[data-ride="carousel"]'
  2490. };
  2491. var PointerType = {
  2492. TOUCH: 'touch',
  2493. PEN: 'pen'
  2494. };
  2495. /**
  2496. * ------------------------------------------------------------------------
  2497. * Class Definition
  2498. * ------------------------------------------------------------------------
  2499. */
  2500. var Carousel =
  2501. /*#__PURE__*/
  2502. function () {
  2503. function Carousel(element, config) {
  2504. this._items = null;
  2505. this._interval = null;
  2506. this._activeElement = null;
  2507. this._isPaused = false;
  2508. this._isSliding = false;
  2509. this.touchTimeout = null;
  2510. this.touchStartX = 0;
  2511. this.touchDeltaX = 0;
  2512. this._config = this._getConfig(config);
  2513. this._element = element;
  2514. this._indicatorsElement = this._element.querySelector(Selector$2.INDICATORS);
  2515. this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0;
  2516. this._pointerEvent = Boolean(window.PointerEvent || window.MSPointerEvent);
  2517. this._addEventListeners();
  2518. } // Getters
  2519. var _proto = Carousel.prototype;
  2520. // Public
  2521. _proto.next = function next() {
  2522. if (!this._isSliding) {
  2523. this._slide(Direction.NEXT);
  2524. }
  2525. };
  2526. _proto.nextWhenVisible = function nextWhenVisible() {
  2527. // Don't call next when the page isn't visible
  2528. // or the carousel or its parent isn't visible
  2529. if (!document.hidden && $(this._element).is(':visible') && $(this._element).css('visibility') !== 'hidden') {
  2530. this.next();
  2531. }
  2532. };
  2533. _proto.prev = function prev() {
  2534. if (!this._isSliding) {
  2535. this._slide(Direction.PREV);
  2536. }
  2537. };
  2538. _proto.pause = function pause(event) {
  2539. if (!event) {
  2540. this._isPaused = true;
  2541. }
  2542. if (this._element.querySelector(Selector$2.NEXT_PREV)) {
  2543. Util.triggerTransitionEnd(this._element);
  2544. this.cycle(true);
  2545. }
  2546. clearInterval(this._interval);
  2547. this._interval = null;
  2548. };
  2549. _proto.cycle = function cycle(event) {
  2550. if (!event) {
  2551. this._isPaused = false;
  2552. }
  2553. if (this._interval) {
  2554. clearInterval(this._interval);
  2555. this._interval = null;
  2556. }
  2557. if (this._config.interval && !this._isPaused) {
  2558. this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval);
  2559. }
  2560. };
  2561. _proto.to = function to(index) {
  2562. var _this = this;
  2563. this._activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2564. var activeIndex = this._getItemIndex(this._activeElement);
  2565. if (index > this._items.length - 1 || index < 0) {
  2566. return;
  2567. }
  2568. if (this._isSliding) {
  2569. $(this._element).one(Event$2.SLID, function () {
  2570. return _this.to(index);
  2571. });
  2572. return;
  2573. }
  2574. if (activeIndex === index) {
  2575. this.pause();
  2576. this.cycle();
  2577. return;
  2578. }
  2579. var direction = index > activeIndex ? Direction.NEXT : Direction.PREV;
  2580. this._slide(direction, this._items[index]);
  2581. };
  2582. _proto.dispose = function dispose() {
  2583. $(this._element).off(EVENT_KEY$2);
  2584. $.removeData(this._element, DATA_KEY$2);
  2585. this._items = null;
  2586. this._config = null;
  2587. this._element = null;
  2588. this._interval = null;
  2589. this._isPaused = null;
  2590. this._isSliding = null;
  2591. this._activeElement = null;
  2592. this._indicatorsElement = null;
  2593. } // Private
  2594. ;
  2595. _proto._getConfig = function _getConfig(config) {
  2596. config = _objectSpread2({}, Default, {}, config);
  2597. Util.typeCheckConfig(NAME$2, config, DefaultType);
  2598. return config;
  2599. };
  2600. _proto._handleSwipe = function _handleSwipe() {
  2601. var absDeltax = Math.abs(this.touchDeltaX);
  2602. if (absDeltax <= SWIPE_THRESHOLD) {
  2603. return;
  2604. }
  2605. var direction = absDeltax / this.touchDeltaX;
  2606. this.touchDeltaX = 0; // swipe left
  2607. if (direction > 0) {
  2608. this.prev();
  2609. } // swipe right
  2610. if (direction < 0) {
  2611. this.next();
  2612. }
  2613. };
  2614. _proto._addEventListeners = function _addEventListeners() {
  2615. var _this2 = this;
  2616. if (this._config.keyboard) {
  2617. $(this._element).on(Event$2.KEYDOWN, function (event) {
  2618. return _this2._keydown(event);
  2619. });
  2620. }
  2621. if (this._config.pause === 'hover') {
  2622. $(this._element).on(Event$2.MOUSEENTER, function (event) {
  2623. return _this2.pause(event);
  2624. }).on(Event$2.MOUSELEAVE, function (event) {
  2625. return _this2.cycle(event);
  2626. });
  2627. }
  2628. if (this._config.touch) {
  2629. this._addTouchEventListeners();
  2630. }
  2631. };
  2632. _proto._addTouchEventListeners = function _addTouchEventListeners() {
  2633. var _this3 = this;
  2634. if (!this._touchSupported) {
  2635. return;
  2636. }
  2637. var start = function start(event) {
  2638. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2639. _this3.touchStartX = event.originalEvent.clientX;
  2640. } else if (!_this3._pointerEvent) {
  2641. _this3.touchStartX = event.originalEvent.touches[0].clientX;
  2642. }
  2643. };
  2644. var move = function move(event) {
  2645. // ensure swiping with one touch and not pinching
  2646. if (event.originalEvent.touches && event.originalEvent.touches.length > 1) {
  2647. _this3.touchDeltaX = 0;
  2648. } else {
  2649. _this3.touchDeltaX = event.originalEvent.touches[0].clientX - _this3.touchStartX;
  2650. }
  2651. };
  2652. var end = function end(event) {
  2653. if (_this3._pointerEvent && PointerType[event.originalEvent.pointerType.toUpperCase()]) {
  2654. _this3.touchDeltaX = event.originalEvent.clientX - _this3.touchStartX;
  2655. }
  2656. _this3._handleSwipe();
  2657. if (_this3._config.pause === 'hover') {
  2658. // If it's a touch-enabled device, mouseenter/leave are fired as
  2659. // part of the mouse compatibility events on first tap - the carousel
  2660. // would stop cycling until user tapped out of it;
  2661. // here, we listen for touchend, explicitly pause the carousel
  2662. // (as if it's the second time we tap on it, mouseenter compat event
  2663. // is NOT fired) and after a timeout (to allow for mouse compatibility
  2664. // events to fire) we explicitly restart cycling
  2665. _this3.pause();
  2666. if (_this3.touchTimeout) {
  2667. clearTimeout(_this3.touchTimeout);
  2668. }
  2669. _this3.touchTimeout = setTimeout(function (event) {
  2670. return _this3.cycle(event);
  2671. }, TOUCHEVENT_COMPAT_WAIT + _this3._config.interval);
  2672. }
  2673. };
  2674. $(this._element.querySelectorAll(Selector$2.ITEM_IMG)).on(Event$2.DRAG_START, function (e) {
  2675. return e.preventDefault();
  2676. });
  2677. if (this._pointerEvent) {
  2678. $(this._element).on(Event$2.POINTERDOWN, function (event) {
  2679. return start(event);
  2680. });
  2681. $(this._element).on(Event$2.POINTERUP, function (event) {
  2682. return end(event);
  2683. });
  2684. this._element.classList.add(ClassName$2.POINTER_EVENT);
  2685. } else {
  2686. $(this._element).on(Event$2.TOUCHSTART, function (event) {
  2687. return start(event);
  2688. });
  2689. $(this._element).on(Event$2.TOUCHMOVE, function (event) {
  2690. return move(event);
  2691. });
  2692. $(this._element).on(Event$2.TOUCHEND, function (event) {
  2693. return end(event);
  2694. });
  2695. }
  2696. };
  2697. _proto._keydown = function _keydown(event) {
  2698. if (/input|textarea/i.test(event.target.tagName)) {
  2699. return;
  2700. }
  2701. switch (event.which) {
  2702. case ARROW_LEFT_KEYCODE:
  2703. event.preventDefault();
  2704. this.prev();
  2705. break;
  2706. case ARROW_RIGHT_KEYCODE:
  2707. event.preventDefault();
  2708. this.next();
  2709. break;
  2710. }
  2711. };
  2712. _proto._getItemIndex = function _getItemIndex(element) {
  2713. this._items = element && element.parentNode ? [].slice.call(element.parentNode.querySelectorAll(Selector$2.ITEM)) : [];
  2714. return this._items.indexOf(element);
  2715. };
  2716. _proto._getItemByDirection = function _getItemByDirection(direction, activeElement) {
  2717. var isNextDirection = direction === Direction.NEXT;
  2718. var isPrevDirection = direction === Direction.PREV;
  2719. var activeIndex = this._getItemIndex(activeElement);
  2720. var lastItemIndex = this._items.length - 1;
  2721. var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex;
  2722. if (isGoingToWrap && !this._config.wrap) {
  2723. return activeElement;
  2724. }
  2725. var delta = direction === Direction.PREV ? -1 : 1;
  2726. var itemIndex = (activeIndex + delta) % this._items.length;
  2727. return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex];
  2728. };
  2729. _proto._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
  2730. var targetIndex = this._getItemIndex(relatedTarget);
  2731. var fromIndex = this._getItemIndex(this._element.querySelector(Selector$2.ACTIVE_ITEM));
  2732. var slideEvent = $.Event(Event$2.SLIDE, {
  2733. relatedTarget: relatedTarget,
  2734. direction: eventDirectionName,
  2735. from: fromIndex,
  2736. to: targetIndex
  2737. });
  2738. $(this._element).trigger(slideEvent);
  2739. return slideEvent;
  2740. };
  2741. _proto._setActiveIndicatorElement = function _setActiveIndicatorElement(element) {
  2742. if (this._indicatorsElement) {
  2743. var indicators = [].slice.call(this._indicatorsElement.querySelectorAll(Selector$2.ACTIVE));
  2744. $(indicators).removeClass(ClassName$2.ACTIVE);
  2745. var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)];
  2746. if (nextIndicator) {
  2747. $(nextIndicator).addClass(ClassName$2.ACTIVE);
  2748. }
  2749. }
  2750. };
  2751. _proto._slide = function _slide(direction, element) {
  2752. var _this4 = this;
  2753. var activeElement = this._element.querySelector(Selector$2.ACTIVE_ITEM);
  2754. var activeElementIndex = this._getItemIndex(activeElement);
  2755. var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
  2756. var nextElementIndex = this._getItemIndex(nextElement);
  2757. var isCycling = Boolean(this._interval);
  2758. var directionalClassName;
  2759. var orderClassName;
  2760. var eventDirectionName;
  2761. if (direction === Direction.NEXT) {
  2762. directionalClassName = ClassName$2.LEFT;
  2763. orderClassName = ClassName$2.NEXT;
  2764. eventDirectionName = Direction.LEFT;
  2765. } else {
  2766. directionalClassName = ClassName$2.RIGHT;
  2767. orderClassName = ClassName$2.PREV;
  2768. eventDirectionName = Direction.RIGHT;
  2769. }
  2770. if (nextElement && $(nextElement).hasClass(ClassName$2.ACTIVE)) {
  2771. this._isSliding = false;
  2772. return;
  2773. }
  2774. var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName);
  2775. if (slideEvent.isDefaultPrevented()) {
  2776. return;
  2777. }
  2778. if (!activeElement || !nextElement) {
  2779. // Some weirdness is happening, so we bail
  2780. return;
  2781. }
  2782. this._isSliding = true;
  2783. if (isCycling) {
  2784. this.pause();
  2785. }
  2786. this._setActiveIndicatorElement(nextElement);
  2787. var slidEvent = $.Event(Event$2.SLID, {
  2788. relatedTarget: nextElement,
  2789. direction: eventDirectionName,
  2790. from: activeElementIndex,
  2791. to: nextElementIndex
  2792. });
  2793. if ($(this._element).hasClass(ClassName$2.SLIDE)) {
  2794. $(nextElement).addClass(orderClassName);
  2795. Util.reflow(nextElement);
  2796. $(activeElement).addClass(directionalClassName);
  2797. $(nextElement).addClass(directionalClassName);
  2798. var nextElementInterval = parseInt(nextElement.getAttribute('data-interval'), 10);
  2799. if (nextElementInterval) {
  2800. this._config.defaultInterval = this._config.defaultInterval || this._config.interval;
  2801. this._config.interval = nextElementInterval;
  2802. } else {
  2803. this._config.interval = this._config.defaultInterval || this._config.interval;
  2804. }
  2805. var transitionDuration = Util.getTransitionDurationFromElement(activeElement);
  2806. $(activeElement).one(Util.TRANSITION_END, function () {
  2807. $(nextElement).removeClass(directionalClassName + " " + orderClassName).addClass(ClassName$2.ACTIVE);
  2808. $(activeElement).removeClass(ClassName$2.ACTIVE + " " + orderClassName + " " + directionalClassName);
  2809. _this4._isSliding = false;
  2810. setTimeout(function () {
  2811. return $(_this4._element).trigger(slidEvent);
  2812. }, 0);
  2813. }).emulateTransitionEnd(transitionDuration);
  2814. } else {
  2815. $(activeElement).removeClass(ClassName$2.ACTIVE);
  2816. $(nextElement).addClass(ClassName$2.ACTIVE);
  2817. this._isSliding = false;
  2818. $(this._element).trigger(slidEvent);
  2819. }
  2820. if (isCycling) {
  2821. this.cycle();
  2822. }
  2823. } // Static
  2824. ;
  2825. Carousel._jQueryInterface = function _jQueryInterface(config) {
  2826. return this.each(function () {
  2827. var data = $(this).data(DATA_KEY$2);
  2828. var _config = _objectSpread2({}, Default, {}, $(this).data());
  2829. if (typeof config === 'object') {
  2830. _config = _objectSpread2({}, _config, {}, config);
  2831. }
  2832. var action = typeof config === 'string' ? config : _config.slide;
  2833. if (!data) {
  2834. data = new Carousel(this, _config);
  2835. $(this).data(DATA_KEY$2, data);
  2836. }
  2837. if (typeof config === 'number') {
  2838. data.to(config);
  2839. } else if (typeof action === 'string') {
  2840. if (typeof data[action] === 'undefined') {
  2841. throw new TypeError("No method named \"" + action + "\"");
  2842. }
  2843. data[action]();
  2844. } else if (_config.interval && _config.ride) {
  2845. data.pause();
  2846. data.cycle();
  2847. }
  2848. });
  2849. };
  2850. Carousel._dataApiClickHandler = function _dataApiClickHandler(event) {
  2851. var selector = Util.getSelectorFromElement(this);
  2852. if (!selector) {
  2853. return;
  2854. }
  2855. var target = $(selector)[0];
  2856. if (!target || !$(target).hasClass(ClassName$2.CAROUSEL)) {
  2857. return;
  2858. }
  2859. var config = _objectSpread2({}, $(target).data(), {}, $(this).data());
  2860. var slideIndex = this.getAttribute('data-slide-to');
  2861. if (slideIndex) {
  2862. config.interval = false;
  2863. }
  2864. Carousel._jQueryInterface.call($(target), config);
  2865. if (slideIndex) {
  2866. $(target).data(DATA_KEY$2).to(slideIndex);
  2867. }
  2868. event.preventDefault();
  2869. };
  2870. _createClass(Carousel, null, [{
  2871. key: "VERSION",
  2872. get: function get() {
  2873. return VERSION$2;
  2874. }
  2875. }, {
  2876. key: "Default",
  2877. get: function get() {
  2878. return Default;
  2879. }
  2880. }]);
  2881. return Carousel;
  2882. }();
  2883. /**
  2884. * ------------------------------------------------------------------------
  2885. * Data Api implementation
  2886. * ------------------------------------------------------------------------
  2887. */
  2888. $(document).on(Event$2.CLICK_DATA_API, Selector$2.DATA_SLIDE, Carousel._dataApiClickHandler);
  2889. $(window).on(Event$2.LOAD_DATA_API, function () {
  2890. var carousels = [].slice.call(document.querySelectorAll(Selector$2.DATA_RIDE));
  2891. for (var i = 0, len = carousels.length; i < len; i++) {
  2892. var $carousel = $(carousels[i]);
  2893. Carousel._jQueryInterface.call($carousel, $carousel.data());
  2894. }
  2895. });
  2896. /**
  2897. * ------------------------------------------------------------------------
  2898. * jQuery
  2899. * ------------------------------------------------------------------------
  2900. */
  2901. $.fn[NAME$2] = Carousel._jQueryInterface;
  2902. $.fn[NAME$2].Constructor = Carousel;
  2903. $.fn[NAME$2].noConflict = function () {
  2904. $.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
  2905. return Carousel._jQueryInterface;
  2906. };
  2907. /**
  2908. * ------------------------------------------------------------------------
  2909. * Constants
  2910. * ------------------------------------------------------------------------
  2911. */
  2912. var NAME$3 = 'collapse';
  2913. var VERSION$3 = '4.4.1';
  2914. var DATA_KEY$3 = 'bs.collapse';
  2915. var EVENT_KEY$3 = "." + DATA_KEY$3;
  2916. var DATA_API_KEY$3 = '.data-api';
  2917. var JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
  2918. var Default$1 = {
  2919. toggle: true,
  2920. parent: ''
  2921. };
  2922. var DefaultType$1 = {
  2923. toggle: 'boolean',
  2924. parent: '(string|element)'
  2925. };
  2926. var Event$3 = {
  2927. SHOW: "show" + EVENT_KEY$3,
  2928. SHOWN: "shown" + EVENT_KEY$3,
  2929. HIDE: "hide" + EVENT_KEY$3,
  2930. HIDDEN: "hidden" + EVENT_KEY$3,
  2931. CLICK_DATA_API: "click" + EVENT_KEY$3 + DATA_API_KEY$3
  2932. };
  2933. var ClassName$3 = {
  2934. SHOW: 'show',
  2935. COLLAPSE: 'collapse',
  2936. COLLAPSING: 'collapsing',
  2937. COLLAPSED: 'collapsed'
  2938. };
  2939. var Dimension = {
  2940. WIDTH: 'width',
  2941. HEIGHT: 'height'
  2942. };
  2943. var Selector$3 = {
  2944. ACTIVES: '.show, .collapsing',
  2945. DATA_TOGGLE: '[data-toggle="collapse"]'
  2946. };
  2947. /**
  2948. * ------------------------------------------------------------------------
  2949. * Class Definition
  2950. * ------------------------------------------------------------------------
  2951. */
  2952. var Collapse =
  2953. /*#__PURE__*/
  2954. function () {
  2955. function Collapse(element, config) {
  2956. this._isTransitioning = false;
  2957. this._element = element;
  2958. this._config = this._getConfig(config);
  2959. this._triggerArray = [].slice.call(document.querySelectorAll("[data-toggle=\"collapse\"][href=\"#" + element.id + "\"]," + ("[data-toggle=\"collapse\"][data-target=\"#" + element.id + "\"]")));
  2960. var toggleList = [].slice.call(document.querySelectorAll(Selector$3.DATA_TOGGLE));
  2961. for (var i = 0, len = toggleList.length; i < len; i++) {
  2962. var elem = toggleList[i];
  2963. var selector = Util.getSelectorFromElement(elem);
  2964. var filterElement = [].slice.call(document.querySelectorAll(selector)).filter(function (foundElem) {
  2965. return foundElem === element;
  2966. });
  2967. if (selector !== null && filterElement.length > 0) {
  2968. this._selector = selector;
  2969. this._triggerArray.push(elem);
  2970. }
  2971. }
  2972. this._parent = this._config.parent ? this._getParent() : null;
  2973. if (!this._config.parent) {
  2974. this._addAriaAndCollapsedClass(this._element, this._triggerArray);
  2975. }
  2976. if (this._config.toggle) {
  2977. this.toggle();
  2978. }
  2979. } // Getters
  2980. var _proto = Collapse.prototype;
  2981. // Public
  2982. _proto.toggle = function toggle() {
  2983. if ($(this._element).hasClass(ClassName$3.SHOW)) {
  2984. this.hide();
  2985. } else {
  2986. this.show();
  2987. }
  2988. };
  2989. _proto.show = function show() {
  2990. var _this = this;
  2991. if (this._isTransitioning || $(this._element).hasClass(ClassName$3.SHOW)) {
  2992. return;
  2993. }
  2994. var actives;
  2995. var activesData;
  2996. if (this._parent) {
  2997. actives = [].slice.call(this._parent.querySelectorAll(Selector$3.ACTIVES)).filter(function (elem) {
  2998. if (typeof _this._config.parent === 'string') {
  2999. return elem.getAttribute('data-parent') === _this._config.parent;
  3000. }
  3001. return elem.classList.contains(ClassName$3.COLLAPSE);
  3002. });
  3003. if (actives.length === 0) {
  3004. actives = null;
  3005. }
  3006. }
  3007. if (actives) {
  3008. activesData = $(actives).not(this._selector).data(DATA_KEY$3);
  3009. if (activesData && activesData._isTransitioning) {
  3010. return;
  3011. }
  3012. }
  3013. var startEvent = $.Event(Event$3.SHOW);
  3014. $(this._element).trigger(startEvent);
  3015. if (startEvent.isDefaultPrevented()) {
  3016. return;
  3017. }
  3018. if (actives) {
  3019. Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
  3020. if (!activesData) {
  3021. $(actives).data(DATA_KEY$3, null);
  3022. }
  3023. }
  3024. var dimension = this._getDimension();
  3025. $(this._element).removeClass(ClassName$3.COLLAPSE).addClass(ClassName$3.COLLAPSING);
  3026. this._element.style[dimension] = 0;
  3027. if (this._triggerArray.length) {
  3028. $(this._triggerArray).removeClass(ClassName$3.COLLAPSED).attr('aria-expanded', true);
  3029. }
  3030. this.setTransitioning(true);
  3031. var complete = function complete() {
  3032. $(_this._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).addClass(ClassName$3.SHOW);
  3033. _this._element.style[dimension] = '';
  3034. _this.setTransitioning(false);
  3035. $(_this._element).trigger(Event$3.SHOWN);
  3036. };
  3037. var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
  3038. var scrollSize = "scroll" + capitalizedDimension;
  3039. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3040. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3041. this._element.style[dimension] = this._element[scrollSize] + "px";
  3042. };
  3043. _proto.hide = function hide() {
  3044. var _this2 = this;
  3045. if (this._isTransitioning || !$(this._element).hasClass(ClassName$3.SHOW)) {
  3046. return;
  3047. }
  3048. var startEvent = $.Event(Event$3.HIDE);
  3049. $(this._element).trigger(startEvent);
  3050. if (startEvent.isDefaultPrevented()) {
  3051. return;
  3052. }
  3053. var dimension = this._getDimension();
  3054. this._element.style[dimension] = this._element.getBoundingClientRect()[dimension] + "px";
  3055. Util.reflow(this._element);
  3056. $(this._element).addClass(ClassName$3.COLLAPSING).removeClass(ClassName$3.COLLAPSE).removeClass(ClassName$3.SHOW);
  3057. var triggerArrayLength = this._triggerArray.length;
  3058. if (triggerArrayLength > 0) {
  3059. for (var i = 0; i < triggerArrayLength; i++) {
  3060. var trigger = this._triggerArray[i];
  3061. var selector = Util.getSelectorFromElement(trigger);
  3062. if (selector !== null) {
  3063. var $elem = $([].slice.call(document.querySelectorAll(selector)));
  3064. if (!$elem.hasClass(ClassName$3.SHOW)) {
  3065. $(trigger).addClass(ClassName$3.COLLAPSED).attr('aria-expanded', false);
  3066. }
  3067. }
  3068. }
  3069. }
  3070. this.setTransitioning(true);
  3071. var complete = function complete() {
  3072. _this2.setTransitioning(false);
  3073. $(_this2._element).removeClass(ClassName$3.COLLAPSING).addClass(ClassName$3.COLLAPSE).trigger(Event$3.HIDDEN);
  3074. };
  3075. this._element.style[dimension] = '';
  3076. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3077. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  3078. };
  3079. _proto.setTransitioning = function setTransitioning(isTransitioning) {
  3080. this._isTransitioning = isTransitioning;
  3081. };
  3082. _proto.dispose = function dispose() {
  3083. $.removeData(this._element, DATA_KEY$3);
  3084. this._config = null;
  3085. this._parent = null;
  3086. this._element = null;
  3087. this._triggerArray = null;
  3088. this._isTransitioning = null;
  3089. } // Private
  3090. ;
  3091. _proto._getConfig = function _getConfig(config) {
  3092. config = _objectSpread2({}, Default$1, {}, config);
  3093. config.toggle = Boolean(config.toggle); // Coerce string values
  3094. Util.typeCheckConfig(NAME$3, config, DefaultType$1);
  3095. return config;
  3096. };
  3097. _proto._getDimension = function _getDimension() {
  3098. var hasWidth = $(this._element).hasClass(Dimension.WIDTH);
  3099. return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT;
  3100. };
  3101. _proto._getParent = function _getParent() {
  3102. var _this3 = this;
  3103. var parent;
  3104. if (Util.isElement(this._config.parent)) {
  3105. parent = this._config.parent; // It's a jQuery object
  3106. if (typeof this._config.parent.jquery !== 'undefined') {
  3107. parent = this._config.parent[0];
  3108. }
  3109. } else {
  3110. parent = document.querySelector(this._config.parent);
  3111. }
  3112. var selector = "[data-toggle=\"collapse\"][data-parent=\"" + this._config.parent + "\"]";
  3113. var children = [].slice.call(parent.querySelectorAll(selector));
  3114. $(children).each(function (i, element) {
  3115. _this3._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]);
  3116. });
  3117. return parent;
  3118. };
  3119. _proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
  3120. var isOpen = $(element).hasClass(ClassName$3.SHOW);
  3121. if (triggerArray.length) {
  3122. $(triggerArray).toggleClass(ClassName$3.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
  3123. }
  3124. } // Static
  3125. ;
  3126. Collapse._getTargetFromElement = function _getTargetFromElement(element) {
  3127. var selector = Util.getSelectorFromElement(element);
  3128. return selector ? document.querySelector(selector) : null;
  3129. };
  3130. Collapse._jQueryInterface = function _jQueryInterface(config) {
  3131. return this.each(function () {
  3132. var $this = $(this);
  3133. var data = $this.data(DATA_KEY$3);
  3134. var _config = _objectSpread2({}, Default$1, {}, $this.data(), {}, typeof config === 'object' && config ? config : {});
  3135. if (!data && _config.toggle && /show|hide/.test(config)) {
  3136. _config.toggle = false;
  3137. }
  3138. if (!data) {
  3139. data = new Collapse(this, _config);
  3140. $this.data(DATA_KEY$3, data);
  3141. }
  3142. if (typeof config === 'string') {
  3143. if (typeof data[config] === 'undefined') {
  3144. throw new TypeError("No method named \"" + config + "\"");
  3145. }
  3146. data[config]();
  3147. }
  3148. });
  3149. };
  3150. _createClass(Collapse, null, [{
  3151. key: "VERSION",
  3152. get: function get() {
  3153. return VERSION$3;
  3154. }
  3155. }, {
  3156. key: "Default",
  3157. get: function get() {
  3158. return Default$1;
  3159. }
  3160. }]);
  3161. return Collapse;
  3162. }();
  3163. /**
  3164. * ------------------------------------------------------------------------
  3165. * Data Api implementation
  3166. * ------------------------------------------------------------------------
  3167. */
  3168. $(document).on(Event$3.CLICK_DATA_API, Selector$3.DATA_TOGGLE, function (event) {
  3169. // preventDefault only for <a> elements (which change the URL) not inside the collapsible element
  3170. if (event.currentTarget.tagName === 'A') {
  3171. event.preventDefault();
  3172. }
  3173. var $trigger = $(this);
  3174. var selector = Util.getSelectorFromElement(this);
  3175. var selectors = [].slice.call(document.querySelectorAll(selector));
  3176. $(selectors).each(function () {
  3177. var $target = $(this);
  3178. var data = $target.data(DATA_KEY$3);
  3179. var config = data ? 'toggle' : $trigger.data();
  3180. Collapse._jQueryInterface.call($target, config);
  3181. });
  3182. });
  3183. /**
  3184. * ------------------------------------------------------------------------
  3185. * jQuery
  3186. * ------------------------------------------------------------------------
  3187. */
  3188. $.fn[NAME$3] = Collapse._jQueryInterface;
  3189. $.fn[NAME$3].Constructor = Collapse;
  3190. $.fn[NAME$3].noConflict = function () {
  3191. $.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
  3192. return Collapse._jQueryInterface;
  3193. };
  3194. /**
  3195. * ------------------------------------------------------------------------
  3196. * Constants
  3197. * ------------------------------------------------------------------------
  3198. */
  3199. var NAME$4 = 'dropdown';
  3200. var VERSION$4 = '4.4.1';
  3201. var DATA_KEY$4 = 'bs.dropdown';
  3202. var EVENT_KEY$4 = "." + DATA_KEY$4;
  3203. var DATA_API_KEY$4 = '.data-api';
  3204. var JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
  3205. var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
  3206. var SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
  3207. var TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
  3208. var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
  3209. var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
  3210. var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
  3211. var REGEXP_KEYDOWN = new RegExp(ARROW_UP_KEYCODE + "|" + ARROW_DOWN_KEYCODE + "|" + ESCAPE_KEYCODE);
  3212. var Event$4 = {
  3213. HIDE: "hide" + EVENT_KEY$4,
  3214. HIDDEN: "hidden" + EVENT_KEY$4,
  3215. SHOW: "show" + EVENT_KEY$4,
  3216. SHOWN: "shown" + EVENT_KEY$4,
  3217. CLICK: "click" + EVENT_KEY$4,
  3218. CLICK_DATA_API: "click" + EVENT_KEY$4 + DATA_API_KEY$4,
  3219. KEYDOWN_DATA_API: "keydown" + EVENT_KEY$4 + DATA_API_KEY$4,
  3220. KEYUP_DATA_API: "keyup" + EVENT_KEY$4 + DATA_API_KEY$4
  3221. };
  3222. var ClassName$4 = {
  3223. DISABLED: 'disabled',
  3224. SHOW: 'show',
  3225. DROPUP: 'dropup',
  3226. DROPRIGHT: 'dropright',
  3227. DROPLEFT: 'dropleft',
  3228. MENURIGHT: 'dropdown-menu-right',
  3229. MENULEFT: 'dropdown-menu-left',
  3230. POSITION_STATIC: 'position-static'
  3231. };
  3232. var Selector$4 = {
  3233. DATA_TOGGLE: '[data-toggle="dropdown"]',
  3234. FORM_CHILD: '.dropdown form',
  3235. MENU: '.dropdown-menu',
  3236. NAVBAR_NAV: '.navbar-nav',
  3237. VISIBLE_ITEMS: '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'
  3238. };
  3239. var AttachmentMap = {
  3240. TOP: 'top-start',
  3241. TOPEND: 'top-end',
  3242. BOTTOM: 'bottom-start',
  3243. BOTTOMEND: 'bottom-end',
  3244. RIGHT: 'right-start',
  3245. RIGHTEND: 'right-end',
  3246. LEFT: 'left-start',
  3247. LEFTEND: 'left-end'
  3248. };
  3249. var Default$2 = {
  3250. offset: 0,
  3251. flip: true,
  3252. boundary: 'scrollParent',
  3253. reference: 'toggle',
  3254. display: 'dynamic',
  3255. popperConfig: null
  3256. };
  3257. var DefaultType$2 = {
  3258. offset: '(number|string|function)',
  3259. flip: 'boolean',
  3260. boundary: '(string|element)',
  3261. reference: '(string|element)',
  3262. display: 'string',
  3263. popperConfig: '(null|object)'
  3264. };
  3265. /**
  3266. * ------------------------------------------------------------------------
  3267. * Class Definition
  3268. * ------------------------------------------------------------------------
  3269. */
  3270. var Dropdown =
  3271. /*#__PURE__*/
  3272. function () {
  3273. function Dropdown(element, config) {
  3274. this._element = element;
  3275. this._popper = null;
  3276. this._config = this._getConfig(config);
  3277. this._menu = this._getMenuElement();
  3278. this._inNavbar = this._detectNavbar();
  3279. this._addEventListeners();
  3280. } // Getters
  3281. var _proto = Dropdown.prototype;
  3282. // Public
  3283. _proto.toggle = function toggle() {
  3284. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED)) {
  3285. return;
  3286. }
  3287. var isActive = $(this._menu).hasClass(ClassName$4.SHOW);
  3288. Dropdown._clearMenus();
  3289. if (isActive) {
  3290. return;
  3291. }
  3292. this.show(true);
  3293. };
  3294. _proto.show = function show(usePopper) {
  3295. if (usePopper === void 0) {
  3296. usePopper = false;
  3297. }
  3298. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || $(this._menu).hasClass(ClassName$4.SHOW)) {
  3299. return;
  3300. }
  3301. var relatedTarget = {
  3302. relatedTarget: this._element
  3303. };
  3304. var showEvent = $.Event(Event$4.SHOW, relatedTarget);
  3305. var parent = Dropdown._getParentFromElement(this._element);
  3306. $(parent).trigger(showEvent);
  3307. if (showEvent.isDefaultPrevented()) {
  3308. return;
  3309. } // Disable totally Popper.js for Dropdown in Navbar
  3310. if (!this._inNavbar && usePopper) {
  3311. /**
  3312. * Check for Popper dependency
  3313. * Popper - https://popper.js.org
  3314. */
  3315. if (typeof Popper === 'undefined') {
  3316. throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)');
  3317. }
  3318. var referenceElement = this._element;
  3319. if (this._config.reference === 'parent') {
  3320. referenceElement = parent;
  3321. } else if (Util.isElement(this._config.reference)) {
  3322. referenceElement = this._config.reference; // Check if it's jQuery element
  3323. if (typeof this._config.reference.jquery !== 'undefined') {
  3324. referenceElement = this._config.reference[0];
  3325. }
  3326. } // If boundary is not `scrollParent`, then set position to `static`
  3327. // to allow the menu to "escape" the scroll parent's boundaries
  3328. // https://github.com/twbs/bootstrap/issues/24251
  3329. if (this._config.boundary !== 'scrollParent') {
  3330. $(parent).addClass(ClassName$4.POSITION_STATIC);
  3331. }
  3332. this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
  3333. } // If this is a touch-enabled device we add extra
  3334. // empty mouseover listeners to the body's immediate children;
  3335. // only needed because of broken event delegation on iOS
  3336. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  3337. if ('ontouchstart' in document.documentElement && $(parent).closest(Selector$4.NAVBAR_NAV).length === 0) {
  3338. $(document.body).children().on('mouseover', null, $.noop);
  3339. }
  3340. this._element.focus();
  3341. this._element.setAttribute('aria-expanded', true);
  3342. $(this._menu).toggleClass(ClassName$4.SHOW);
  3343. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.SHOWN, relatedTarget));
  3344. };
  3345. _proto.hide = function hide() {
  3346. if (this._element.disabled || $(this._element).hasClass(ClassName$4.DISABLED) || !$(this._menu).hasClass(ClassName$4.SHOW)) {
  3347. return;
  3348. }
  3349. var relatedTarget = {
  3350. relatedTarget: this._element
  3351. };
  3352. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3353. var parent = Dropdown._getParentFromElement(this._element);
  3354. $(parent).trigger(hideEvent);
  3355. if (hideEvent.isDefaultPrevented()) {
  3356. return;
  3357. }
  3358. if (this._popper) {
  3359. this._popper.destroy();
  3360. }
  3361. $(this._menu).toggleClass(ClassName$4.SHOW);
  3362. $(parent).toggleClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3363. };
  3364. _proto.dispose = function dispose() {
  3365. $.removeData(this._element, DATA_KEY$4);
  3366. $(this._element).off(EVENT_KEY$4);
  3367. this._element = null;
  3368. this._menu = null;
  3369. if (this._popper !== null) {
  3370. this._popper.destroy();
  3371. this._popper = null;
  3372. }
  3373. };
  3374. _proto.update = function update() {
  3375. this._inNavbar = this._detectNavbar();
  3376. if (this._popper !== null) {
  3377. this._popper.scheduleUpdate();
  3378. }
  3379. } // Private
  3380. ;
  3381. _proto._addEventListeners = function _addEventListeners() {
  3382. var _this = this;
  3383. $(this._element).on(Event$4.CLICK, function (event) {
  3384. event.preventDefault();
  3385. event.stopPropagation();
  3386. _this.toggle();
  3387. });
  3388. };
  3389. _proto._getConfig = function _getConfig(config) {
  3390. config = _objectSpread2({}, this.constructor.Default, {}, $(this._element).data(), {}, config);
  3391. Util.typeCheckConfig(NAME$4, config, this.constructor.DefaultType);
  3392. return config;
  3393. };
  3394. _proto._getMenuElement = function _getMenuElement() {
  3395. if (!this._menu) {
  3396. var parent = Dropdown._getParentFromElement(this._element);
  3397. if (parent) {
  3398. this._menu = parent.querySelector(Selector$4.MENU);
  3399. }
  3400. }
  3401. return this._menu;
  3402. };
  3403. _proto._getPlacement = function _getPlacement() {
  3404. var $parentDropdown = $(this._element.parentNode);
  3405. var placement = AttachmentMap.BOTTOM; // Handle dropup
  3406. if ($parentDropdown.hasClass(ClassName$4.DROPUP)) {
  3407. placement = AttachmentMap.TOP;
  3408. if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3409. placement = AttachmentMap.TOPEND;
  3410. }
  3411. } else if ($parentDropdown.hasClass(ClassName$4.DROPRIGHT)) {
  3412. placement = AttachmentMap.RIGHT;
  3413. } else if ($parentDropdown.hasClass(ClassName$4.DROPLEFT)) {
  3414. placement = AttachmentMap.LEFT;
  3415. } else if ($(this._menu).hasClass(ClassName$4.MENURIGHT)) {
  3416. placement = AttachmentMap.BOTTOMEND;
  3417. }
  3418. return placement;
  3419. };
  3420. _proto._detectNavbar = function _detectNavbar() {
  3421. return $(this._element).closest('.navbar').length > 0;
  3422. };
  3423. _proto._getOffset = function _getOffset() {
  3424. var _this2 = this;
  3425. var offset = {};
  3426. if (typeof this._config.offset === 'function') {
  3427. offset.fn = function (data) {
  3428. data.offsets = _objectSpread2({}, data.offsets, {}, _this2._config.offset(data.offsets, _this2._element) || {});
  3429. return data;
  3430. };
  3431. } else {
  3432. offset.offset = this._config.offset;
  3433. }
  3434. return offset;
  3435. };
  3436. _proto._getPopperConfig = function _getPopperConfig() {
  3437. var popperConfig = {
  3438. placement: this._getPlacement(),
  3439. modifiers: {
  3440. offset: this._getOffset(),
  3441. flip: {
  3442. enabled: this._config.flip
  3443. },
  3444. preventOverflow: {
  3445. boundariesElement: this._config.boundary
  3446. }
  3447. }
  3448. }; // Disable Popper.js if we have a static display
  3449. if (this._config.display === 'static') {
  3450. popperConfig.modifiers.applyStyle = {
  3451. enabled: false
  3452. };
  3453. }
  3454. return _objectSpread2({}, popperConfig, {}, this._config.popperConfig);
  3455. } // Static
  3456. ;
  3457. Dropdown._jQueryInterface = function _jQueryInterface(config) {
  3458. return this.each(function () {
  3459. var data = $(this).data(DATA_KEY$4);
  3460. var _config = typeof config === 'object' ? config : null;
  3461. if (!data) {
  3462. data = new Dropdown(this, _config);
  3463. $(this).data(DATA_KEY$4, data);
  3464. }
  3465. if (typeof config === 'string') {
  3466. if (typeof data[config] === 'undefined') {
  3467. throw new TypeError("No method named \"" + config + "\"");
  3468. }
  3469. data[config]();
  3470. }
  3471. });
  3472. };
  3473. Dropdown._clearMenus = function _clearMenus(event) {
  3474. if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH || event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
  3475. return;
  3476. }
  3477. var toggles = [].slice.call(document.querySelectorAll(Selector$4.DATA_TOGGLE));
  3478. for (var i = 0, len = toggles.length; i < len; i++) {
  3479. var parent = Dropdown._getParentFromElement(toggles[i]);
  3480. var context = $(toggles[i]).data(DATA_KEY$4);
  3481. var relatedTarget = {
  3482. relatedTarget: toggles[i]
  3483. };
  3484. if (event && event.type === 'click') {
  3485. relatedTarget.clickEvent = event;
  3486. }
  3487. if (!context) {
  3488. continue;
  3489. }
  3490. var dropdownMenu = context._menu;
  3491. if (!$(parent).hasClass(ClassName$4.SHOW)) {
  3492. continue;
  3493. }
  3494. if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) && $.contains(parent, event.target)) {
  3495. continue;
  3496. }
  3497. var hideEvent = $.Event(Event$4.HIDE, relatedTarget);
  3498. $(parent).trigger(hideEvent);
  3499. if (hideEvent.isDefaultPrevented()) {
  3500. continue;
  3501. } // If this is a touch-enabled device we remove the extra
  3502. // empty mouseover listeners we added for iOS support
  3503. if ('ontouchstart' in document.documentElement) {
  3504. $(document.body).children().off('mouseover', null, $.noop);
  3505. }
  3506. toggles[i].setAttribute('aria-expanded', 'false');
  3507. if (context._popper) {
  3508. context._popper.destroy();
  3509. }
  3510. $(dropdownMenu).removeClass(ClassName$4.SHOW);
  3511. $(parent).removeClass(ClassName$4.SHOW).trigger($.Event(Event$4.HIDDEN, relatedTarget));
  3512. }
  3513. };
  3514. Dropdown._getParentFromElement = function _getParentFromElement(element) {
  3515. var parent;
  3516. var selector = Util.getSelectorFromElement(element);
  3517. if (selector) {
  3518. parent = document.querySelector(selector);
  3519. }
  3520. return parent || element.parentNode;
  3521. } // eslint-disable-next-line complexity
  3522. ;
  3523. Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) {
  3524. // If not input/textarea:
  3525. // - And not a key in REGEXP_KEYDOWN => not a dropdown command
  3526. // If input/textarea:
  3527. // - If space key => not a dropdown command
  3528. // - If key is other than escape
  3529. // - If key is not up or down => not a dropdown command
  3530. // - If trigger inside the menu => not a dropdown command
  3531. 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)) {
  3532. return;
  3533. }
  3534. event.preventDefault();
  3535. event.stopPropagation();
  3536. if (this.disabled || $(this).hasClass(ClassName$4.DISABLED)) {
  3537. return;
  3538. }
  3539. var parent = Dropdown._getParentFromElement(this);
  3540. var isActive = $(parent).hasClass(ClassName$4.SHOW);
  3541. if (!isActive && event.which === ESCAPE_KEYCODE) {
  3542. return;
  3543. }
  3544. if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
  3545. if (event.which === ESCAPE_KEYCODE) {
  3546. var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
  3547. $(toggle).trigger('focus');
  3548. }
  3549. $(this).trigger('click');
  3550. return;
  3551. }
  3552. var items = [].slice.call(parent.querySelectorAll(Selector$4.VISIBLE_ITEMS)).filter(function (item) {
  3553. return $(item).is(':visible');
  3554. });
  3555. if (items.length === 0) {
  3556. return;
  3557. }
  3558. var index = items.indexOf(event.target);
  3559. if (event.which === ARROW_UP_KEYCODE && index > 0) {
  3560. // Up
  3561. index--;
  3562. }
  3563. if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) {
  3564. // Down
  3565. index++;
  3566. }
  3567. if (index < 0) {
  3568. index = 0;
  3569. }
  3570. items[index].focus();
  3571. };
  3572. _createClass(Dropdown, null, [{
  3573. key: "VERSION",
  3574. get: function get() {
  3575. return VERSION$4;
  3576. }
  3577. }, {
  3578. key: "Default",
  3579. get: function get() {
  3580. return Default$2;
  3581. }
  3582. }, {
  3583. key: "DefaultType",
  3584. get: function get() {
  3585. return DefaultType$2;
  3586. }
  3587. }]);
  3588. return Dropdown;
  3589. }();
  3590. /**
  3591. * ------------------------------------------------------------------------
  3592. * Data Api implementation
  3593. * ------------------------------------------------------------------------
  3594. */
  3595. $(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) {
  3596. event.preventDefault();
  3597. event.stopPropagation();
  3598. Dropdown._jQueryInterface.call($(this), 'toggle');
  3599. }).on(Event$4.CLICK_DATA_API, Selector$4.FORM_CHILD, function (e) {
  3600. e.stopPropagation();
  3601. });
  3602. /**
  3603. * ------------------------------------------------------------------------
  3604. * jQuery
  3605. * ------------------------------------------------------------------------
  3606. */
  3607. $.fn[NAME$4] = Dropdown._jQueryInterface;
  3608. $.fn[NAME$4].Constructor = Dropdown;
  3609. $.fn[NAME$4].noConflict = function () {
  3610. $.fn[NAME$4] = JQUERY_NO_CONFLICT$4;
  3611. return Dropdown._jQueryInterface;
  3612. };
  3613. /**
  3614. * ------------------------------------------------------------------------
  3615. * Constants
  3616. * ------------------------------------------------------------------------
  3617. */
  3618. var NAME$5 = 'modal';
  3619. var VERSION$5 = '4.4.1';
  3620. var DATA_KEY$5 = 'bs.modal';
  3621. var EVENT_KEY$5 = "." + DATA_KEY$5;
  3622. var DATA_API_KEY$5 = '.data-api';
  3623. var JQUERY_NO_CONFLICT$5 = $.fn[NAME$5];
  3624. var ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
  3625. var Default$3 = {
  3626. backdrop: true,
  3627. keyboard: true,
  3628. focus: true,
  3629. show: true
  3630. };
  3631. var DefaultType$3 = {
  3632. backdrop: '(boolean|string)',
  3633. keyboard: 'boolean',
  3634. focus: 'boolean',
  3635. show: 'boolean'
  3636. };
  3637. var Event$5 = {
  3638. HIDE: "hide" + EVENT_KEY$5,
  3639. HIDE_PREVENTED: "hidePrevented" + EVENT_KEY$5,
  3640. HIDDEN: "hidden" + EVENT_KEY$5,
  3641. SHOW: "show" + EVENT_KEY$5,
  3642. SHOWN: "shown" + EVENT_KEY$5,
  3643. FOCUSIN: "focusin" + EVENT_KEY$5,
  3644. RESIZE: "resize" + EVENT_KEY$5,
  3645. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$5,
  3646. KEYDOWN_DISMISS: "keydown.dismiss" + EVENT_KEY$5,
  3647. MOUSEUP_DISMISS: "mouseup.dismiss" + EVENT_KEY$5,
  3648. MOUSEDOWN_DISMISS: "mousedown.dismiss" + EVENT_KEY$5,
  3649. CLICK_DATA_API: "click" + EVENT_KEY$5 + DATA_API_KEY$5
  3650. };
  3651. var ClassName$5 = {
  3652. SCROLLABLE: 'modal-dialog-scrollable',
  3653. SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
  3654. BACKDROP: 'modal-backdrop',
  3655. OPEN: 'modal-open',
  3656. FADE: 'fade',
  3657. SHOW: 'show',
  3658. STATIC: 'modal-static'
  3659. };
  3660. var Selector$5 = {
  3661. DIALOG: '.modal-dialog',
  3662. MODAL_BODY: '.modal-body',
  3663. DATA_TOGGLE: '[data-toggle="modal"]',
  3664. DATA_DISMISS: '[data-dismiss="modal"]',
  3665. FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top',
  3666. STICKY_CONTENT: '.sticky-top'
  3667. };
  3668. /**
  3669. * ------------------------------------------------------------------------
  3670. * Class Definition
  3671. * ------------------------------------------------------------------------
  3672. */
  3673. var Modal =
  3674. /*#__PURE__*/
  3675. function () {
  3676. function Modal(element, config) {
  3677. this._config = this._getConfig(config);
  3678. this._element = element;
  3679. this._dialog = element.querySelector(Selector$5.DIALOG);
  3680. this._backdrop = null;
  3681. this._isShown = false;
  3682. this._isBodyOverflowing = false;
  3683. this._ignoreBackdropClick = false;
  3684. this._isTransitioning = false;
  3685. this._scrollbarWidth = 0;
  3686. } // Getters
  3687. var _proto = Modal.prototype;
  3688. // Public
  3689. _proto.toggle = function toggle(relatedTarget) {
  3690. return this._isShown ? this.hide() : this.show(relatedTarget);
  3691. };
  3692. _proto.show = function show(relatedTarget) {
  3693. var _this = this;
  3694. if (this._isShown || this._isTransitioning) {
  3695. return;
  3696. }
  3697. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3698. this._isTransitioning = true;
  3699. }
  3700. var showEvent = $.Event(Event$5.SHOW, {
  3701. relatedTarget: relatedTarget
  3702. });
  3703. $(this._element).trigger(showEvent);
  3704. if (this._isShown || showEvent.isDefaultPrevented()) {
  3705. return;
  3706. }
  3707. this._isShown = true;
  3708. this._checkScrollbar();
  3709. this._setScrollbar();
  3710. this._adjustDialog();
  3711. this._setEscapeEvent();
  3712. this._setResizeEvent();
  3713. $(this._element).on(Event$5.CLICK_DISMISS, Selector$5.DATA_DISMISS, function (event) {
  3714. return _this.hide(event);
  3715. });
  3716. $(this._dialog).on(Event$5.MOUSEDOWN_DISMISS, function () {
  3717. $(_this._element).one(Event$5.MOUSEUP_DISMISS, function (event) {
  3718. if ($(event.target).is(_this._element)) {
  3719. _this._ignoreBackdropClick = true;
  3720. }
  3721. });
  3722. });
  3723. this._showBackdrop(function () {
  3724. return _this._showElement(relatedTarget);
  3725. });
  3726. };
  3727. _proto.hide = function hide(event) {
  3728. var _this2 = this;
  3729. if (event) {
  3730. event.preventDefault();
  3731. }
  3732. if (!this._isShown || this._isTransitioning) {
  3733. return;
  3734. }
  3735. var hideEvent = $.Event(Event$5.HIDE);
  3736. $(this._element).trigger(hideEvent);
  3737. if (!this._isShown || hideEvent.isDefaultPrevented()) {
  3738. return;
  3739. }
  3740. this._isShown = false;
  3741. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3742. if (transition) {
  3743. this._isTransitioning = true;
  3744. }
  3745. this._setEscapeEvent();
  3746. this._setResizeEvent();
  3747. $(document).off(Event$5.FOCUSIN);
  3748. $(this._element).removeClass(ClassName$5.SHOW);
  3749. $(this._element).off(Event$5.CLICK_DISMISS);
  3750. $(this._dialog).off(Event$5.MOUSEDOWN_DISMISS);
  3751. if (transition) {
  3752. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  3753. $(this._element).one(Util.TRANSITION_END, function (event) {
  3754. return _this2._hideModal(event);
  3755. }).emulateTransitionEnd(transitionDuration);
  3756. } else {
  3757. this._hideModal();
  3758. }
  3759. };
  3760. _proto.dispose = function dispose() {
  3761. [window, this._element, this._dialog].forEach(function (htmlElement) {
  3762. return $(htmlElement).off(EVENT_KEY$5);
  3763. });
  3764. /**
  3765. * `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
  3766. * Do not move `document` in `htmlElements` array
  3767. * It will remove `Event.CLICK_DATA_API` event that should remain
  3768. */
  3769. $(document).off(Event$5.FOCUSIN);
  3770. $.removeData(this._element, DATA_KEY$5);
  3771. this._config = null;
  3772. this._element = null;
  3773. this._dialog = null;
  3774. this._backdrop = null;
  3775. this._isShown = null;
  3776. this._isBodyOverflowing = null;
  3777. this._ignoreBackdropClick = null;
  3778. this._isTransitioning = null;
  3779. this._scrollbarWidth = null;
  3780. };
  3781. _proto.handleUpdate = function handleUpdate() {
  3782. this._adjustDialog();
  3783. } // Private
  3784. ;
  3785. _proto._getConfig = function _getConfig(config) {
  3786. config = _objectSpread2({}, Default$3, {}, config);
  3787. Util.typeCheckConfig(NAME$5, config, DefaultType$3);
  3788. return config;
  3789. };
  3790. _proto._triggerBackdropTransition = function _triggerBackdropTransition() {
  3791. var _this3 = this;
  3792. if (this._config.backdrop === 'static') {
  3793. var hideEventPrevented = $.Event(Event$5.HIDE_PREVENTED);
  3794. $(this._element).trigger(hideEventPrevented);
  3795. if (hideEventPrevented.defaultPrevented) {
  3796. return;
  3797. }
  3798. this._element.classList.add(ClassName$5.STATIC);
  3799. var modalTransitionDuration = Util.getTransitionDurationFromElement(this._element);
  3800. $(this._element).one(Util.TRANSITION_END, function () {
  3801. _this3._element.classList.remove(ClassName$5.STATIC);
  3802. }).emulateTransitionEnd(modalTransitionDuration);
  3803. this._element.focus();
  3804. } else {
  3805. this.hide();
  3806. }
  3807. };
  3808. _proto._showElement = function _showElement(relatedTarget) {
  3809. var _this4 = this;
  3810. var transition = $(this._element).hasClass(ClassName$5.FADE);
  3811. var modalBody = this._dialog ? this._dialog.querySelector(Selector$5.MODAL_BODY) : null;
  3812. if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
  3813. // Don't move modal's DOM position
  3814. document.body.appendChild(this._element);
  3815. }
  3816. this._element.style.display = 'block';
  3817. this._element.removeAttribute('aria-hidden');
  3818. this._element.setAttribute('aria-modal', true);
  3819. if ($(this._dialog).hasClass(ClassName$5.SCROLLABLE) && modalBody) {
  3820. modalBody.scrollTop = 0;
  3821. } else {
  3822. this._element.scrollTop = 0;
  3823. }
  3824. if (transition) {
  3825. Util.reflow(this._element);
  3826. }
  3827. $(this._element).addClass(ClassName$5.SHOW);
  3828. if (this._config.focus) {
  3829. this._enforceFocus();
  3830. }
  3831. var shownEvent = $.Event(Event$5.SHOWN, {
  3832. relatedTarget: relatedTarget
  3833. });
  3834. var transitionComplete = function transitionComplete() {
  3835. if (_this4._config.focus) {
  3836. _this4._element.focus();
  3837. }
  3838. _this4._isTransitioning = false;
  3839. $(_this4._element).trigger(shownEvent);
  3840. };
  3841. if (transition) {
  3842. var transitionDuration = Util.getTransitionDurationFromElement(this._dialog);
  3843. $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(transitionDuration);
  3844. } else {
  3845. transitionComplete();
  3846. }
  3847. };
  3848. _proto._enforceFocus = function _enforceFocus() {
  3849. var _this5 = this;
  3850. $(document).off(Event$5.FOCUSIN) // Guard against infinite focus loop
  3851. .on(Event$5.FOCUSIN, function (event) {
  3852. if (document !== event.target && _this5._element !== event.target && $(_this5._element).has(event.target).length === 0) {
  3853. _this5._element.focus();
  3854. }
  3855. });
  3856. };
  3857. _proto._setEscapeEvent = function _setEscapeEvent() {
  3858. var _this6 = this;
  3859. if (this._isShown && this._config.keyboard) {
  3860. $(this._element).on(Event$5.KEYDOWN_DISMISS, function (event) {
  3861. if (event.which === ESCAPE_KEYCODE$1) {
  3862. _this6._triggerBackdropTransition();
  3863. }
  3864. });
  3865. } else if (!this._isShown) {
  3866. $(this._element).off(Event$5.KEYDOWN_DISMISS);
  3867. }
  3868. };
  3869. _proto._setResizeEvent = function _setResizeEvent() {
  3870. var _this7 = this;
  3871. if (this._isShown) {
  3872. $(window).on(Event$5.RESIZE, function (event) {
  3873. return _this7.handleUpdate(event);
  3874. });
  3875. } else {
  3876. $(window).off(Event$5.RESIZE);
  3877. }
  3878. };
  3879. _proto._hideModal = function _hideModal() {
  3880. var _this8 = this;
  3881. this._element.style.display = 'none';
  3882. this._element.setAttribute('aria-hidden', true);
  3883. this._element.removeAttribute('aria-modal');
  3884. this._isTransitioning = false;
  3885. this._showBackdrop(function () {
  3886. $(document.body).removeClass(ClassName$5.OPEN);
  3887. _this8._resetAdjustments();
  3888. _this8._resetScrollbar();
  3889. $(_this8._element).trigger(Event$5.HIDDEN);
  3890. });
  3891. };
  3892. _proto._removeBackdrop = function _removeBackdrop() {
  3893. if (this._backdrop) {
  3894. $(this._backdrop).remove();
  3895. this._backdrop = null;
  3896. }
  3897. };
  3898. _proto._showBackdrop = function _showBackdrop(callback) {
  3899. var _this9 = this;
  3900. var animate = $(this._element).hasClass(ClassName$5.FADE) ? ClassName$5.FADE : '';
  3901. if (this._isShown && this._config.backdrop) {
  3902. this._backdrop = document.createElement('div');
  3903. this._backdrop.className = ClassName$5.BACKDROP;
  3904. if (animate) {
  3905. this._backdrop.classList.add(animate);
  3906. }
  3907. $(this._backdrop).appendTo(document.body);
  3908. $(this._element).on(Event$5.CLICK_DISMISS, function (event) {
  3909. if (_this9._ignoreBackdropClick) {
  3910. _this9._ignoreBackdropClick = false;
  3911. return;
  3912. }
  3913. if (event.target !== event.currentTarget) {
  3914. return;
  3915. }
  3916. _this9._triggerBackdropTransition();
  3917. });
  3918. if (animate) {
  3919. Util.reflow(this._backdrop);
  3920. }
  3921. $(this._backdrop).addClass(ClassName$5.SHOW);
  3922. if (!callback) {
  3923. return;
  3924. }
  3925. if (!animate) {
  3926. callback();
  3927. return;
  3928. }
  3929. var backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3930. $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(backdropTransitionDuration);
  3931. } else if (!this._isShown && this._backdrop) {
  3932. $(this._backdrop).removeClass(ClassName$5.SHOW);
  3933. var callbackRemove = function callbackRemove() {
  3934. _this9._removeBackdrop();
  3935. if (callback) {
  3936. callback();
  3937. }
  3938. };
  3939. if ($(this._element).hasClass(ClassName$5.FADE)) {
  3940. var _backdropTransitionDuration = Util.getTransitionDurationFromElement(this._backdrop);
  3941. $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(_backdropTransitionDuration);
  3942. } else {
  3943. callbackRemove();
  3944. }
  3945. } else if (callback) {
  3946. callback();
  3947. }
  3948. } // ----------------------------------------------------------------------
  3949. // the following methods are used to handle overflowing modals
  3950. // todo (fat): these should probably be refactored out of modal.js
  3951. // ----------------------------------------------------------------------
  3952. ;
  3953. _proto._adjustDialog = function _adjustDialog() {
  3954. var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight;
  3955. if (!this._isBodyOverflowing && isModalOverflowing) {
  3956. this._element.style.paddingLeft = this._scrollbarWidth + "px";
  3957. }
  3958. if (this._isBodyOverflowing && !isModalOverflowing) {
  3959. this._element.style.paddingRight = this._scrollbarWidth + "px";
  3960. }
  3961. };
  3962. _proto._resetAdjustments = function _resetAdjustments() {
  3963. this._element.style.paddingLeft = '';
  3964. this._element.style.paddingRight = '';
  3965. };
  3966. _proto._checkScrollbar = function _checkScrollbar() {
  3967. var rect = document.body.getBoundingClientRect();
  3968. this._isBodyOverflowing = rect.left + rect.right < window.innerWidth;
  3969. this._scrollbarWidth = this._getScrollbarWidth();
  3970. };
  3971. _proto._setScrollbar = function _setScrollbar() {
  3972. var _this10 = this;
  3973. if (this._isBodyOverflowing) {
  3974. // Note: DOMNode.style.paddingRight returns the actual value or '' if not set
  3975. // while $(DOMNode).css('padding-right') returns the calculated value or 0 if not set
  3976. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3977. var stickyContent = [].slice.call(document.querySelectorAll(Selector$5.STICKY_CONTENT)); // Adjust fixed content padding
  3978. $(fixedContent).each(function (index, element) {
  3979. var actualPadding = element.style.paddingRight;
  3980. var calculatedPadding = $(element).css('padding-right');
  3981. $(element).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + _this10._scrollbarWidth + "px");
  3982. }); // Adjust sticky content margin
  3983. $(stickyContent).each(function (index, element) {
  3984. var actualMargin = element.style.marginRight;
  3985. var calculatedMargin = $(element).css('margin-right');
  3986. $(element).data('margin-right', actualMargin).css('margin-right', parseFloat(calculatedMargin) - _this10._scrollbarWidth + "px");
  3987. }); // Adjust body padding
  3988. var actualPadding = document.body.style.paddingRight;
  3989. var calculatedPadding = $(document.body).css('padding-right');
  3990. $(document.body).data('padding-right', actualPadding).css('padding-right', parseFloat(calculatedPadding) + this._scrollbarWidth + "px");
  3991. }
  3992. $(document.body).addClass(ClassName$5.OPEN);
  3993. };
  3994. _proto._resetScrollbar = function _resetScrollbar() {
  3995. // Restore fixed content padding
  3996. var fixedContent = [].slice.call(document.querySelectorAll(Selector$5.FIXED_CONTENT));
  3997. $(fixedContent).each(function (index, element) {
  3998. var padding = $(element).data('padding-right');
  3999. $(element).removeData('padding-right');
  4000. element.style.paddingRight = padding ? padding : '';
  4001. }); // Restore sticky content
  4002. var elements = [].slice.call(document.querySelectorAll("" + Selector$5.STICKY_CONTENT));
  4003. $(elements).each(function (index, element) {
  4004. var margin = $(element).data('margin-right');
  4005. if (typeof margin !== 'undefined') {
  4006. $(element).css('margin-right', margin).removeData('margin-right');
  4007. }
  4008. }); // Restore body padding
  4009. var padding = $(document.body).data('padding-right');
  4010. $(document.body).removeData('padding-right');
  4011. document.body.style.paddingRight = padding ? padding : '';
  4012. };
  4013. _proto._getScrollbarWidth = function _getScrollbarWidth() {
  4014. // thx d.walsh
  4015. var scrollDiv = document.createElement('div');
  4016. scrollDiv.className = ClassName$5.SCROLLBAR_MEASURER;
  4017. document.body.appendChild(scrollDiv);
  4018. var scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
  4019. document.body.removeChild(scrollDiv);
  4020. return scrollbarWidth;
  4021. } // Static
  4022. ;
  4023. Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) {
  4024. return this.each(function () {
  4025. var data = $(this).data(DATA_KEY$5);
  4026. var _config = _objectSpread2({}, Default$3, {}, $(this).data(), {}, typeof config === 'object' && config ? config : {});
  4027. if (!data) {
  4028. data = new Modal(this, _config);
  4029. $(this).data(DATA_KEY$5, data);
  4030. }
  4031. if (typeof config === 'string') {
  4032. if (typeof data[config] === 'undefined') {
  4033. throw new TypeError("No method named \"" + config + "\"");
  4034. }
  4035. data[config](relatedTarget);
  4036. } else if (_config.show) {
  4037. data.show(relatedTarget);
  4038. }
  4039. });
  4040. };
  4041. _createClass(Modal, null, [{
  4042. key: "VERSION",
  4043. get: function get() {
  4044. return VERSION$5;
  4045. }
  4046. }, {
  4047. key: "Default",
  4048. get: function get() {
  4049. return Default$3;
  4050. }
  4051. }]);
  4052. return Modal;
  4053. }();
  4054. /**
  4055. * ------------------------------------------------------------------------
  4056. * Data Api implementation
  4057. * ------------------------------------------------------------------------
  4058. */
  4059. $(document).on(Event$5.CLICK_DATA_API, Selector$5.DATA_TOGGLE, function (event) {
  4060. var _this11 = this;
  4061. var target;
  4062. var selector = Util.getSelectorFromElement(this);
  4063. if (selector) {
  4064. target = document.querySelector(selector);
  4065. }
  4066. var config = $(target).data(DATA_KEY$5) ? 'toggle' : _objectSpread2({}, $(target).data(), {}, $(this).data());
  4067. if (this.tagName === 'A' || this.tagName === 'AREA') {
  4068. event.preventDefault();
  4069. }
  4070. var $target = $(target).one(Event$5.SHOW, function (showEvent) {
  4071. if (showEvent.isDefaultPrevented()) {
  4072. // Only register focus restorer if modal will actually get shown
  4073. return;
  4074. }
  4075. $target.one(Event$5.HIDDEN, function () {
  4076. if ($(_this11).is(':visible')) {
  4077. _this11.focus();
  4078. }
  4079. });
  4080. });
  4081. Modal._jQueryInterface.call($(target), config, this);
  4082. });
  4083. /**
  4084. * ------------------------------------------------------------------------
  4085. * jQuery
  4086. * ------------------------------------------------------------------------
  4087. */
  4088. $.fn[NAME$5] = Modal._jQueryInterface;
  4089. $.fn[NAME$5].Constructor = Modal;
  4090. $.fn[NAME$5].noConflict = function () {
  4091. $.fn[NAME$5] = JQUERY_NO_CONFLICT$5;
  4092. return Modal._jQueryInterface;
  4093. };
  4094. /**
  4095. * --------------------------------------------------------------------------
  4096. * Bootstrap (v4.4.1): tools/sanitizer.js
  4097. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  4098. * --------------------------------------------------------------------------
  4099. */
  4100. var uriAttrs = ['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href'];
  4101. var ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i;
  4102. var DefaultWhitelist = {
  4103. // Global attributes allowed on any supplied element below.
  4104. '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN],
  4105. a: ['target', 'href', 'title', 'rel'],
  4106. area: [],
  4107. b: [],
  4108. br: [],
  4109. col: [],
  4110. code: [],
  4111. div: [],
  4112. em: [],
  4113. hr: [],
  4114. h1: [],
  4115. h2: [],
  4116. h3: [],
  4117. h4: [],
  4118. h5: [],
  4119. h6: [],
  4120. i: [],
  4121. img: ['src', 'alt', 'title', 'width', 'height'],
  4122. li: [],
  4123. ol: [],
  4124. p: [],
  4125. pre: [],
  4126. s: [],
  4127. small: [],
  4128. span: [],
  4129. sub: [],
  4130. sup: [],
  4131. strong: [],
  4132. u: [],
  4133. ul: []
  4134. };
  4135. /**
  4136. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  4137. *
  4138. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4139. */
  4140. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  4141. /**
  4142. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  4143. *
  4144. * Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts
  4145. */
  4146. 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;
  4147. function allowedAttribute(attr, allowedAttributeList) {
  4148. var attrName = attr.nodeName.toLowerCase();
  4149. if (allowedAttributeList.indexOf(attrName) !== -1) {
  4150. if (uriAttrs.indexOf(attrName) !== -1) {
  4151. return Boolean(attr.nodeValue.match(SAFE_URL_PATTERN) || attr.nodeValue.match(DATA_URL_PATTERN));
  4152. }
  4153. return true;
  4154. }
  4155. var regExp = allowedAttributeList.filter(function (attrRegex) {
  4156. return attrRegex instanceof RegExp;
  4157. }); // Check if a regular expression validates the attribute.
  4158. for (var i = 0, l = regExp.length; i < l; i++) {
  4159. if (attrName.match(regExp[i])) {
  4160. return true;
  4161. }
  4162. }
  4163. return false;
  4164. }
  4165. function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
  4166. if (unsafeHtml.length === 0) {
  4167. return unsafeHtml;
  4168. }
  4169. if (sanitizeFn && typeof sanitizeFn === 'function') {
  4170. return sanitizeFn(unsafeHtml);
  4171. }
  4172. var domParser = new window.DOMParser();
  4173. var createdDocument = domParser.parseFromString(unsafeHtml, 'text/html');
  4174. var whitelistKeys = Object.keys(whiteList);
  4175. var elements = [].slice.call(createdDocument.body.querySelectorAll('*'));
  4176. var _loop = function _loop(i, len) {
  4177. var el = elements[i];
  4178. var elName = el.nodeName.toLowerCase();
  4179. if (whitelistKeys.indexOf(el.nodeName.toLowerCase()) === -1) {
  4180. el.parentNode.removeChild(el);
  4181. return "continue";
  4182. }
  4183. var attributeList = [].slice.call(el.attributes);
  4184. var whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || []);
  4185. attributeList.forEach(function (attr) {
  4186. if (!allowedAttribute(attr, whitelistedAttributes)) {
  4187. el.removeAttribute(attr.nodeName);
  4188. }
  4189. });
  4190. };
  4191. for (var i = 0, len = elements.length; i < len; i++) {
  4192. var _ret = _loop(i);
  4193. if (_ret === "continue") continue;
  4194. }
  4195. return createdDocument.body.innerHTML;
  4196. }
  4197. /**
  4198. * ------------------------------------------------------------------------
  4199. * Constants
  4200. * ------------------------------------------------------------------------
  4201. */
  4202. var NAME$6 = 'tooltip';
  4203. var VERSION$6 = '4.4.1';
  4204. var DATA_KEY$6 = 'bs.tooltip';
  4205. var EVENT_KEY$6 = "." + DATA_KEY$6;
  4206. var JQUERY_NO_CONFLICT$6 = $.fn[NAME$6];
  4207. var CLASS_PREFIX = 'bs-tooltip';
  4208. var BSCLS_PREFIX_REGEX = new RegExp("(^|\\s)" + CLASS_PREFIX + "\\S+", 'g');
  4209. var DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn'];
  4210. var DefaultType$4 = {
  4211. animation: 'boolean',
  4212. template: 'string',
  4213. title: '(string|element|function)',
  4214. trigger: 'string',
  4215. delay: '(number|object)',
  4216. html: 'boolean',
  4217. selector: '(string|boolean)',
  4218. placement: '(string|function)',
  4219. offset: '(number|string|function)',
  4220. container: '(string|element|boolean)',
  4221. fallbackPlacement: '(string|array)',
  4222. boundary: '(string|element)',
  4223. sanitize: 'boolean',
  4224. sanitizeFn: '(null|function)',
  4225. whiteList: 'object',
  4226. popperConfig: '(null|object)'
  4227. };
  4228. var AttachmentMap$1 = {
  4229. AUTO: 'auto',
  4230. TOP: 'top',
  4231. RIGHT: 'right',
  4232. BOTTOM: 'bottom',
  4233. LEFT: 'left'
  4234. };
  4235. var Default$4 = {
  4236. animation: true,
  4237. template: '<div class="tooltip" role="tooltip">' + '<div class="arrow"></div>' + '<div class="tooltip-inner"></div></div>',
  4238. trigger: 'hover focus',
  4239. title: '',
  4240. delay: 0,
  4241. html: false,
  4242. selector: false,
  4243. placement: 'top',
  4244. offset: 0,
  4245. container: false,
  4246. fallbackPlacement: 'flip',
  4247. boundary: 'scrollParent',
  4248. sanitize: true,
  4249. sanitizeFn: null,
  4250. whiteList: DefaultWhitelist,
  4251. popperConfig: null
  4252. };
  4253. var HoverState = {
  4254. SHOW: 'show',
  4255. OUT: 'out'
  4256. };
  4257. var Event$6 = {
  4258. HIDE: "hide" + EVENT_KEY$6,
  4259. HIDDEN: "hidden" + EVENT_KEY$6,
  4260. SHOW: "show" + EVENT_KEY$6,
  4261. SHOWN: "shown" + EVENT_KEY$6,
  4262. INSERTED: "inserted" + EVENT_KEY$6,
  4263. CLICK: "click" + EVENT_KEY$6,
  4264. FOCUSIN: "focusin" + EVENT_KEY$6,
  4265. FOCUSOUT: "focusout" + EVENT_KEY$6,
  4266. MOUSEENTER: "mouseenter" + EVENT_KEY$6,
  4267. MOUSELEAVE: "mouseleave" + EVENT_KEY$6
  4268. };
  4269. var ClassName$6 = {
  4270. FADE: 'fade',
  4271. SHOW: 'show'
  4272. };
  4273. var Selector$6 = {
  4274. TOOLTIP: '.tooltip',
  4275. TOOLTIP_INNER: '.tooltip-inner',
  4276. ARROW: '.arrow'
  4277. };
  4278. var Trigger = {
  4279. HOVER: 'hover',
  4280. FOCUS: 'focus',
  4281. CLICK: 'click',
  4282. MANUAL: 'manual'
  4283. };
  4284. /**
  4285. * ------------------------------------------------------------------------
  4286. * Class Definition
  4287. * ------------------------------------------------------------------------
  4288. */
  4289. var Tooltip =
  4290. /*#__PURE__*/
  4291. function () {
  4292. function Tooltip(element, config) {
  4293. if (typeof Popper === 'undefined') {
  4294. throw new TypeError('Bootstrap\'s tooltips require Popper.js (https://popper.js.org/)');
  4295. } // private
  4296. this._isEnabled = true;
  4297. this._timeout = 0;
  4298. this._hoverState = '';
  4299. this._activeTrigger = {};
  4300. this._popper = null; // Protected
  4301. this.element = element;
  4302. this.config = this._getConfig(config);
  4303. this.tip = null;
  4304. this._setListeners();
  4305. } // Getters
  4306. var _proto = Tooltip.prototype;
  4307. // Public
  4308. _proto.enable = function enable() {
  4309. this._isEnabled = true;
  4310. };
  4311. _proto.disable = function disable() {
  4312. this._isEnabled = false;
  4313. };
  4314. _proto.toggleEnabled = function toggleEnabled() {
  4315. this._isEnabled = !this._isEnabled;
  4316. };
  4317. _proto.toggle = function toggle(event) {
  4318. if (!this._isEnabled) {
  4319. return;
  4320. }
  4321. if (event) {
  4322. var dataKey = this.constructor.DATA_KEY;
  4323. var context = $(event.currentTarget).data(dataKey);
  4324. if (!context) {
  4325. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4326. $(event.currentTarget).data(dataKey, context);
  4327. }
  4328. context._activeTrigger.click = !context._activeTrigger.click;
  4329. if (context._isWithActiveTrigger()) {
  4330. context._enter(null, context);
  4331. } else {
  4332. context._leave(null, context);
  4333. }
  4334. } else {
  4335. if ($(this.getTipElement()).hasClass(ClassName$6.SHOW)) {
  4336. this._leave(null, this);
  4337. return;
  4338. }
  4339. this._enter(null, this);
  4340. }
  4341. };
  4342. _proto.dispose = function dispose() {
  4343. clearTimeout(this._timeout);
  4344. $.removeData(this.element, this.constructor.DATA_KEY);
  4345. $(this.element).off(this.constructor.EVENT_KEY);
  4346. $(this.element).closest('.modal').off('hide.bs.modal', this._hideModalHandler);
  4347. if (this.tip) {
  4348. $(this.tip).remove();
  4349. }
  4350. this._isEnabled = null;
  4351. this._timeout = null;
  4352. this._hoverState = null;
  4353. this._activeTrigger = null;
  4354. if (this._popper) {
  4355. this._popper.destroy();
  4356. }
  4357. this._popper = null;
  4358. this.element = null;
  4359. this.config = null;
  4360. this.tip = null;
  4361. };
  4362. _proto.show = function show() {
  4363. var _this = this;
  4364. if ($(this.element).css('display') === 'none') {
  4365. throw new Error('Please use show on visible elements');
  4366. }
  4367. var showEvent = $.Event(this.constructor.Event.SHOW);
  4368. if (this.isWithContent() && this._isEnabled) {
  4369. $(this.element).trigger(showEvent);
  4370. var shadowRoot = Util.findShadowRoot(this.element);
  4371. var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
  4372. if (showEvent.isDefaultPrevented() || !isInTheDom) {
  4373. return;
  4374. }
  4375. var tip = this.getTipElement();
  4376. var tipId = Util.getUID(this.constructor.NAME);
  4377. tip.setAttribute('id', tipId);
  4378. this.element.setAttribute('aria-describedby', tipId);
  4379. this.setContent();
  4380. if (this.config.animation) {
  4381. $(tip).addClass(ClassName$6.FADE);
  4382. }
  4383. var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement;
  4384. var attachment = this._getAttachment(placement);
  4385. this.addAttachmentClass(attachment);
  4386. var container = this._getContainer();
  4387. $(tip).data(this.constructor.DATA_KEY, this);
  4388. if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
  4389. $(tip).appendTo(container);
  4390. }
  4391. $(this.element).trigger(this.constructor.Event.INSERTED);
  4392. this._popper = new Popper(this.element, tip, this._getPopperConfig(attachment));
  4393. $(tip).addClass(ClassName$6.SHOW); // If this is a touch-enabled device we add extra
  4394. // empty mouseover listeners to the body's immediate children;
  4395. // only needed because of broken event delegation on iOS
  4396. // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
  4397. if ('ontouchstart' in document.documentElement) {
  4398. $(document.body).children().on('mouseover', null, $.noop);
  4399. }
  4400. var complete = function complete() {
  4401. if (_this.config.animation) {
  4402. _this._fixTransition();
  4403. }
  4404. var prevHoverState = _this._hoverState;
  4405. _this._hoverState = null;
  4406. $(_this.element).trigger(_this.constructor.Event.SHOWN);
  4407. if (prevHoverState === HoverState.OUT) {
  4408. _this._leave(null, _this);
  4409. }
  4410. };
  4411. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4412. var transitionDuration = Util.getTransitionDurationFromElement(this.tip);
  4413. $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4414. } else {
  4415. complete();
  4416. }
  4417. }
  4418. };
  4419. _proto.hide = function hide(callback) {
  4420. var _this2 = this;
  4421. var tip = this.getTipElement();
  4422. var hideEvent = $.Event(this.constructor.Event.HIDE);
  4423. var complete = function complete() {
  4424. if (_this2._hoverState !== HoverState.SHOW && tip.parentNode) {
  4425. tip.parentNode.removeChild(tip);
  4426. }
  4427. _this2._cleanTipClass();
  4428. _this2.element.removeAttribute('aria-describedby');
  4429. $(_this2.element).trigger(_this2.constructor.Event.HIDDEN);
  4430. if (_this2._popper !== null) {
  4431. _this2._popper.destroy();
  4432. }
  4433. if (callback) {
  4434. callback();
  4435. }
  4436. };
  4437. $(this.element).trigger(hideEvent);
  4438. if (hideEvent.isDefaultPrevented()) {
  4439. return;
  4440. }
  4441. $(tip).removeClass(ClassName$6.SHOW); // If this is a touch-enabled device we remove the extra
  4442. // empty mouseover listeners we added for iOS support
  4443. if ('ontouchstart' in document.documentElement) {
  4444. $(document.body).children().off('mouseover', null, $.noop);
  4445. }
  4446. this._activeTrigger[Trigger.CLICK] = false;
  4447. this._activeTrigger[Trigger.FOCUS] = false;
  4448. this._activeTrigger[Trigger.HOVER] = false;
  4449. if ($(this.tip).hasClass(ClassName$6.FADE)) {
  4450. var transitionDuration = Util.getTransitionDurationFromElement(tip);
  4451. $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  4452. } else {
  4453. complete();
  4454. }
  4455. this._hoverState = '';
  4456. };
  4457. _proto.update = function update() {
  4458. if (this._popper !== null) {
  4459. this._popper.scheduleUpdate();
  4460. }
  4461. } // Protected
  4462. ;
  4463. _proto.isWithContent = function isWithContent() {
  4464. return Boolean(this.getTitle());
  4465. };
  4466. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4467. $(this.getTipElement()).addClass(CLASS_PREFIX + "-" + attachment);
  4468. };
  4469. _proto.getTipElement = function getTipElement() {
  4470. this.tip = this.tip || $(this.config.template)[0];
  4471. return this.tip;
  4472. };
  4473. _proto.setContent = function setContent() {
  4474. var tip = this.getTipElement();
  4475. this.setElementContent($(tip.querySelectorAll(Selector$6.TOOLTIP_INNER)), this.getTitle());
  4476. $(tip).removeClass(ClassName$6.FADE + " " + ClassName$6.SHOW);
  4477. };
  4478. _proto.setElementContent = function setElementContent($element, content) {
  4479. if (typeof content === 'object' && (content.nodeType || content.jquery)) {
  4480. // Content is a DOM node or a jQuery
  4481. if (this.config.html) {
  4482. if (!$(content).parent().is($element)) {
  4483. $element.empty().append(content);
  4484. }
  4485. } else {
  4486. $element.text($(content).text());
  4487. }
  4488. return;
  4489. }
  4490. if (this.config.html) {
  4491. if (this.config.sanitize) {
  4492. content = sanitizeHtml(content, this.config.whiteList, this.config.sanitizeFn);
  4493. }
  4494. $element.html(content);
  4495. } else {
  4496. $element.text(content);
  4497. }
  4498. };
  4499. _proto.getTitle = function getTitle() {
  4500. var title = this.element.getAttribute('data-original-title');
  4501. if (!title) {
  4502. title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title;
  4503. }
  4504. return title;
  4505. } // Private
  4506. ;
  4507. _proto._getPopperConfig = function _getPopperConfig(attachment) {
  4508. var _this3 = this;
  4509. var defaultBsConfig = {
  4510. placement: attachment,
  4511. modifiers: {
  4512. offset: this._getOffset(),
  4513. flip: {
  4514. behavior: this.config.fallbackPlacement
  4515. },
  4516. arrow: {
  4517. element: Selector$6.ARROW
  4518. },
  4519. preventOverflow: {
  4520. boundariesElement: this.config.boundary
  4521. }
  4522. },
  4523. onCreate: function onCreate(data) {
  4524. if (data.originalPlacement !== data.placement) {
  4525. _this3._handlePopperPlacementChange(data);
  4526. }
  4527. },
  4528. onUpdate: function onUpdate(data) {
  4529. return _this3._handlePopperPlacementChange(data);
  4530. }
  4531. };
  4532. return _objectSpread2({}, defaultBsConfig, {}, this.config.popperConfig);
  4533. };
  4534. _proto._getOffset = function _getOffset() {
  4535. var _this4 = this;
  4536. var offset = {};
  4537. if (typeof this.config.offset === 'function') {
  4538. offset.fn = function (data) {
  4539. data.offsets = _objectSpread2({}, data.offsets, {}, _this4.config.offset(data.offsets, _this4.element) || {});
  4540. return data;
  4541. };
  4542. } else {
  4543. offset.offset = this.config.offset;
  4544. }
  4545. return offset;
  4546. };
  4547. _proto._getContainer = function _getContainer() {
  4548. if (this.config.container === false) {
  4549. return document.body;
  4550. }
  4551. if (Util.isElement(this.config.container)) {
  4552. return $(this.config.container);
  4553. }
  4554. return $(document).find(this.config.container);
  4555. };
  4556. _proto._getAttachment = function _getAttachment(placement) {
  4557. return AttachmentMap$1[placement.toUpperCase()];
  4558. };
  4559. _proto._setListeners = function _setListeners() {
  4560. var _this5 = this;
  4561. var triggers = this.config.trigger.split(' ');
  4562. triggers.forEach(function (trigger) {
  4563. if (trigger === 'click') {
  4564. $(_this5.element).on(_this5.constructor.Event.CLICK, _this5.config.selector, function (event) {
  4565. return _this5.toggle(event);
  4566. });
  4567. } else if (trigger !== Trigger.MANUAL) {
  4568. var eventIn = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSEENTER : _this5.constructor.Event.FOCUSIN;
  4569. var eventOut = trigger === Trigger.HOVER ? _this5.constructor.Event.MOUSELEAVE : _this5.constructor.Event.FOCUSOUT;
  4570. $(_this5.element).on(eventIn, _this5.config.selector, function (event) {
  4571. return _this5._enter(event);
  4572. }).on(eventOut, _this5.config.selector, function (event) {
  4573. return _this5._leave(event);
  4574. });
  4575. }
  4576. });
  4577. this._hideModalHandler = function () {
  4578. if (_this5.element) {
  4579. _this5.hide();
  4580. }
  4581. };
  4582. $(this.element).closest('.modal').on('hide.bs.modal', this._hideModalHandler);
  4583. if (this.config.selector) {
  4584. this.config = _objectSpread2({}, this.config, {
  4585. trigger: 'manual',
  4586. selector: ''
  4587. });
  4588. } else {
  4589. this._fixTitle();
  4590. }
  4591. };
  4592. _proto._fixTitle = function _fixTitle() {
  4593. var titleType = typeof this.element.getAttribute('data-original-title');
  4594. if (this.element.getAttribute('title') || titleType !== 'string') {
  4595. this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '');
  4596. this.element.setAttribute('title', '');
  4597. }
  4598. };
  4599. _proto._enter = function _enter(event, context) {
  4600. var dataKey = this.constructor.DATA_KEY;
  4601. context = context || $(event.currentTarget).data(dataKey);
  4602. if (!context) {
  4603. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4604. $(event.currentTarget).data(dataKey, context);
  4605. }
  4606. if (event) {
  4607. context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true;
  4608. }
  4609. if ($(context.getTipElement()).hasClass(ClassName$6.SHOW) || context._hoverState === HoverState.SHOW) {
  4610. context._hoverState = HoverState.SHOW;
  4611. return;
  4612. }
  4613. clearTimeout(context._timeout);
  4614. context._hoverState = HoverState.SHOW;
  4615. if (!context.config.delay || !context.config.delay.show) {
  4616. context.show();
  4617. return;
  4618. }
  4619. context._timeout = setTimeout(function () {
  4620. if (context._hoverState === HoverState.SHOW) {
  4621. context.show();
  4622. }
  4623. }, context.config.delay.show);
  4624. };
  4625. _proto._leave = function _leave(event, context) {
  4626. var dataKey = this.constructor.DATA_KEY;
  4627. context = context || $(event.currentTarget).data(dataKey);
  4628. if (!context) {
  4629. context = new this.constructor(event.currentTarget, this._getDelegateConfig());
  4630. $(event.currentTarget).data(dataKey, context);
  4631. }
  4632. if (event) {
  4633. context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false;
  4634. }
  4635. if (context._isWithActiveTrigger()) {
  4636. return;
  4637. }
  4638. clearTimeout(context._timeout);
  4639. context._hoverState = HoverState.OUT;
  4640. if (!context.config.delay || !context.config.delay.hide) {
  4641. context.hide();
  4642. return;
  4643. }
  4644. context._timeout = setTimeout(function () {
  4645. if (context._hoverState === HoverState.OUT) {
  4646. context.hide();
  4647. }
  4648. }, context.config.delay.hide);
  4649. };
  4650. _proto._isWithActiveTrigger = function _isWithActiveTrigger() {
  4651. for (var trigger in this._activeTrigger) {
  4652. if (this._activeTrigger[trigger]) {
  4653. return true;
  4654. }
  4655. }
  4656. return false;
  4657. };
  4658. _proto._getConfig = function _getConfig(config) {
  4659. var dataAttributes = $(this.element).data();
  4660. Object.keys(dataAttributes).forEach(function (dataAttr) {
  4661. if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
  4662. delete dataAttributes[dataAttr];
  4663. }
  4664. });
  4665. config = _objectSpread2({}, this.constructor.Default, {}, dataAttributes, {}, typeof config === 'object' && config ? config : {});
  4666. if (typeof config.delay === 'number') {
  4667. config.delay = {
  4668. show: config.delay,
  4669. hide: config.delay
  4670. };
  4671. }
  4672. if (typeof config.title === 'number') {
  4673. config.title = config.title.toString();
  4674. }
  4675. if (typeof config.content === 'number') {
  4676. config.content = config.content.toString();
  4677. }
  4678. Util.typeCheckConfig(NAME$6, config, this.constructor.DefaultType);
  4679. if (config.sanitize) {
  4680. config.template = sanitizeHtml(config.template, config.whiteList, config.sanitizeFn);
  4681. }
  4682. return config;
  4683. };
  4684. _proto._getDelegateConfig = function _getDelegateConfig() {
  4685. var config = {};
  4686. if (this.config) {
  4687. for (var key in this.config) {
  4688. if (this.constructor.Default[key] !== this.config[key]) {
  4689. config[key] = this.config[key];
  4690. }
  4691. }
  4692. }
  4693. return config;
  4694. };
  4695. _proto._cleanTipClass = function _cleanTipClass() {
  4696. var $tip = $(this.getTipElement());
  4697. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX);
  4698. if (tabClass !== null && tabClass.length) {
  4699. $tip.removeClass(tabClass.join(''));
  4700. }
  4701. };
  4702. _proto._handlePopperPlacementChange = function _handlePopperPlacementChange(popperData) {
  4703. var popperInstance = popperData.instance;
  4704. this.tip = popperInstance.popper;
  4705. this._cleanTipClass();
  4706. this.addAttachmentClass(this._getAttachment(popperData.placement));
  4707. };
  4708. _proto._fixTransition = function _fixTransition() {
  4709. var tip = this.getTipElement();
  4710. var initConfigAnimation = this.config.animation;
  4711. if (tip.getAttribute('x-placement') !== null) {
  4712. return;
  4713. }
  4714. $(tip).removeClass(ClassName$6.FADE);
  4715. this.config.animation = false;
  4716. this.hide();
  4717. this.show();
  4718. this.config.animation = initConfigAnimation;
  4719. } // Static
  4720. ;
  4721. Tooltip._jQueryInterface = function _jQueryInterface(config) {
  4722. return this.each(function () {
  4723. var data = $(this).data(DATA_KEY$6);
  4724. var _config = typeof config === 'object' && config;
  4725. if (!data && /dispose|hide/.test(config)) {
  4726. return;
  4727. }
  4728. if (!data) {
  4729. data = new Tooltip(this, _config);
  4730. $(this).data(DATA_KEY$6, data);
  4731. }
  4732. if (typeof config === 'string') {
  4733. if (typeof data[config] === 'undefined') {
  4734. throw new TypeError("No method named \"" + config + "\"");
  4735. }
  4736. data[config]();
  4737. }
  4738. });
  4739. };
  4740. _createClass(Tooltip, null, [{
  4741. key: "VERSION",
  4742. get: function get() {
  4743. return VERSION$6;
  4744. }
  4745. }, {
  4746. key: "Default",
  4747. get: function get() {
  4748. return Default$4;
  4749. }
  4750. }, {
  4751. key: "NAME",
  4752. get: function get() {
  4753. return NAME$6;
  4754. }
  4755. }, {
  4756. key: "DATA_KEY",
  4757. get: function get() {
  4758. return DATA_KEY$6;
  4759. }
  4760. }, {
  4761. key: "Event",
  4762. get: function get() {
  4763. return Event$6;
  4764. }
  4765. }, {
  4766. key: "EVENT_KEY",
  4767. get: function get() {
  4768. return EVENT_KEY$6;
  4769. }
  4770. }, {
  4771. key: "DefaultType",
  4772. get: function get() {
  4773. return DefaultType$4;
  4774. }
  4775. }]);
  4776. return Tooltip;
  4777. }();
  4778. /**
  4779. * ------------------------------------------------------------------------
  4780. * jQuery
  4781. * ------------------------------------------------------------------------
  4782. */
  4783. $.fn[NAME$6] = Tooltip._jQueryInterface;
  4784. $.fn[NAME$6].Constructor = Tooltip;
  4785. $.fn[NAME$6].noConflict = function () {
  4786. $.fn[NAME$6] = JQUERY_NO_CONFLICT$6;
  4787. return Tooltip._jQueryInterface;
  4788. };
  4789. /**
  4790. * ------------------------------------------------------------------------
  4791. * Constants
  4792. * ------------------------------------------------------------------------
  4793. */
  4794. var NAME$7 = 'popover';
  4795. var VERSION$7 = '4.4.1';
  4796. var DATA_KEY$7 = 'bs.popover';
  4797. var EVENT_KEY$7 = "." + DATA_KEY$7;
  4798. var JQUERY_NO_CONFLICT$7 = $.fn[NAME$7];
  4799. var CLASS_PREFIX$1 = 'bs-popover';
  4800. var BSCLS_PREFIX_REGEX$1 = new RegExp("(^|\\s)" + CLASS_PREFIX$1 + "\\S+", 'g');
  4801. var Default$5 = _objectSpread2({}, Tooltip.Default, {
  4802. placement: 'right',
  4803. trigger: 'click',
  4804. content: '',
  4805. template: '<div class="popover" role="tooltip">' + '<div class="arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div></div>'
  4806. });
  4807. var DefaultType$5 = _objectSpread2({}, Tooltip.DefaultType, {
  4808. content: '(string|element|function)'
  4809. });
  4810. var ClassName$7 = {
  4811. FADE: 'fade',
  4812. SHOW: 'show'
  4813. };
  4814. var Selector$7 = {
  4815. TITLE: '.popover-header',
  4816. CONTENT: '.popover-body'
  4817. };
  4818. var Event$7 = {
  4819. HIDE: "hide" + EVENT_KEY$7,
  4820. HIDDEN: "hidden" + EVENT_KEY$7,
  4821. SHOW: "show" + EVENT_KEY$7,
  4822. SHOWN: "shown" + EVENT_KEY$7,
  4823. INSERTED: "inserted" + EVENT_KEY$7,
  4824. CLICK: "click" + EVENT_KEY$7,
  4825. FOCUSIN: "focusin" + EVENT_KEY$7,
  4826. FOCUSOUT: "focusout" + EVENT_KEY$7,
  4827. MOUSEENTER: "mouseenter" + EVENT_KEY$7,
  4828. MOUSELEAVE: "mouseleave" + EVENT_KEY$7
  4829. };
  4830. /**
  4831. * ------------------------------------------------------------------------
  4832. * Class Definition
  4833. * ------------------------------------------------------------------------
  4834. */
  4835. var Popover =
  4836. /*#__PURE__*/
  4837. function (_Tooltip) {
  4838. _inheritsLoose(Popover, _Tooltip);
  4839. function Popover() {
  4840. return _Tooltip.apply(this, arguments) || this;
  4841. }
  4842. var _proto = Popover.prototype;
  4843. // Overrides
  4844. _proto.isWithContent = function isWithContent() {
  4845. return this.getTitle() || this._getContent();
  4846. };
  4847. _proto.addAttachmentClass = function addAttachmentClass(attachment) {
  4848. $(this.getTipElement()).addClass(CLASS_PREFIX$1 + "-" + attachment);
  4849. };
  4850. _proto.getTipElement = function getTipElement() {
  4851. this.tip = this.tip || $(this.config.template)[0];
  4852. return this.tip;
  4853. };
  4854. _proto.setContent = function setContent() {
  4855. var $tip = $(this.getTipElement()); // We use append for html objects to maintain js events
  4856. this.setElementContent($tip.find(Selector$7.TITLE), this.getTitle());
  4857. var content = this._getContent();
  4858. if (typeof content === 'function') {
  4859. content = content.call(this.element);
  4860. }
  4861. this.setElementContent($tip.find(Selector$7.CONTENT), content);
  4862. $tip.removeClass(ClassName$7.FADE + " " + ClassName$7.SHOW);
  4863. } // Private
  4864. ;
  4865. _proto._getContent = function _getContent() {
  4866. return this.element.getAttribute('data-content') || this.config.content;
  4867. };
  4868. _proto._cleanTipClass = function _cleanTipClass() {
  4869. var $tip = $(this.getTipElement());
  4870. var tabClass = $tip.attr('class').match(BSCLS_PREFIX_REGEX$1);
  4871. if (tabClass !== null && tabClass.length > 0) {
  4872. $tip.removeClass(tabClass.join(''));
  4873. }
  4874. } // Static
  4875. ;
  4876. Popover._jQueryInterface = function _jQueryInterface(config) {
  4877. return this.each(function () {
  4878. var data = $(this).data(DATA_KEY$7);
  4879. var _config = typeof config === 'object' ? config : null;
  4880. if (!data && /dispose|hide/.test(config)) {
  4881. return;
  4882. }
  4883. if (!data) {
  4884. data = new Popover(this, _config);
  4885. $(this).data(DATA_KEY$7, data);
  4886. }
  4887. if (typeof config === 'string') {
  4888. if (typeof data[config] === 'undefined') {
  4889. throw new TypeError("No method named \"" + config + "\"");
  4890. }
  4891. data[config]();
  4892. }
  4893. });
  4894. };
  4895. _createClass(Popover, null, [{
  4896. key: "VERSION",
  4897. // Getters
  4898. get: function get() {
  4899. return VERSION$7;
  4900. }
  4901. }, {
  4902. key: "Default",
  4903. get: function get() {
  4904. return Default$5;
  4905. }
  4906. }, {
  4907. key: "NAME",
  4908. get: function get() {
  4909. return NAME$7;
  4910. }
  4911. }, {
  4912. key: "DATA_KEY",
  4913. get: function get() {
  4914. return DATA_KEY$7;
  4915. }
  4916. }, {
  4917. key: "Event",
  4918. get: function get() {
  4919. return Event$7;
  4920. }
  4921. }, {
  4922. key: "EVENT_KEY",
  4923. get: function get() {
  4924. return EVENT_KEY$7;
  4925. }
  4926. }, {
  4927. key: "DefaultType",
  4928. get: function get() {
  4929. return DefaultType$5;
  4930. }
  4931. }]);
  4932. return Popover;
  4933. }(Tooltip);
  4934. /**
  4935. * ------------------------------------------------------------------------
  4936. * jQuery
  4937. * ------------------------------------------------------------------------
  4938. */
  4939. $.fn[NAME$7] = Popover._jQueryInterface;
  4940. $.fn[NAME$7].Constructor = Popover;
  4941. $.fn[NAME$7].noConflict = function () {
  4942. $.fn[NAME$7] = JQUERY_NO_CONFLICT$7;
  4943. return Popover._jQueryInterface;
  4944. };
  4945. /**
  4946. * ------------------------------------------------------------------------
  4947. * Constants
  4948. * ------------------------------------------------------------------------
  4949. */
  4950. var NAME$8 = 'scrollspy';
  4951. var VERSION$8 = '4.4.1';
  4952. var DATA_KEY$8 = 'bs.scrollspy';
  4953. var EVENT_KEY$8 = "." + DATA_KEY$8;
  4954. var DATA_API_KEY$6 = '.data-api';
  4955. var JQUERY_NO_CONFLICT$8 = $.fn[NAME$8];
  4956. var Default$6 = {
  4957. offset: 10,
  4958. method: 'auto',
  4959. target: ''
  4960. };
  4961. var DefaultType$6 = {
  4962. offset: 'number',
  4963. method: 'string',
  4964. target: '(string|element)'
  4965. };
  4966. var Event$8 = {
  4967. ACTIVATE: "activate" + EVENT_KEY$8,
  4968. SCROLL: "scroll" + EVENT_KEY$8,
  4969. LOAD_DATA_API: "load" + EVENT_KEY$8 + DATA_API_KEY$6
  4970. };
  4971. var ClassName$8 = {
  4972. DROPDOWN_ITEM: 'dropdown-item',
  4973. DROPDOWN_MENU: 'dropdown-menu',
  4974. ACTIVE: 'active'
  4975. };
  4976. var Selector$8 = {
  4977. DATA_SPY: '[data-spy="scroll"]',
  4978. ACTIVE: '.active',
  4979. NAV_LIST_GROUP: '.nav, .list-group',
  4980. NAV_LINKS: '.nav-link',
  4981. NAV_ITEMS: '.nav-item',
  4982. LIST_ITEMS: '.list-group-item',
  4983. DROPDOWN: '.dropdown',
  4984. DROPDOWN_ITEMS: '.dropdown-item',
  4985. DROPDOWN_TOGGLE: '.dropdown-toggle'
  4986. };
  4987. var OffsetMethod = {
  4988. OFFSET: 'offset',
  4989. POSITION: 'position'
  4990. };
  4991. /**
  4992. * ------------------------------------------------------------------------
  4993. * Class Definition
  4994. * ------------------------------------------------------------------------
  4995. */
  4996. var ScrollSpy =
  4997. /*#__PURE__*/
  4998. function () {
  4999. function ScrollSpy(element, config) {
  5000. var _this = this;
  5001. this._element = element;
  5002. this._scrollElement = element.tagName === 'BODY' ? window : element;
  5003. this._config = this._getConfig(config);
  5004. this._selector = this._config.target + " " + Selector$8.NAV_LINKS + "," + (this._config.target + " " + Selector$8.LIST_ITEMS + ",") + (this._config.target + " " + Selector$8.DROPDOWN_ITEMS);
  5005. this._offsets = [];
  5006. this._targets = [];
  5007. this._activeTarget = null;
  5008. this._scrollHeight = 0;
  5009. $(this._scrollElement).on(Event$8.SCROLL, function (event) {
  5010. return _this._process(event);
  5011. });
  5012. this.refresh();
  5013. this._process();
  5014. } // Getters
  5015. var _proto = ScrollSpy.prototype;
  5016. // Public
  5017. _proto.refresh = function refresh() {
  5018. var _this2 = this;
  5019. var autoMethod = this._scrollElement === this._scrollElement.window ? OffsetMethod.OFFSET : OffsetMethod.POSITION;
  5020. var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method;
  5021. var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0;
  5022. this._offsets = [];
  5023. this._targets = [];
  5024. this._scrollHeight = this._getScrollHeight();
  5025. var targets = [].slice.call(document.querySelectorAll(this._selector));
  5026. targets.map(function (element) {
  5027. var target;
  5028. var targetSelector = Util.getSelectorFromElement(element);
  5029. if (targetSelector) {
  5030. target = document.querySelector(targetSelector);
  5031. }
  5032. if (target) {
  5033. var targetBCR = target.getBoundingClientRect();
  5034. if (targetBCR.width || targetBCR.height) {
  5035. // TODO (fat): remove sketch reliance on jQuery position/offset
  5036. return [$(target)[offsetMethod]().top + offsetBase, targetSelector];
  5037. }
  5038. }
  5039. return null;
  5040. }).filter(function (item) {
  5041. return item;
  5042. }).sort(function (a, b) {
  5043. return a[0] - b[0];
  5044. }).forEach(function (item) {
  5045. _this2._offsets.push(item[0]);
  5046. _this2._targets.push(item[1]);
  5047. });
  5048. };
  5049. _proto.dispose = function dispose() {
  5050. $.removeData(this._element, DATA_KEY$8);
  5051. $(this._scrollElement).off(EVENT_KEY$8);
  5052. this._element = null;
  5053. this._scrollElement = null;
  5054. this._config = null;
  5055. this._selector = null;
  5056. this._offsets = null;
  5057. this._targets = null;
  5058. this._activeTarget = null;
  5059. this._scrollHeight = null;
  5060. } // Private
  5061. ;
  5062. _proto._getConfig = function _getConfig(config) {
  5063. config = _objectSpread2({}, Default$6, {}, typeof config === 'object' && config ? config : {});
  5064. if (typeof config.target !== 'string') {
  5065. var id = $(config.target).attr('id');
  5066. if (!id) {
  5067. id = Util.getUID(NAME$8);
  5068. $(config.target).attr('id', id);
  5069. }
  5070. config.target = "#" + id;
  5071. }
  5072. Util.typeCheckConfig(NAME$8, config, DefaultType$6);
  5073. return config;
  5074. };
  5075. _proto._getScrollTop = function _getScrollTop() {
  5076. return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop;
  5077. };
  5078. _proto._getScrollHeight = function _getScrollHeight() {
  5079. return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
  5080. };
  5081. _proto._getOffsetHeight = function _getOffsetHeight() {
  5082. return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height;
  5083. };
  5084. _proto._process = function _process() {
  5085. var scrollTop = this._getScrollTop() + this._config.offset;
  5086. var scrollHeight = this._getScrollHeight();
  5087. var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight();
  5088. if (this._scrollHeight !== scrollHeight) {
  5089. this.refresh();
  5090. }
  5091. if (scrollTop >= maxScroll) {
  5092. var target = this._targets[this._targets.length - 1];
  5093. if (this._activeTarget !== target) {
  5094. this._activate(target);
  5095. }
  5096. return;
  5097. }
  5098. if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) {
  5099. this._activeTarget = null;
  5100. this._clear();
  5101. return;
  5102. }
  5103. var offsetLength = this._offsets.length;
  5104. for (var i = offsetLength; i--;) {
  5105. var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]);
  5106. if (isActiveTarget) {
  5107. this._activate(this._targets[i]);
  5108. }
  5109. }
  5110. };
  5111. _proto._activate = function _activate(target) {
  5112. this._activeTarget = target;
  5113. this._clear();
  5114. var queries = this._selector.split(',').map(function (selector) {
  5115. return selector + "[data-target=\"" + target + "\"]," + selector + "[href=\"" + target + "\"]";
  5116. });
  5117. var $link = $([].slice.call(document.querySelectorAll(queries.join(','))));
  5118. if ($link.hasClass(ClassName$8.DROPDOWN_ITEM)) {
  5119. $link.closest(Selector$8.DROPDOWN).find(Selector$8.DROPDOWN_TOGGLE).addClass(ClassName$8.ACTIVE);
  5120. $link.addClass(ClassName$8.ACTIVE);
  5121. } else {
  5122. // Set triggered link as active
  5123. $link.addClass(ClassName$8.ACTIVE); // Set triggered links parents as active
  5124. // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
  5125. $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
  5126. $link.parents(Selector$8.NAV_LIST_GROUP).prev(Selector$8.NAV_ITEMS).children(Selector$8.NAV_LINKS).addClass(ClassName$8.ACTIVE);
  5127. }
  5128. $(this._scrollElement).trigger(Event$8.ACTIVATE, {
  5129. relatedTarget: target
  5130. });
  5131. };
  5132. _proto._clear = function _clear() {
  5133. [].slice.call(document.querySelectorAll(this._selector)).filter(function (node) {
  5134. return node.classList.contains(ClassName$8.ACTIVE);
  5135. }).forEach(function (node) {
  5136. return node.classList.remove(ClassName$8.ACTIVE);
  5137. });
  5138. } // Static
  5139. ;
  5140. ScrollSpy._jQueryInterface = function _jQueryInterface(config) {
  5141. return this.each(function () {
  5142. var data = $(this).data(DATA_KEY$8);
  5143. var _config = typeof config === 'object' && config;
  5144. if (!data) {
  5145. data = new ScrollSpy(this, _config);
  5146. $(this).data(DATA_KEY$8, data);
  5147. }
  5148. if (typeof config === 'string') {
  5149. if (typeof data[config] === 'undefined') {
  5150. throw new TypeError("No method named \"" + config + "\"");
  5151. }
  5152. data[config]();
  5153. }
  5154. });
  5155. };
  5156. _createClass(ScrollSpy, null, [{
  5157. key: "VERSION",
  5158. get: function get() {
  5159. return VERSION$8;
  5160. }
  5161. }, {
  5162. key: "Default",
  5163. get: function get() {
  5164. return Default$6;
  5165. }
  5166. }]);
  5167. return ScrollSpy;
  5168. }();
  5169. /**
  5170. * ------------------------------------------------------------------------
  5171. * Data Api implementation
  5172. * ------------------------------------------------------------------------
  5173. */
  5174. $(window).on(Event$8.LOAD_DATA_API, function () {
  5175. var scrollSpys = [].slice.call(document.querySelectorAll(Selector$8.DATA_SPY));
  5176. var scrollSpysLength = scrollSpys.length;
  5177. for (var i = scrollSpysLength; i--;) {
  5178. var $spy = $(scrollSpys[i]);
  5179. ScrollSpy._jQueryInterface.call($spy, $spy.data());
  5180. }
  5181. });
  5182. /**
  5183. * ------------------------------------------------------------------------
  5184. * jQuery
  5185. * ------------------------------------------------------------------------
  5186. */
  5187. $.fn[NAME$8] = ScrollSpy._jQueryInterface;
  5188. $.fn[NAME$8].Constructor = ScrollSpy;
  5189. $.fn[NAME$8].noConflict = function () {
  5190. $.fn[NAME$8] = JQUERY_NO_CONFLICT$8;
  5191. return ScrollSpy._jQueryInterface;
  5192. };
  5193. /**
  5194. * ------------------------------------------------------------------------
  5195. * Constants
  5196. * ------------------------------------------------------------------------
  5197. */
  5198. var NAME$9 = 'tab';
  5199. var VERSION$9 = '4.4.1';
  5200. var DATA_KEY$9 = 'bs.tab';
  5201. var EVENT_KEY$9 = "." + DATA_KEY$9;
  5202. var DATA_API_KEY$7 = '.data-api';
  5203. var JQUERY_NO_CONFLICT$9 = $.fn[NAME$9];
  5204. var Event$9 = {
  5205. HIDE: "hide" + EVENT_KEY$9,
  5206. HIDDEN: "hidden" + EVENT_KEY$9,
  5207. SHOW: "show" + EVENT_KEY$9,
  5208. SHOWN: "shown" + EVENT_KEY$9,
  5209. CLICK_DATA_API: "click" + EVENT_KEY$9 + DATA_API_KEY$7
  5210. };
  5211. var ClassName$9 = {
  5212. DROPDOWN_MENU: 'dropdown-menu',
  5213. ACTIVE: 'active',
  5214. DISABLED: 'disabled',
  5215. FADE: 'fade',
  5216. SHOW: 'show'
  5217. };
  5218. var Selector$9 = {
  5219. DROPDOWN: '.dropdown',
  5220. NAV_LIST_GROUP: '.nav, .list-group',
  5221. ACTIVE: '.active',
  5222. ACTIVE_UL: '> li > .active',
  5223. DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
  5224. DROPDOWN_TOGGLE: '.dropdown-toggle',
  5225. DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active'
  5226. };
  5227. /**
  5228. * ------------------------------------------------------------------------
  5229. * Class Definition
  5230. * ------------------------------------------------------------------------
  5231. */
  5232. var Tab =
  5233. /*#__PURE__*/
  5234. function () {
  5235. function Tab(element) {
  5236. this._element = element;
  5237. } // Getters
  5238. var _proto = Tab.prototype;
  5239. // Public
  5240. _proto.show = function show() {
  5241. var _this = this;
  5242. if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName$9.ACTIVE) || $(this._element).hasClass(ClassName$9.DISABLED)) {
  5243. return;
  5244. }
  5245. var target;
  5246. var previous;
  5247. var listElement = $(this._element).closest(Selector$9.NAV_LIST_GROUP)[0];
  5248. var selector = Util.getSelectorFromElement(this._element);
  5249. if (listElement) {
  5250. var itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector$9.ACTIVE_UL : Selector$9.ACTIVE;
  5251. previous = $.makeArray($(listElement).find(itemSelector));
  5252. previous = previous[previous.length - 1];
  5253. }
  5254. var hideEvent = $.Event(Event$9.HIDE, {
  5255. relatedTarget: this._element
  5256. });
  5257. var showEvent = $.Event(Event$9.SHOW, {
  5258. relatedTarget: previous
  5259. });
  5260. if (previous) {
  5261. $(previous).trigger(hideEvent);
  5262. }
  5263. $(this._element).trigger(showEvent);
  5264. if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) {
  5265. return;
  5266. }
  5267. if (selector) {
  5268. target = document.querySelector(selector);
  5269. }
  5270. this._activate(this._element, listElement);
  5271. var complete = function complete() {
  5272. var hiddenEvent = $.Event(Event$9.HIDDEN, {
  5273. relatedTarget: _this._element
  5274. });
  5275. var shownEvent = $.Event(Event$9.SHOWN, {
  5276. relatedTarget: previous
  5277. });
  5278. $(previous).trigger(hiddenEvent);
  5279. $(_this._element).trigger(shownEvent);
  5280. };
  5281. if (target) {
  5282. this._activate(target, target.parentNode, complete);
  5283. } else {
  5284. complete();
  5285. }
  5286. };
  5287. _proto.dispose = function dispose() {
  5288. $.removeData(this._element, DATA_KEY$9);
  5289. this._element = null;
  5290. } // Private
  5291. ;
  5292. _proto._activate = function _activate(element, container, callback) {
  5293. var _this2 = this;
  5294. var activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? $(container).find(Selector$9.ACTIVE_UL) : $(container).children(Selector$9.ACTIVE);
  5295. var active = activeElements[0];
  5296. var isTransitioning = callback && active && $(active).hasClass(ClassName$9.FADE);
  5297. var complete = function complete() {
  5298. return _this2._transitionComplete(element, active, callback);
  5299. };
  5300. if (active && isTransitioning) {
  5301. var transitionDuration = Util.getTransitionDurationFromElement(active);
  5302. $(active).removeClass(ClassName$9.SHOW).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5303. } else {
  5304. complete();
  5305. }
  5306. };
  5307. _proto._transitionComplete = function _transitionComplete(element, active, callback) {
  5308. if (active) {
  5309. $(active).removeClass(ClassName$9.ACTIVE);
  5310. var dropdownChild = $(active.parentNode).find(Selector$9.DROPDOWN_ACTIVE_CHILD)[0];
  5311. if (dropdownChild) {
  5312. $(dropdownChild).removeClass(ClassName$9.ACTIVE);
  5313. }
  5314. if (active.getAttribute('role') === 'tab') {
  5315. active.setAttribute('aria-selected', false);
  5316. }
  5317. }
  5318. $(element).addClass(ClassName$9.ACTIVE);
  5319. if (element.getAttribute('role') === 'tab') {
  5320. element.setAttribute('aria-selected', true);
  5321. }
  5322. Util.reflow(element);
  5323. if (element.classList.contains(ClassName$9.FADE)) {
  5324. element.classList.add(ClassName$9.SHOW);
  5325. }
  5326. if (element.parentNode && $(element.parentNode).hasClass(ClassName$9.DROPDOWN_MENU)) {
  5327. var dropdownElement = $(element).closest(Selector$9.DROPDOWN)[0];
  5328. if (dropdownElement) {
  5329. var dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector$9.DROPDOWN_TOGGLE));
  5330. $(dropdownToggleList).addClass(ClassName$9.ACTIVE);
  5331. }
  5332. element.setAttribute('aria-expanded', true);
  5333. }
  5334. if (callback) {
  5335. callback();
  5336. }
  5337. } // Static
  5338. ;
  5339. Tab._jQueryInterface = function _jQueryInterface(config) {
  5340. return this.each(function () {
  5341. var $this = $(this);
  5342. var data = $this.data(DATA_KEY$9);
  5343. if (!data) {
  5344. data = new Tab(this);
  5345. $this.data(DATA_KEY$9, data);
  5346. }
  5347. if (typeof config === 'string') {
  5348. if (typeof data[config] === 'undefined') {
  5349. throw new TypeError("No method named \"" + config + "\"");
  5350. }
  5351. data[config]();
  5352. }
  5353. });
  5354. };
  5355. _createClass(Tab, null, [{
  5356. key: "VERSION",
  5357. get: function get() {
  5358. return VERSION$9;
  5359. }
  5360. }]);
  5361. return Tab;
  5362. }();
  5363. /**
  5364. * ------------------------------------------------------------------------
  5365. * Data Api implementation
  5366. * ------------------------------------------------------------------------
  5367. */
  5368. $(document).on(Event$9.CLICK_DATA_API, Selector$9.DATA_TOGGLE, function (event) {
  5369. event.preventDefault();
  5370. Tab._jQueryInterface.call($(this), 'show');
  5371. });
  5372. /**
  5373. * ------------------------------------------------------------------------
  5374. * jQuery
  5375. * ------------------------------------------------------------------------
  5376. */
  5377. $.fn[NAME$9] = Tab._jQueryInterface;
  5378. $.fn[NAME$9].Constructor = Tab;
  5379. $.fn[NAME$9].noConflict = function () {
  5380. $.fn[NAME$9] = JQUERY_NO_CONFLICT$9;
  5381. return Tab._jQueryInterface;
  5382. };
  5383. /**
  5384. * ------------------------------------------------------------------------
  5385. * Constants
  5386. * ------------------------------------------------------------------------
  5387. */
  5388. var NAME$a = 'toast';
  5389. var VERSION$a = '4.4.1';
  5390. var DATA_KEY$a = 'bs.toast';
  5391. var EVENT_KEY$a = "." + DATA_KEY$a;
  5392. var JQUERY_NO_CONFLICT$a = $.fn[NAME$a];
  5393. var Event$a = {
  5394. CLICK_DISMISS: "click.dismiss" + EVENT_KEY$a,
  5395. HIDE: "hide" + EVENT_KEY$a,
  5396. HIDDEN: "hidden" + EVENT_KEY$a,
  5397. SHOW: "show" + EVENT_KEY$a,
  5398. SHOWN: "shown" + EVENT_KEY$a
  5399. };
  5400. var ClassName$a = {
  5401. FADE: 'fade',
  5402. HIDE: 'hide',
  5403. SHOW: 'show',
  5404. SHOWING: 'showing'
  5405. };
  5406. var DefaultType$7 = {
  5407. animation: 'boolean',
  5408. autohide: 'boolean',
  5409. delay: 'number'
  5410. };
  5411. var Default$7 = {
  5412. animation: true,
  5413. autohide: true,
  5414. delay: 500
  5415. };
  5416. var Selector$a = {
  5417. DATA_DISMISS: '[data-dismiss="toast"]'
  5418. };
  5419. /**
  5420. * ------------------------------------------------------------------------
  5421. * Class Definition
  5422. * ------------------------------------------------------------------------
  5423. */
  5424. var Toast =
  5425. /*#__PURE__*/
  5426. function () {
  5427. function Toast(element, config) {
  5428. this._element = element;
  5429. this._config = this._getConfig(config);
  5430. this._timeout = null;
  5431. this._setListeners();
  5432. } // Getters
  5433. var _proto = Toast.prototype;
  5434. // Public
  5435. _proto.show = function show() {
  5436. var _this = this;
  5437. var showEvent = $.Event(Event$a.SHOW);
  5438. $(this._element).trigger(showEvent);
  5439. if (showEvent.isDefaultPrevented()) {
  5440. return;
  5441. }
  5442. if (this._config.animation) {
  5443. this._element.classList.add(ClassName$a.FADE);
  5444. }
  5445. var complete = function complete() {
  5446. _this._element.classList.remove(ClassName$a.SHOWING);
  5447. _this._element.classList.add(ClassName$a.SHOW);
  5448. $(_this._element).trigger(Event$a.SHOWN);
  5449. if (_this._config.autohide) {
  5450. _this._timeout = setTimeout(function () {
  5451. _this.hide();
  5452. }, _this._config.delay);
  5453. }
  5454. };
  5455. this._element.classList.remove(ClassName$a.HIDE);
  5456. Util.reflow(this._element);
  5457. this._element.classList.add(ClassName$a.SHOWING);
  5458. if (this._config.animation) {
  5459. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5460. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5461. } else {
  5462. complete();
  5463. }
  5464. };
  5465. _proto.hide = function hide() {
  5466. if (!this._element.classList.contains(ClassName$a.SHOW)) {
  5467. return;
  5468. }
  5469. var hideEvent = $.Event(Event$a.HIDE);
  5470. $(this._element).trigger(hideEvent);
  5471. if (hideEvent.isDefaultPrevented()) {
  5472. return;
  5473. }
  5474. this._close();
  5475. };
  5476. _proto.dispose = function dispose() {
  5477. clearTimeout(this._timeout);
  5478. this._timeout = null;
  5479. if (this._element.classList.contains(ClassName$a.SHOW)) {
  5480. this._element.classList.remove(ClassName$a.SHOW);
  5481. }
  5482. $(this._element).off(Event$a.CLICK_DISMISS);
  5483. $.removeData(this._element, DATA_KEY$a);
  5484. this._element = null;
  5485. this._config = null;
  5486. } // Private
  5487. ;
  5488. _proto._getConfig = function _getConfig(config) {
  5489. config = _objectSpread2({}, Default$7, {}, $(this._element).data(), {}, typeof config === 'object' && config ? config : {});
  5490. Util.typeCheckConfig(NAME$a, config, this.constructor.DefaultType);
  5491. return config;
  5492. };
  5493. _proto._setListeners = function _setListeners() {
  5494. var _this2 = this;
  5495. $(this._element).on(Event$a.CLICK_DISMISS, Selector$a.DATA_DISMISS, function () {
  5496. return _this2.hide();
  5497. });
  5498. };
  5499. _proto._close = function _close() {
  5500. var _this3 = this;
  5501. var complete = function complete() {
  5502. _this3._element.classList.add(ClassName$a.HIDE);
  5503. $(_this3._element).trigger(Event$a.HIDDEN);
  5504. };
  5505. this._element.classList.remove(ClassName$a.SHOW);
  5506. if (this._config.animation) {
  5507. var transitionDuration = Util.getTransitionDurationFromElement(this._element);
  5508. $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
  5509. } else {
  5510. complete();
  5511. }
  5512. } // Static
  5513. ;
  5514. Toast._jQueryInterface = function _jQueryInterface(config) {
  5515. return this.each(function () {
  5516. var $element = $(this);
  5517. var data = $element.data(DATA_KEY$a);
  5518. var _config = typeof config === 'object' && config;
  5519. if (!data) {
  5520. data = new Toast(this, _config);
  5521. $element.data(DATA_KEY$a, data);
  5522. }
  5523. if (typeof config === 'string') {
  5524. if (typeof data[config] === 'undefined') {
  5525. throw new TypeError("No method named \"" + config + "\"");
  5526. }
  5527. data[config](this);
  5528. }
  5529. });
  5530. };
  5531. _createClass(Toast, null, [{
  5532. key: "VERSION",
  5533. get: function get() {
  5534. return VERSION$a;
  5535. }
  5536. }, {
  5537. key: "DefaultType",
  5538. get: function get() {
  5539. return DefaultType$7;
  5540. }
  5541. }, {
  5542. key: "Default",
  5543. get: function get() {
  5544. return Default$7;
  5545. }
  5546. }]);
  5547. return Toast;
  5548. }();
  5549. /**
  5550. * ------------------------------------------------------------------------
  5551. * jQuery
  5552. * ------------------------------------------------------------------------
  5553. */
  5554. $.fn[NAME$a] = Toast._jQueryInterface;
  5555. $.fn[NAME$a].Constructor = Toast;
  5556. $.fn[NAME$a].noConflict = function () {
  5557. $.fn[NAME$a] = JQUERY_NO_CONFLICT$a;
  5558. return Toast._jQueryInterface;
  5559. };
  5560. exports.Alert = Alert;
  5561. exports.Button = Button;
  5562. exports.Carousel = Carousel;
  5563. exports.Collapse = Collapse;
  5564. exports.Dropdown = Dropdown;
  5565. exports.Modal = Modal;
  5566. exports.Popover = Popover;
  5567. exports.Scrollspy = ScrollSpy;
  5568. exports.Tab = Tab;
  5569. exports.Toast = Toast;
  5570. exports.Tooltip = Tooltip;
  5571. exports.Util = Util;
  5572. Object.defineProperty(exports, '__esModule', { value: true });
  5573. })));
  5574. //# sourceMappingURL=bootstrap.js.map
  5575. /***/ }),
  5576. /***/ "./node_modules/buffer/index.js":
  5577. /*!**************************************!*\
  5578. !*** ./node_modules/buffer/index.js ***!
  5579. \**************************************/
  5580. /*! no static exports found */
  5581. /***/ (function(module, exports, __webpack_require__) {
  5582. "use strict";
  5583. /* WEBPACK VAR INJECTION */(function(global) {/*!
  5584. * The buffer module from node.js, for the browser.
  5585. *
  5586. * @author Feross Aboukhadijeh <http://feross.org>
  5587. * @license MIT
  5588. */
  5589. /* eslint-disable no-proto */
  5590. var base64 = __webpack_require__(/*! base64-js */ "./node_modules/base64-js/index.js")
  5591. var ieee754 = __webpack_require__(/*! ieee754 */ "./node_modules/ieee754/index.js")
  5592. var isArray = __webpack_require__(/*! isarray */ "./node_modules/isarray/index.js")
  5593. exports.Buffer = Buffer
  5594. exports.SlowBuffer = SlowBuffer
  5595. exports.INSPECT_MAX_BYTES = 50
  5596. /**
  5597. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  5598. * === true Use Uint8Array implementation (fastest)
  5599. * === false Use Object implementation (most compatible, even IE6)
  5600. *
  5601. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  5602. * Opera 11.6+, iOS 4.2+.
  5603. *
  5604. * Due to various browser bugs, sometimes the Object implementation will be used even
  5605. * when the browser supports typed arrays.
  5606. *
  5607. * Note:
  5608. *
  5609. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  5610. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  5611. *
  5612. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  5613. *
  5614. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  5615. * incorrect length in some situations.
  5616. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  5617. * get the Object implementation, which is slower but behaves correctly.
  5618. */
  5619. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  5620. ? global.TYPED_ARRAY_SUPPORT
  5621. : typedArraySupport()
  5622. /*
  5623. * Export kMaxLength after typed array support is determined.
  5624. */
  5625. exports.kMaxLength = kMaxLength()
  5626. function typedArraySupport () {
  5627. try {
  5628. var arr = new Uint8Array(1)
  5629. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  5630. return arr.foo() === 42 && // typed array instances can be augmented
  5631. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  5632. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  5633. } catch (e) {
  5634. return false
  5635. }
  5636. }
  5637. function kMaxLength () {
  5638. return Buffer.TYPED_ARRAY_SUPPORT
  5639. ? 0x7fffffff
  5640. : 0x3fffffff
  5641. }
  5642. function createBuffer (that, length) {
  5643. if (kMaxLength() < length) {
  5644. throw new RangeError('Invalid typed array length')
  5645. }
  5646. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5647. // Return an augmented `Uint8Array` instance, for best performance
  5648. that = new Uint8Array(length)
  5649. that.__proto__ = Buffer.prototype
  5650. } else {
  5651. // Fallback: Return an object instance of the Buffer class
  5652. if (that === null) {
  5653. that = new Buffer(length)
  5654. }
  5655. that.length = length
  5656. }
  5657. return that
  5658. }
  5659. /**
  5660. * The Buffer constructor returns instances of `Uint8Array` that have their
  5661. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  5662. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  5663. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  5664. * returns a single octet.
  5665. *
  5666. * The `Uint8Array` prototype remains unmodified.
  5667. */
  5668. function Buffer (arg, encodingOrOffset, length) {
  5669. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  5670. return new Buffer(arg, encodingOrOffset, length)
  5671. }
  5672. // Common case.
  5673. if (typeof arg === 'number') {
  5674. if (typeof encodingOrOffset === 'string') {
  5675. throw new Error(
  5676. 'If encoding is specified then the first argument must be a string'
  5677. )
  5678. }
  5679. return allocUnsafe(this, arg)
  5680. }
  5681. return from(this, arg, encodingOrOffset, length)
  5682. }
  5683. Buffer.poolSize = 8192 // not used by this implementation
  5684. // TODO: Legacy, not needed anymore. Remove in next major version.
  5685. Buffer._augment = function (arr) {
  5686. arr.__proto__ = Buffer.prototype
  5687. return arr
  5688. }
  5689. function from (that, value, encodingOrOffset, length) {
  5690. if (typeof value === 'number') {
  5691. throw new TypeError('"value" argument must not be a number')
  5692. }
  5693. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  5694. return fromArrayBuffer(that, value, encodingOrOffset, length)
  5695. }
  5696. if (typeof value === 'string') {
  5697. return fromString(that, value, encodingOrOffset)
  5698. }
  5699. return fromObject(that, value)
  5700. }
  5701. /**
  5702. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  5703. * if value is a number.
  5704. * Buffer.from(str[, encoding])
  5705. * Buffer.from(array)
  5706. * Buffer.from(buffer)
  5707. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  5708. **/
  5709. Buffer.from = function (value, encodingOrOffset, length) {
  5710. return from(null, value, encodingOrOffset, length)
  5711. }
  5712. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5713. Buffer.prototype.__proto__ = Uint8Array.prototype
  5714. Buffer.__proto__ = Uint8Array
  5715. if (typeof Symbol !== 'undefined' && Symbol.species &&
  5716. Buffer[Symbol.species] === Buffer) {
  5717. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  5718. Object.defineProperty(Buffer, Symbol.species, {
  5719. value: null,
  5720. configurable: true
  5721. })
  5722. }
  5723. }
  5724. function assertSize (size) {
  5725. if (typeof size !== 'number') {
  5726. throw new TypeError('"size" argument must be a number')
  5727. } else if (size < 0) {
  5728. throw new RangeError('"size" argument must not be negative')
  5729. }
  5730. }
  5731. function alloc (that, size, fill, encoding) {
  5732. assertSize(size)
  5733. if (size <= 0) {
  5734. return createBuffer(that, size)
  5735. }
  5736. if (fill !== undefined) {
  5737. // Only pay attention to encoding if it's a string. This
  5738. // prevents accidentally sending in a number that would
  5739. // be interpretted as a start offset.
  5740. return typeof encoding === 'string'
  5741. ? createBuffer(that, size).fill(fill, encoding)
  5742. : createBuffer(that, size).fill(fill)
  5743. }
  5744. return createBuffer(that, size)
  5745. }
  5746. /**
  5747. * Creates a new filled Buffer instance.
  5748. * alloc(size[, fill[, encoding]])
  5749. **/
  5750. Buffer.alloc = function (size, fill, encoding) {
  5751. return alloc(null, size, fill, encoding)
  5752. }
  5753. function allocUnsafe (that, size) {
  5754. assertSize(size)
  5755. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  5756. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  5757. for (var i = 0; i < size; ++i) {
  5758. that[i] = 0
  5759. }
  5760. }
  5761. return that
  5762. }
  5763. /**
  5764. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  5765. * */
  5766. Buffer.allocUnsafe = function (size) {
  5767. return allocUnsafe(null, size)
  5768. }
  5769. /**
  5770. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  5771. */
  5772. Buffer.allocUnsafeSlow = function (size) {
  5773. return allocUnsafe(null, size)
  5774. }
  5775. function fromString (that, string, encoding) {
  5776. if (typeof encoding !== 'string' || encoding === '') {
  5777. encoding = 'utf8'
  5778. }
  5779. if (!Buffer.isEncoding(encoding)) {
  5780. throw new TypeError('"encoding" must be a valid string encoding')
  5781. }
  5782. var length = byteLength(string, encoding) | 0
  5783. that = createBuffer(that, length)
  5784. var actual = that.write(string, encoding)
  5785. if (actual !== length) {
  5786. // Writing a hex string, for example, that contains invalid characters will
  5787. // cause everything after the first invalid character to be ignored. (e.g.
  5788. // 'abxxcd' will be treated as 'ab')
  5789. that = that.slice(0, actual)
  5790. }
  5791. return that
  5792. }
  5793. function fromArrayLike (that, array) {
  5794. var length = array.length < 0 ? 0 : checked(array.length) | 0
  5795. that = createBuffer(that, length)
  5796. for (var i = 0; i < length; i += 1) {
  5797. that[i] = array[i] & 255
  5798. }
  5799. return that
  5800. }
  5801. function fromArrayBuffer (that, array, byteOffset, length) {
  5802. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  5803. if (byteOffset < 0 || array.byteLength < byteOffset) {
  5804. throw new RangeError('\'offset\' is out of bounds')
  5805. }
  5806. if (array.byteLength < byteOffset + (length || 0)) {
  5807. throw new RangeError('\'length\' is out of bounds')
  5808. }
  5809. if (byteOffset === undefined && length === undefined) {
  5810. array = new Uint8Array(array)
  5811. } else if (length === undefined) {
  5812. array = new Uint8Array(array, byteOffset)
  5813. } else {
  5814. array = new Uint8Array(array, byteOffset, length)
  5815. }
  5816. if (Buffer.TYPED_ARRAY_SUPPORT) {
  5817. // Return an augmented `Uint8Array` instance, for best performance
  5818. that = array
  5819. that.__proto__ = Buffer.prototype
  5820. } else {
  5821. // Fallback: Return an object instance of the Buffer class
  5822. that = fromArrayLike(that, array)
  5823. }
  5824. return that
  5825. }
  5826. function fromObject (that, obj) {
  5827. if (Buffer.isBuffer(obj)) {
  5828. var len = checked(obj.length) | 0
  5829. that = createBuffer(that, len)
  5830. if (that.length === 0) {
  5831. return that
  5832. }
  5833. obj.copy(that, 0, 0, len)
  5834. return that
  5835. }
  5836. if (obj) {
  5837. if ((typeof ArrayBuffer !== 'undefined' &&
  5838. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  5839. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  5840. return createBuffer(that, 0)
  5841. }
  5842. return fromArrayLike(that, obj)
  5843. }
  5844. if (obj.type === 'Buffer' && isArray(obj.data)) {
  5845. return fromArrayLike(that, obj.data)
  5846. }
  5847. }
  5848. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  5849. }
  5850. function checked (length) {
  5851. // Note: cannot use `length < kMaxLength()` here because that fails when
  5852. // length is NaN (which is otherwise coerced to zero.)
  5853. if (length >= kMaxLength()) {
  5854. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  5855. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  5856. }
  5857. return length | 0
  5858. }
  5859. function SlowBuffer (length) {
  5860. if (+length != length) { // eslint-disable-line eqeqeq
  5861. length = 0
  5862. }
  5863. return Buffer.alloc(+length)
  5864. }
  5865. Buffer.isBuffer = function isBuffer (b) {
  5866. return !!(b != null && b._isBuffer)
  5867. }
  5868. Buffer.compare = function compare (a, b) {
  5869. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  5870. throw new TypeError('Arguments must be Buffers')
  5871. }
  5872. if (a === b) return 0
  5873. var x = a.length
  5874. var y = b.length
  5875. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  5876. if (a[i] !== b[i]) {
  5877. x = a[i]
  5878. y = b[i]
  5879. break
  5880. }
  5881. }
  5882. if (x < y) return -1
  5883. if (y < x) return 1
  5884. return 0
  5885. }
  5886. Buffer.isEncoding = function isEncoding (encoding) {
  5887. switch (String(encoding).toLowerCase()) {
  5888. case 'hex':
  5889. case 'utf8':
  5890. case 'utf-8':
  5891. case 'ascii':
  5892. case 'latin1':
  5893. case 'binary':
  5894. case 'base64':
  5895. case 'ucs2':
  5896. case 'ucs-2':
  5897. case 'utf16le':
  5898. case 'utf-16le':
  5899. return true
  5900. default:
  5901. return false
  5902. }
  5903. }
  5904. Buffer.concat = function concat (list, length) {
  5905. if (!isArray(list)) {
  5906. throw new TypeError('"list" argument must be an Array of Buffers')
  5907. }
  5908. if (list.length === 0) {
  5909. return Buffer.alloc(0)
  5910. }
  5911. var i
  5912. if (length === undefined) {
  5913. length = 0
  5914. for (i = 0; i < list.length; ++i) {
  5915. length += list[i].length
  5916. }
  5917. }
  5918. var buffer = Buffer.allocUnsafe(length)
  5919. var pos = 0
  5920. for (i = 0; i < list.length; ++i) {
  5921. var buf = list[i]
  5922. if (!Buffer.isBuffer(buf)) {
  5923. throw new TypeError('"list" argument must be an Array of Buffers')
  5924. }
  5925. buf.copy(buffer, pos)
  5926. pos += buf.length
  5927. }
  5928. return buffer
  5929. }
  5930. function byteLength (string, encoding) {
  5931. if (Buffer.isBuffer(string)) {
  5932. return string.length
  5933. }
  5934. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  5935. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  5936. return string.byteLength
  5937. }
  5938. if (typeof string !== 'string') {
  5939. string = '' + string
  5940. }
  5941. var len = string.length
  5942. if (len === 0) return 0
  5943. // Use a for loop to avoid recursion
  5944. var loweredCase = false
  5945. for (;;) {
  5946. switch (encoding) {
  5947. case 'ascii':
  5948. case 'latin1':
  5949. case 'binary':
  5950. return len
  5951. case 'utf8':
  5952. case 'utf-8':
  5953. case undefined:
  5954. return utf8ToBytes(string).length
  5955. case 'ucs2':
  5956. case 'ucs-2':
  5957. case 'utf16le':
  5958. case 'utf-16le':
  5959. return len * 2
  5960. case 'hex':
  5961. return len >>> 1
  5962. case 'base64':
  5963. return base64ToBytes(string).length
  5964. default:
  5965. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  5966. encoding = ('' + encoding).toLowerCase()
  5967. loweredCase = true
  5968. }
  5969. }
  5970. }
  5971. Buffer.byteLength = byteLength
  5972. function slowToString (encoding, start, end) {
  5973. var loweredCase = false
  5974. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  5975. // property of a typed array.
  5976. // This behaves neither like String nor Uint8Array in that we set start/end
  5977. // to their upper/lower bounds if the value passed is out of range.
  5978. // undefined is handled specially as per ECMA-262 6th Edition,
  5979. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  5980. if (start === undefined || start < 0) {
  5981. start = 0
  5982. }
  5983. // Return early if start > this.length. Done here to prevent potential uint32
  5984. // coercion fail below.
  5985. if (start > this.length) {
  5986. return ''
  5987. }
  5988. if (end === undefined || end > this.length) {
  5989. end = this.length
  5990. }
  5991. if (end <= 0) {
  5992. return ''
  5993. }
  5994. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  5995. end >>>= 0
  5996. start >>>= 0
  5997. if (end <= start) {
  5998. return ''
  5999. }
  6000. if (!encoding) encoding = 'utf8'
  6001. while (true) {
  6002. switch (encoding) {
  6003. case 'hex':
  6004. return hexSlice(this, start, end)
  6005. case 'utf8':
  6006. case 'utf-8':
  6007. return utf8Slice(this, start, end)
  6008. case 'ascii':
  6009. return asciiSlice(this, start, end)
  6010. case 'latin1':
  6011. case 'binary':
  6012. return latin1Slice(this, start, end)
  6013. case 'base64':
  6014. return base64Slice(this, start, end)
  6015. case 'ucs2':
  6016. case 'ucs-2':
  6017. case 'utf16le':
  6018. case 'utf-16le':
  6019. return utf16leSlice(this, start, end)
  6020. default:
  6021. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6022. encoding = (encoding + '').toLowerCase()
  6023. loweredCase = true
  6024. }
  6025. }
  6026. }
  6027. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  6028. // Buffer instances.
  6029. Buffer.prototype._isBuffer = true
  6030. function swap (b, n, m) {
  6031. var i = b[n]
  6032. b[n] = b[m]
  6033. b[m] = i
  6034. }
  6035. Buffer.prototype.swap16 = function swap16 () {
  6036. var len = this.length
  6037. if (len % 2 !== 0) {
  6038. throw new RangeError('Buffer size must be a multiple of 16-bits')
  6039. }
  6040. for (var i = 0; i < len; i += 2) {
  6041. swap(this, i, i + 1)
  6042. }
  6043. return this
  6044. }
  6045. Buffer.prototype.swap32 = function swap32 () {
  6046. var len = this.length
  6047. if (len % 4 !== 0) {
  6048. throw new RangeError('Buffer size must be a multiple of 32-bits')
  6049. }
  6050. for (var i = 0; i < len; i += 4) {
  6051. swap(this, i, i + 3)
  6052. swap(this, i + 1, i + 2)
  6053. }
  6054. return this
  6055. }
  6056. Buffer.prototype.swap64 = function swap64 () {
  6057. var len = this.length
  6058. if (len % 8 !== 0) {
  6059. throw new RangeError('Buffer size must be a multiple of 64-bits')
  6060. }
  6061. for (var i = 0; i < len; i += 8) {
  6062. swap(this, i, i + 7)
  6063. swap(this, i + 1, i + 6)
  6064. swap(this, i + 2, i + 5)
  6065. swap(this, i + 3, i + 4)
  6066. }
  6067. return this
  6068. }
  6069. Buffer.prototype.toString = function toString () {
  6070. var length = this.length | 0
  6071. if (length === 0) return ''
  6072. if (arguments.length === 0) return utf8Slice(this, 0, length)
  6073. return slowToString.apply(this, arguments)
  6074. }
  6075. Buffer.prototype.equals = function equals (b) {
  6076. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  6077. if (this === b) return true
  6078. return Buffer.compare(this, b) === 0
  6079. }
  6080. Buffer.prototype.inspect = function inspect () {
  6081. var str = ''
  6082. var max = exports.INSPECT_MAX_BYTES
  6083. if (this.length > 0) {
  6084. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  6085. if (this.length > max) str += ' ... '
  6086. }
  6087. return '<Buffer ' + str + '>'
  6088. }
  6089. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  6090. if (!Buffer.isBuffer(target)) {
  6091. throw new TypeError('Argument must be a Buffer')
  6092. }
  6093. if (start === undefined) {
  6094. start = 0
  6095. }
  6096. if (end === undefined) {
  6097. end = target ? target.length : 0
  6098. }
  6099. if (thisStart === undefined) {
  6100. thisStart = 0
  6101. }
  6102. if (thisEnd === undefined) {
  6103. thisEnd = this.length
  6104. }
  6105. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  6106. throw new RangeError('out of range index')
  6107. }
  6108. if (thisStart >= thisEnd && start >= end) {
  6109. return 0
  6110. }
  6111. if (thisStart >= thisEnd) {
  6112. return -1
  6113. }
  6114. if (start >= end) {
  6115. return 1
  6116. }
  6117. start >>>= 0
  6118. end >>>= 0
  6119. thisStart >>>= 0
  6120. thisEnd >>>= 0
  6121. if (this === target) return 0
  6122. var x = thisEnd - thisStart
  6123. var y = end - start
  6124. var len = Math.min(x, y)
  6125. var thisCopy = this.slice(thisStart, thisEnd)
  6126. var targetCopy = target.slice(start, end)
  6127. for (var i = 0; i < len; ++i) {
  6128. if (thisCopy[i] !== targetCopy[i]) {
  6129. x = thisCopy[i]
  6130. y = targetCopy[i]
  6131. break
  6132. }
  6133. }
  6134. if (x < y) return -1
  6135. if (y < x) return 1
  6136. return 0
  6137. }
  6138. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  6139. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  6140. //
  6141. // Arguments:
  6142. // - buffer - a Buffer to search
  6143. // - val - a string, Buffer, or number
  6144. // - byteOffset - an index into `buffer`; will be clamped to an int32
  6145. // - encoding - an optional encoding, relevant is val is a string
  6146. // - dir - true for indexOf, false for lastIndexOf
  6147. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  6148. // Empty buffer means no match
  6149. if (buffer.length === 0) return -1
  6150. // Normalize byteOffset
  6151. if (typeof byteOffset === 'string') {
  6152. encoding = byteOffset
  6153. byteOffset = 0
  6154. } else if (byteOffset > 0x7fffffff) {
  6155. byteOffset = 0x7fffffff
  6156. } else if (byteOffset < -0x80000000) {
  6157. byteOffset = -0x80000000
  6158. }
  6159. byteOffset = +byteOffset // Coerce to Number.
  6160. if (isNaN(byteOffset)) {
  6161. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  6162. byteOffset = dir ? 0 : (buffer.length - 1)
  6163. }
  6164. // Normalize byteOffset: negative offsets start from the end of the buffer
  6165. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  6166. if (byteOffset >= buffer.length) {
  6167. if (dir) return -1
  6168. else byteOffset = buffer.length - 1
  6169. } else if (byteOffset < 0) {
  6170. if (dir) byteOffset = 0
  6171. else return -1
  6172. }
  6173. // Normalize val
  6174. if (typeof val === 'string') {
  6175. val = Buffer.from(val, encoding)
  6176. }
  6177. // Finally, search either indexOf (if dir is true) or lastIndexOf
  6178. if (Buffer.isBuffer(val)) {
  6179. // Special case: looking for empty string/buffer always fails
  6180. if (val.length === 0) {
  6181. return -1
  6182. }
  6183. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  6184. } else if (typeof val === 'number') {
  6185. val = val & 0xFF // Search for a byte value [0-255]
  6186. if (Buffer.TYPED_ARRAY_SUPPORT &&
  6187. typeof Uint8Array.prototype.indexOf === 'function') {
  6188. if (dir) {
  6189. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  6190. } else {
  6191. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  6192. }
  6193. }
  6194. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  6195. }
  6196. throw new TypeError('val must be string, number or Buffer')
  6197. }
  6198. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  6199. var indexSize = 1
  6200. var arrLength = arr.length
  6201. var valLength = val.length
  6202. if (encoding !== undefined) {
  6203. encoding = String(encoding).toLowerCase()
  6204. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  6205. encoding === 'utf16le' || encoding === 'utf-16le') {
  6206. if (arr.length < 2 || val.length < 2) {
  6207. return -1
  6208. }
  6209. indexSize = 2
  6210. arrLength /= 2
  6211. valLength /= 2
  6212. byteOffset /= 2
  6213. }
  6214. }
  6215. function read (buf, i) {
  6216. if (indexSize === 1) {
  6217. return buf[i]
  6218. } else {
  6219. return buf.readUInt16BE(i * indexSize)
  6220. }
  6221. }
  6222. var i
  6223. if (dir) {
  6224. var foundIndex = -1
  6225. for (i = byteOffset; i < arrLength; i++) {
  6226. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  6227. if (foundIndex === -1) foundIndex = i
  6228. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  6229. } else {
  6230. if (foundIndex !== -1) i -= i - foundIndex
  6231. foundIndex = -1
  6232. }
  6233. }
  6234. } else {
  6235. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  6236. for (i = byteOffset; i >= 0; i--) {
  6237. var found = true
  6238. for (var j = 0; j < valLength; j++) {
  6239. if (read(arr, i + j) !== read(val, j)) {
  6240. found = false
  6241. break
  6242. }
  6243. }
  6244. if (found) return i
  6245. }
  6246. }
  6247. return -1
  6248. }
  6249. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  6250. return this.indexOf(val, byteOffset, encoding) !== -1
  6251. }
  6252. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  6253. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  6254. }
  6255. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  6256. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  6257. }
  6258. function hexWrite (buf, string, offset, length) {
  6259. offset = Number(offset) || 0
  6260. var remaining = buf.length - offset
  6261. if (!length) {
  6262. length = remaining
  6263. } else {
  6264. length = Number(length)
  6265. if (length > remaining) {
  6266. length = remaining
  6267. }
  6268. }
  6269. // must be an even number of digits
  6270. var strLen = string.length
  6271. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  6272. if (length > strLen / 2) {
  6273. length = strLen / 2
  6274. }
  6275. for (var i = 0; i < length; ++i) {
  6276. var parsed = parseInt(string.substr(i * 2, 2), 16)
  6277. if (isNaN(parsed)) return i
  6278. buf[offset + i] = parsed
  6279. }
  6280. return i
  6281. }
  6282. function utf8Write (buf, string, offset, length) {
  6283. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  6284. }
  6285. function asciiWrite (buf, string, offset, length) {
  6286. return blitBuffer(asciiToBytes(string), buf, offset, length)
  6287. }
  6288. function latin1Write (buf, string, offset, length) {
  6289. return asciiWrite(buf, string, offset, length)
  6290. }
  6291. function base64Write (buf, string, offset, length) {
  6292. return blitBuffer(base64ToBytes(string), buf, offset, length)
  6293. }
  6294. function ucs2Write (buf, string, offset, length) {
  6295. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  6296. }
  6297. Buffer.prototype.write = function write (string, offset, length, encoding) {
  6298. // Buffer#write(string)
  6299. if (offset === undefined) {
  6300. encoding = 'utf8'
  6301. length = this.length
  6302. offset = 0
  6303. // Buffer#write(string, encoding)
  6304. } else if (length === undefined && typeof offset === 'string') {
  6305. encoding = offset
  6306. length = this.length
  6307. offset = 0
  6308. // Buffer#write(string, offset[, length][, encoding])
  6309. } else if (isFinite(offset)) {
  6310. offset = offset | 0
  6311. if (isFinite(length)) {
  6312. length = length | 0
  6313. if (encoding === undefined) encoding = 'utf8'
  6314. } else {
  6315. encoding = length
  6316. length = undefined
  6317. }
  6318. // legacy write(string, encoding, offset, length) - remove in v0.13
  6319. } else {
  6320. throw new Error(
  6321. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  6322. )
  6323. }
  6324. var remaining = this.length - offset
  6325. if (length === undefined || length > remaining) length = remaining
  6326. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  6327. throw new RangeError('Attempt to write outside buffer bounds')
  6328. }
  6329. if (!encoding) encoding = 'utf8'
  6330. var loweredCase = false
  6331. for (;;) {
  6332. switch (encoding) {
  6333. case 'hex':
  6334. return hexWrite(this, string, offset, length)
  6335. case 'utf8':
  6336. case 'utf-8':
  6337. return utf8Write(this, string, offset, length)
  6338. case 'ascii':
  6339. return asciiWrite(this, string, offset, length)
  6340. case 'latin1':
  6341. case 'binary':
  6342. return latin1Write(this, string, offset, length)
  6343. case 'base64':
  6344. // Warning: maxLength not taken into account in base64Write
  6345. return base64Write(this, string, offset, length)
  6346. case 'ucs2':
  6347. case 'ucs-2':
  6348. case 'utf16le':
  6349. case 'utf-16le':
  6350. return ucs2Write(this, string, offset, length)
  6351. default:
  6352. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  6353. encoding = ('' + encoding).toLowerCase()
  6354. loweredCase = true
  6355. }
  6356. }
  6357. }
  6358. Buffer.prototype.toJSON = function toJSON () {
  6359. return {
  6360. type: 'Buffer',
  6361. data: Array.prototype.slice.call(this._arr || this, 0)
  6362. }
  6363. }
  6364. function base64Slice (buf, start, end) {
  6365. if (start === 0 && end === buf.length) {
  6366. return base64.fromByteArray(buf)
  6367. } else {
  6368. return base64.fromByteArray(buf.slice(start, end))
  6369. }
  6370. }
  6371. function utf8Slice (buf, start, end) {
  6372. end = Math.min(buf.length, end)
  6373. var res = []
  6374. var i = start
  6375. while (i < end) {
  6376. var firstByte = buf[i]
  6377. var codePoint = null
  6378. var bytesPerSequence = (firstByte > 0xEF) ? 4
  6379. : (firstByte > 0xDF) ? 3
  6380. : (firstByte > 0xBF) ? 2
  6381. : 1
  6382. if (i + bytesPerSequence <= end) {
  6383. var secondByte, thirdByte, fourthByte, tempCodePoint
  6384. switch (bytesPerSequence) {
  6385. case 1:
  6386. if (firstByte < 0x80) {
  6387. codePoint = firstByte
  6388. }
  6389. break
  6390. case 2:
  6391. secondByte = buf[i + 1]
  6392. if ((secondByte & 0xC0) === 0x80) {
  6393. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  6394. if (tempCodePoint > 0x7F) {
  6395. codePoint = tempCodePoint
  6396. }
  6397. }
  6398. break
  6399. case 3:
  6400. secondByte = buf[i + 1]
  6401. thirdByte = buf[i + 2]
  6402. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  6403. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  6404. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  6405. codePoint = tempCodePoint
  6406. }
  6407. }
  6408. break
  6409. case 4:
  6410. secondByte = buf[i + 1]
  6411. thirdByte = buf[i + 2]
  6412. fourthByte = buf[i + 3]
  6413. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  6414. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  6415. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  6416. codePoint = tempCodePoint
  6417. }
  6418. }
  6419. }
  6420. }
  6421. if (codePoint === null) {
  6422. // we did not generate a valid codePoint so insert a
  6423. // replacement char (U+FFFD) and advance only 1 byte
  6424. codePoint = 0xFFFD
  6425. bytesPerSequence = 1
  6426. } else if (codePoint > 0xFFFF) {
  6427. // encode to utf16 (surrogate pair dance)
  6428. codePoint -= 0x10000
  6429. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  6430. codePoint = 0xDC00 | codePoint & 0x3FF
  6431. }
  6432. res.push(codePoint)
  6433. i += bytesPerSequence
  6434. }
  6435. return decodeCodePointsArray(res)
  6436. }
  6437. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  6438. // the lowest limit is Chrome, with 0x10000 args.
  6439. // We go 1 magnitude less, for safety
  6440. var MAX_ARGUMENTS_LENGTH = 0x1000
  6441. function decodeCodePointsArray (codePoints) {
  6442. var len = codePoints.length
  6443. if (len <= MAX_ARGUMENTS_LENGTH) {
  6444. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  6445. }
  6446. // Decode in chunks to avoid "call stack size exceeded".
  6447. var res = ''
  6448. var i = 0
  6449. while (i < len) {
  6450. res += String.fromCharCode.apply(
  6451. String,
  6452. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  6453. )
  6454. }
  6455. return res
  6456. }
  6457. function asciiSlice (buf, start, end) {
  6458. var ret = ''
  6459. end = Math.min(buf.length, end)
  6460. for (var i = start; i < end; ++i) {
  6461. ret += String.fromCharCode(buf[i] & 0x7F)
  6462. }
  6463. return ret
  6464. }
  6465. function latin1Slice (buf, start, end) {
  6466. var ret = ''
  6467. end = Math.min(buf.length, end)
  6468. for (var i = start; i < end; ++i) {
  6469. ret += String.fromCharCode(buf[i])
  6470. }
  6471. return ret
  6472. }
  6473. function hexSlice (buf, start, end) {
  6474. var len = buf.length
  6475. if (!start || start < 0) start = 0
  6476. if (!end || end < 0 || end > len) end = len
  6477. var out = ''
  6478. for (var i = start; i < end; ++i) {
  6479. out += toHex(buf[i])
  6480. }
  6481. return out
  6482. }
  6483. function utf16leSlice (buf, start, end) {
  6484. var bytes = buf.slice(start, end)
  6485. var res = ''
  6486. for (var i = 0; i < bytes.length; i += 2) {
  6487. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  6488. }
  6489. return res
  6490. }
  6491. Buffer.prototype.slice = function slice (start, end) {
  6492. var len = this.length
  6493. start = ~~start
  6494. end = end === undefined ? len : ~~end
  6495. if (start < 0) {
  6496. start += len
  6497. if (start < 0) start = 0
  6498. } else if (start > len) {
  6499. start = len
  6500. }
  6501. if (end < 0) {
  6502. end += len
  6503. if (end < 0) end = 0
  6504. } else if (end > len) {
  6505. end = len
  6506. }
  6507. if (end < start) end = start
  6508. var newBuf
  6509. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6510. newBuf = this.subarray(start, end)
  6511. newBuf.__proto__ = Buffer.prototype
  6512. } else {
  6513. var sliceLen = end - start
  6514. newBuf = new Buffer(sliceLen, undefined)
  6515. for (var i = 0; i < sliceLen; ++i) {
  6516. newBuf[i] = this[i + start]
  6517. }
  6518. }
  6519. return newBuf
  6520. }
  6521. /*
  6522. * Need to make sure that buffer isn't trying to write out of bounds.
  6523. */
  6524. function checkOffset (offset, ext, length) {
  6525. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  6526. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  6527. }
  6528. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  6529. offset = offset | 0
  6530. byteLength = byteLength | 0
  6531. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6532. var val = this[offset]
  6533. var mul = 1
  6534. var i = 0
  6535. while (++i < byteLength && (mul *= 0x100)) {
  6536. val += this[offset + i] * mul
  6537. }
  6538. return val
  6539. }
  6540. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  6541. offset = offset | 0
  6542. byteLength = byteLength | 0
  6543. if (!noAssert) {
  6544. checkOffset(offset, byteLength, this.length)
  6545. }
  6546. var val = this[offset + --byteLength]
  6547. var mul = 1
  6548. while (byteLength > 0 && (mul *= 0x100)) {
  6549. val += this[offset + --byteLength] * mul
  6550. }
  6551. return val
  6552. }
  6553. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  6554. if (!noAssert) checkOffset(offset, 1, this.length)
  6555. return this[offset]
  6556. }
  6557. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  6558. if (!noAssert) checkOffset(offset, 2, this.length)
  6559. return this[offset] | (this[offset + 1] << 8)
  6560. }
  6561. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  6562. if (!noAssert) checkOffset(offset, 2, this.length)
  6563. return (this[offset] << 8) | this[offset + 1]
  6564. }
  6565. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  6566. if (!noAssert) checkOffset(offset, 4, this.length)
  6567. return ((this[offset]) |
  6568. (this[offset + 1] << 8) |
  6569. (this[offset + 2] << 16)) +
  6570. (this[offset + 3] * 0x1000000)
  6571. }
  6572. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  6573. if (!noAssert) checkOffset(offset, 4, this.length)
  6574. return (this[offset] * 0x1000000) +
  6575. ((this[offset + 1] << 16) |
  6576. (this[offset + 2] << 8) |
  6577. this[offset + 3])
  6578. }
  6579. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  6580. offset = offset | 0
  6581. byteLength = byteLength | 0
  6582. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6583. var val = this[offset]
  6584. var mul = 1
  6585. var i = 0
  6586. while (++i < byteLength && (mul *= 0x100)) {
  6587. val += this[offset + i] * mul
  6588. }
  6589. mul *= 0x80
  6590. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6591. return val
  6592. }
  6593. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  6594. offset = offset | 0
  6595. byteLength = byteLength | 0
  6596. if (!noAssert) checkOffset(offset, byteLength, this.length)
  6597. var i = byteLength
  6598. var mul = 1
  6599. var val = this[offset + --i]
  6600. while (i > 0 && (mul *= 0x100)) {
  6601. val += this[offset + --i] * mul
  6602. }
  6603. mul *= 0x80
  6604. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  6605. return val
  6606. }
  6607. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  6608. if (!noAssert) checkOffset(offset, 1, this.length)
  6609. if (!(this[offset] & 0x80)) return (this[offset])
  6610. return ((0xff - this[offset] + 1) * -1)
  6611. }
  6612. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  6613. if (!noAssert) checkOffset(offset, 2, this.length)
  6614. var val = this[offset] | (this[offset + 1] << 8)
  6615. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6616. }
  6617. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  6618. if (!noAssert) checkOffset(offset, 2, this.length)
  6619. var val = this[offset + 1] | (this[offset] << 8)
  6620. return (val & 0x8000) ? val | 0xFFFF0000 : val
  6621. }
  6622. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  6623. if (!noAssert) checkOffset(offset, 4, this.length)
  6624. return (this[offset]) |
  6625. (this[offset + 1] << 8) |
  6626. (this[offset + 2] << 16) |
  6627. (this[offset + 3] << 24)
  6628. }
  6629. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  6630. if (!noAssert) checkOffset(offset, 4, this.length)
  6631. return (this[offset] << 24) |
  6632. (this[offset + 1] << 16) |
  6633. (this[offset + 2] << 8) |
  6634. (this[offset + 3])
  6635. }
  6636. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  6637. if (!noAssert) checkOffset(offset, 4, this.length)
  6638. return ieee754.read(this, offset, true, 23, 4)
  6639. }
  6640. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  6641. if (!noAssert) checkOffset(offset, 4, this.length)
  6642. return ieee754.read(this, offset, false, 23, 4)
  6643. }
  6644. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  6645. if (!noAssert) checkOffset(offset, 8, this.length)
  6646. return ieee754.read(this, offset, true, 52, 8)
  6647. }
  6648. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  6649. if (!noAssert) checkOffset(offset, 8, this.length)
  6650. return ieee754.read(this, offset, false, 52, 8)
  6651. }
  6652. function checkInt (buf, value, offset, ext, max, min) {
  6653. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  6654. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  6655. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6656. }
  6657. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  6658. value = +value
  6659. offset = offset | 0
  6660. byteLength = byteLength | 0
  6661. if (!noAssert) {
  6662. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6663. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6664. }
  6665. var mul = 1
  6666. var i = 0
  6667. this[offset] = value & 0xFF
  6668. while (++i < byteLength && (mul *= 0x100)) {
  6669. this[offset + i] = (value / mul) & 0xFF
  6670. }
  6671. return offset + byteLength
  6672. }
  6673. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  6674. value = +value
  6675. offset = offset | 0
  6676. byteLength = byteLength | 0
  6677. if (!noAssert) {
  6678. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  6679. checkInt(this, value, offset, byteLength, maxBytes, 0)
  6680. }
  6681. var i = byteLength - 1
  6682. var mul = 1
  6683. this[offset + i] = value & 0xFF
  6684. while (--i >= 0 && (mul *= 0x100)) {
  6685. this[offset + i] = (value / mul) & 0xFF
  6686. }
  6687. return offset + byteLength
  6688. }
  6689. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  6690. value = +value
  6691. offset = offset | 0
  6692. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  6693. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6694. this[offset] = (value & 0xff)
  6695. return offset + 1
  6696. }
  6697. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  6698. if (value < 0) value = 0xffff + value + 1
  6699. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  6700. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  6701. (littleEndian ? i : 1 - i) * 8
  6702. }
  6703. }
  6704. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  6705. value = +value
  6706. offset = offset | 0
  6707. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6708. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6709. this[offset] = (value & 0xff)
  6710. this[offset + 1] = (value >>> 8)
  6711. } else {
  6712. objectWriteUInt16(this, value, offset, true)
  6713. }
  6714. return offset + 2
  6715. }
  6716. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  6717. value = +value
  6718. offset = offset | 0
  6719. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  6720. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6721. this[offset] = (value >>> 8)
  6722. this[offset + 1] = (value & 0xff)
  6723. } else {
  6724. objectWriteUInt16(this, value, offset, false)
  6725. }
  6726. return offset + 2
  6727. }
  6728. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  6729. if (value < 0) value = 0xffffffff + value + 1
  6730. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  6731. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  6732. }
  6733. }
  6734. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  6735. value = +value
  6736. offset = offset | 0
  6737. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6738. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6739. this[offset + 3] = (value >>> 24)
  6740. this[offset + 2] = (value >>> 16)
  6741. this[offset + 1] = (value >>> 8)
  6742. this[offset] = (value & 0xff)
  6743. } else {
  6744. objectWriteUInt32(this, value, offset, true)
  6745. }
  6746. return offset + 4
  6747. }
  6748. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  6749. value = +value
  6750. offset = offset | 0
  6751. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  6752. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6753. this[offset] = (value >>> 24)
  6754. this[offset + 1] = (value >>> 16)
  6755. this[offset + 2] = (value >>> 8)
  6756. this[offset + 3] = (value & 0xff)
  6757. } else {
  6758. objectWriteUInt32(this, value, offset, false)
  6759. }
  6760. return offset + 4
  6761. }
  6762. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  6763. value = +value
  6764. offset = offset | 0
  6765. if (!noAssert) {
  6766. var limit = Math.pow(2, 8 * byteLength - 1)
  6767. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6768. }
  6769. var i = 0
  6770. var mul = 1
  6771. var sub = 0
  6772. this[offset] = value & 0xFF
  6773. while (++i < byteLength && (mul *= 0x100)) {
  6774. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  6775. sub = 1
  6776. }
  6777. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6778. }
  6779. return offset + byteLength
  6780. }
  6781. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  6782. value = +value
  6783. offset = offset | 0
  6784. if (!noAssert) {
  6785. var limit = Math.pow(2, 8 * byteLength - 1)
  6786. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  6787. }
  6788. var i = byteLength - 1
  6789. var mul = 1
  6790. var sub = 0
  6791. this[offset + i] = value & 0xFF
  6792. while (--i >= 0 && (mul *= 0x100)) {
  6793. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  6794. sub = 1
  6795. }
  6796. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  6797. }
  6798. return offset + byteLength
  6799. }
  6800. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  6801. value = +value
  6802. offset = offset | 0
  6803. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  6804. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  6805. if (value < 0) value = 0xff + value + 1
  6806. this[offset] = (value & 0xff)
  6807. return offset + 1
  6808. }
  6809. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  6810. value = +value
  6811. offset = offset | 0
  6812. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6813. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6814. this[offset] = (value & 0xff)
  6815. this[offset + 1] = (value >>> 8)
  6816. } else {
  6817. objectWriteUInt16(this, value, offset, true)
  6818. }
  6819. return offset + 2
  6820. }
  6821. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  6822. value = +value
  6823. offset = offset | 0
  6824. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  6825. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6826. this[offset] = (value >>> 8)
  6827. this[offset + 1] = (value & 0xff)
  6828. } else {
  6829. objectWriteUInt16(this, value, offset, false)
  6830. }
  6831. return offset + 2
  6832. }
  6833. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  6834. value = +value
  6835. offset = offset | 0
  6836. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6837. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6838. this[offset] = (value & 0xff)
  6839. this[offset + 1] = (value >>> 8)
  6840. this[offset + 2] = (value >>> 16)
  6841. this[offset + 3] = (value >>> 24)
  6842. } else {
  6843. objectWriteUInt32(this, value, offset, true)
  6844. }
  6845. return offset + 4
  6846. }
  6847. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  6848. value = +value
  6849. offset = offset | 0
  6850. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  6851. if (value < 0) value = 0xffffffff + value + 1
  6852. if (Buffer.TYPED_ARRAY_SUPPORT) {
  6853. this[offset] = (value >>> 24)
  6854. this[offset + 1] = (value >>> 16)
  6855. this[offset + 2] = (value >>> 8)
  6856. this[offset + 3] = (value & 0xff)
  6857. } else {
  6858. objectWriteUInt32(this, value, offset, false)
  6859. }
  6860. return offset + 4
  6861. }
  6862. function checkIEEE754 (buf, value, offset, ext, max, min) {
  6863. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  6864. if (offset < 0) throw new RangeError('Index out of range')
  6865. }
  6866. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  6867. if (!noAssert) {
  6868. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  6869. }
  6870. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  6871. return offset + 4
  6872. }
  6873. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  6874. return writeFloat(this, value, offset, true, noAssert)
  6875. }
  6876. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  6877. return writeFloat(this, value, offset, false, noAssert)
  6878. }
  6879. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  6880. if (!noAssert) {
  6881. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  6882. }
  6883. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  6884. return offset + 8
  6885. }
  6886. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  6887. return writeDouble(this, value, offset, true, noAssert)
  6888. }
  6889. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  6890. return writeDouble(this, value, offset, false, noAssert)
  6891. }
  6892. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  6893. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  6894. if (!start) start = 0
  6895. if (!end && end !== 0) end = this.length
  6896. if (targetStart >= target.length) targetStart = target.length
  6897. if (!targetStart) targetStart = 0
  6898. if (end > 0 && end < start) end = start
  6899. // Copy 0 bytes; we're done
  6900. if (end === start) return 0
  6901. if (target.length === 0 || this.length === 0) return 0
  6902. // Fatal error conditions
  6903. if (targetStart < 0) {
  6904. throw new RangeError('targetStart out of bounds')
  6905. }
  6906. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  6907. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  6908. // Are we oob?
  6909. if (end > this.length) end = this.length
  6910. if (target.length - targetStart < end - start) {
  6911. end = target.length - targetStart + start
  6912. }
  6913. var len = end - start
  6914. var i
  6915. if (this === target && start < targetStart && targetStart < end) {
  6916. // descending copy from end
  6917. for (i = len - 1; i >= 0; --i) {
  6918. target[i + targetStart] = this[i + start]
  6919. }
  6920. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  6921. // ascending copy from start
  6922. for (i = 0; i < len; ++i) {
  6923. target[i + targetStart] = this[i + start]
  6924. }
  6925. } else {
  6926. Uint8Array.prototype.set.call(
  6927. target,
  6928. this.subarray(start, start + len),
  6929. targetStart
  6930. )
  6931. }
  6932. return len
  6933. }
  6934. // Usage:
  6935. // buffer.fill(number[, offset[, end]])
  6936. // buffer.fill(buffer[, offset[, end]])
  6937. // buffer.fill(string[, offset[, end]][, encoding])
  6938. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  6939. // Handle string cases:
  6940. if (typeof val === 'string') {
  6941. if (typeof start === 'string') {
  6942. encoding = start
  6943. start = 0
  6944. end = this.length
  6945. } else if (typeof end === 'string') {
  6946. encoding = end
  6947. end = this.length
  6948. }
  6949. if (val.length === 1) {
  6950. var code = val.charCodeAt(0)
  6951. if (code < 256) {
  6952. val = code
  6953. }
  6954. }
  6955. if (encoding !== undefined && typeof encoding !== 'string') {
  6956. throw new TypeError('encoding must be a string')
  6957. }
  6958. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  6959. throw new TypeError('Unknown encoding: ' + encoding)
  6960. }
  6961. } else if (typeof val === 'number') {
  6962. val = val & 255
  6963. }
  6964. // Invalid ranges are not set to a default, so can range check early.
  6965. if (start < 0 || this.length < start || this.length < end) {
  6966. throw new RangeError('Out of range index')
  6967. }
  6968. if (end <= start) {
  6969. return this
  6970. }
  6971. start = start >>> 0
  6972. end = end === undefined ? this.length : end >>> 0
  6973. if (!val) val = 0
  6974. var i
  6975. if (typeof val === 'number') {
  6976. for (i = start; i < end; ++i) {
  6977. this[i] = val
  6978. }
  6979. } else {
  6980. var bytes = Buffer.isBuffer(val)
  6981. ? val
  6982. : utf8ToBytes(new Buffer(val, encoding).toString())
  6983. var len = bytes.length
  6984. for (i = 0; i < end - start; ++i) {
  6985. this[i + start] = bytes[i % len]
  6986. }
  6987. }
  6988. return this
  6989. }
  6990. // HELPER FUNCTIONS
  6991. // ================
  6992. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  6993. function base64clean (str) {
  6994. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  6995. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  6996. // Node converts strings with length < 2 to ''
  6997. if (str.length < 2) return ''
  6998. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  6999. while (str.length % 4 !== 0) {
  7000. str = str + '='
  7001. }
  7002. return str
  7003. }
  7004. function stringtrim (str) {
  7005. if (str.trim) return str.trim()
  7006. return str.replace(/^\s+|\s+$/g, '')
  7007. }
  7008. function toHex (n) {
  7009. if (n < 16) return '0' + n.toString(16)
  7010. return n.toString(16)
  7011. }
  7012. function utf8ToBytes (string, units) {
  7013. units = units || Infinity
  7014. var codePoint
  7015. var length = string.length
  7016. var leadSurrogate = null
  7017. var bytes = []
  7018. for (var i = 0; i < length; ++i) {
  7019. codePoint = string.charCodeAt(i)
  7020. // is surrogate component
  7021. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  7022. // last char was a lead
  7023. if (!leadSurrogate) {
  7024. // no lead yet
  7025. if (codePoint > 0xDBFF) {
  7026. // unexpected trail
  7027. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7028. continue
  7029. } else if (i + 1 === length) {
  7030. // unpaired lead
  7031. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7032. continue
  7033. }
  7034. // valid lead
  7035. leadSurrogate = codePoint
  7036. continue
  7037. }
  7038. // 2 leads in a row
  7039. if (codePoint < 0xDC00) {
  7040. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7041. leadSurrogate = codePoint
  7042. continue
  7043. }
  7044. // valid surrogate pair
  7045. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  7046. } else if (leadSurrogate) {
  7047. // valid bmp char, but last char was a lead
  7048. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  7049. }
  7050. leadSurrogate = null
  7051. // encode utf8
  7052. if (codePoint < 0x80) {
  7053. if ((units -= 1) < 0) break
  7054. bytes.push(codePoint)
  7055. } else if (codePoint < 0x800) {
  7056. if ((units -= 2) < 0) break
  7057. bytes.push(
  7058. codePoint >> 0x6 | 0xC0,
  7059. codePoint & 0x3F | 0x80
  7060. )
  7061. } else if (codePoint < 0x10000) {
  7062. if ((units -= 3) < 0) break
  7063. bytes.push(
  7064. codePoint >> 0xC | 0xE0,
  7065. codePoint >> 0x6 & 0x3F | 0x80,
  7066. codePoint & 0x3F | 0x80
  7067. )
  7068. } else if (codePoint < 0x110000) {
  7069. if ((units -= 4) < 0) break
  7070. bytes.push(
  7071. codePoint >> 0x12 | 0xF0,
  7072. codePoint >> 0xC & 0x3F | 0x80,
  7073. codePoint >> 0x6 & 0x3F | 0x80,
  7074. codePoint & 0x3F | 0x80
  7075. )
  7076. } else {
  7077. throw new Error('Invalid code point')
  7078. }
  7079. }
  7080. return bytes
  7081. }
  7082. function asciiToBytes (str) {
  7083. var byteArray = []
  7084. for (var i = 0; i < str.length; ++i) {
  7085. // Node's code seems to be doing this and not & 0x7F..
  7086. byteArray.push(str.charCodeAt(i) & 0xFF)
  7087. }
  7088. return byteArray
  7089. }
  7090. function utf16leToBytes (str, units) {
  7091. var c, hi, lo
  7092. var byteArray = []
  7093. for (var i = 0; i < str.length; ++i) {
  7094. if ((units -= 2) < 0) break
  7095. c = str.charCodeAt(i)
  7096. hi = c >> 8
  7097. lo = c % 256
  7098. byteArray.push(lo)
  7099. byteArray.push(hi)
  7100. }
  7101. return byteArray
  7102. }
  7103. function base64ToBytes (str) {
  7104. return base64.toByteArray(base64clean(str))
  7105. }
  7106. function blitBuffer (src, dst, offset, length) {
  7107. for (var i = 0; i < length; ++i) {
  7108. if ((i + offset >= dst.length) || (i >= src.length)) break
  7109. dst[i + offset] = src[i]
  7110. }
  7111. return i
  7112. }
  7113. function isnan (val) {
  7114. return val !== val // eslint-disable-line no-self-compare
  7115. }
  7116. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  7117. /***/ }),
  7118. /***/ "./node_modules/clipboard/dist/clipboard.js":
  7119. /*!**************************************************!*\
  7120. !*** ./node_modules/clipboard/dist/clipboard.js ***!
  7121. \**************************************************/
  7122. /*! no static exports found */
  7123. /***/ (function(module, exports, __webpack_require__) {
  7124. /*!
  7125. * clipboard.js v2.0.4
  7126. * https://zenorocha.github.io/clipboard.js
  7127. *
  7128. * Licensed MIT © Zeno Rocha
  7129. */
  7130. (function webpackUniversalModuleDefinition(root, factory) {
  7131. if(true)
  7132. module.exports = factory();
  7133. else {}
  7134. })(this, function() {
  7135. return /******/ (function(modules) { // webpackBootstrap
  7136. /******/ // The module cache
  7137. /******/ var installedModules = {};
  7138. /******/
  7139. /******/ // The require function
  7140. /******/ function __webpack_require__(moduleId) {
  7141. /******/
  7142. /******/ // Check if module is in cache
  7143. /******/ if(installedModules[moduleId]) {
  7144. /******/ return installedModules[moduleId].exports;
  7145. /******/ }
  7146. /******/ // Create a new module (and put it into the cache)
  7147. /******/ var module = installedModules[moduleId] = {
  7148. /******/ i: moduleId,
  7149. /******/ l: false,
  7150. /******/ exports: {}
  7151. /******/ };
  7152. /******/
  7153. /******/ // Execute the module function
  7154. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  7155. /******/
  7156. /******/ // Flag the module as loaded
  7157. /******/ module.l = true;
  7158. /******/
  7159. /******/ // Return the exports of the module
  7160. /******/ return module.exports;
  7161. /******/ }
  7162. /******/
  7163. /******/
  7164. /******/ // expose the modules object (__webpack_modules__)
  7165. /******/ __webpack_require__.m = modules;
  7166. /******/
  7167. /******/ // expose the module cache
  7168. /******/ __webpack_require__.c = installedModules;
  7169. /******/
  7170. /******/ // define getter function for harmony exports
  7171. /******/ __webpack_require__.d = function(exports, name, getter) {
  7172. /******/ if(!__webpack_require__.o(exports, name)) {
  7173. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  7174. /******/ }
  7175. /******/ };
  7176. /******/
  7177. /******/ // define __esModule on exports
  7178. /******/ __webpack_require__.r = function(exports) {
  7179. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  7180. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  7181. /******/ }
  7182. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  7183. /******/ };
  7184. /******/
  7185. /******/ // create a fake namespace object
  7186. /******/ // mode & 1: value is a module id, require it
  7187. /******/ // mode & 2: merge all properties of value into the ns
  7188. /******/ // mode & 4: return value when already ns object
  7189. /******/ // mode & 8|1: behave like require
  7190. /******/ __webpack_require__.t = function(value, mode) {
  7191. /******/ if(mode & 1) value = __webpack_require__(value);
  7192. /******/ if(mode & 8) return value;
  7193. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  7194. /******/ var ns = Object.create(null);
  7195. /******/ __webpack_require__.r(ns);
  7196. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  7197. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  7198. /******/ return ns;
  7199. /******/ };
  7200. /******/
  7201. /******/ // getDefaultExport function for compatibility with non-harmony modules
  7202. /******/ __webpack_require__.n = function(module) {
  7203. /******/ var getter = module && module.__esModule ?
  7204. /******/ function getDefault() { return module['default']; } :
  7205. /******/ function getModuleExports() { return module; };
  7206. /******/ __webpack_require__.d(getter, 'a', getter);
  7207. /******/ return getter;
  7208. /******/ };
  7209. /******/
  7210. /******/ // Object.prototype.hasOwnProperty.call
  7211. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  7212. /******/
  7213. /******/ // __webpack_public_path__
  7214. /******/ __webpack_require__.p = "";
  7215. /******/
  7216. /******/
  7217. /******/ // Load entry module and return exports
  7218. /******/ return __webpack_require__(__webpack_require__.s = 0);
  7219. /******/ })
  7220. /************************************************************************/
  7221. /******/ ([
  7222. /* 0 */
  7223. /***/ (function(module, exports, __webpack_require__) {
  7224. "use strict";
  7225. 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; };
  7226. 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; }; }();
  7227. var _clipboardAction = __webpack_require__(1);
  7228. var _clipboardAction2 = _interopRequireDefault(_clipboardAction);
  7229. var _tinyEmitter = __webpack_require__(3);
  7230. var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter);
  7231. var _goodListener = __webpack_require__(4);
  7232. var _goodListener2 = _interopRequireDefault(_goodListener);
  7233. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7234. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7235. 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; }
  7236. 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; }
  7237. /**
  7238. * Base class which takes one or more elements, adds event listeners to them,
  7239. * and instantiates a new `ClipboardAction` on each click.
  7240. */
  7241. var Clipboard = function (_Emitter) {
  7242. _inherits(Clipboard, _Emitter);
  7243. /**
  7244. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  7245. * @param {Object} options
  7246. */
  7247. function Clipboard(trigger, options) {
  7248. _classCallCheck(this, Clipboard);
  7249. var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));
  7250. _this.resolveOptions(options);
  7251. _this.listenClick(trigger);
  7252. return _this;
  7253. }
  7254. /**
  7255. * Defines if attributes would be resolved using internal setter functions
  7256. * or custom functions that were passed in the constructor.
  7257. * @param {Object} options
  7258. */
  7259. _createClass(Clipboard, [{
  7260. key: 'resolveOptions',
  7261. value: function resolveOptions() {
  7262. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7263. this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
  7264. this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
  7265. this.text = typeof options.text === 'function' ? options.text : this.defaultText;
  7266. this.container = _typeof(options.container) === 'object' ? options.container : document.body;
  7267. }
  7268. /**
  7269. * Adds a click event listener to the passed trigger.
  7270. * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
  7271. */
  7272. }, {
  7273. key: 'listenClick',
  7274. value: function listenClick(trigger) {
  7275. var _this2 = this;
  7276. this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
  7277. return _this2.onClick(e);
  7278. });
  7279. }
  7280. /**
  7281. * Defines a new `ClipboardAction` on each click event.
  7282. * @param {Event} e
  7283. */
  7284. }, {
  7285. key: 'onClick',
  7286. value: function onClick(e) {
  7287. var trigger = e.delegateTarget || e.currentTarget;
  7288. if (this.clipboardAction) {
  7289. this.clipboardAction = null;
  7290. }
  7291. this.clipboardAction = new _clipboardAction2.default({
  7292. action: this.action(trigger),
  7293. target: this.target(trigger),
  7294. text: this.text(trigger),
  7295. container: this.container,
  7296. trigger: trigger,
  7297. emitter: this
  7298. });
  7299. }
  7300. /**
  7301. * Default `action` lookup function.
  7302. * @param {Element} trigger
  7303. */
  7304. }, {
  7305. key: 'defaultAction',
  7306. value: function defaultAction(trigger) {
  7307. return getAttributeValue('action', trigger);
  7308. }
  7309. /**
  7310. * Default `target` lookup function.
  7311. * @param {Element} trigger
  7312. */
  7313. }, {
  7314. key: 'defaultTarget',
  7315. value: function defaultTarget(trigger) {
  7316. var selector = getAttributeValue('target', trigger);
  7317. if (selector) {
  7318. return document.querySelector(selector);
  7319. }
  7320. }
  7321. /**
  7322. * Returns the support of the given action, or all actions if no action is
  7323. * given.
  7324. * @param {String} [action]
  7325. */
  7326. }, {
  7327. key: 'defaultText',
  7328. /**
  7329. * Default `text` lookup function.
  7330. * @param {Element} trigger
  7331. */
  7332. value: function defaultText(trigger) {
  7333. return getAttributeValue('text', trigger);
  7334. }
  7335. /**
  7336. * Destroy lifecycle.
  7337. */
  7338. }, {
  7339. key: 'destroy',
  7340. value: function destroy() {
  7341. this.listener.destroy();
  7342. if (this.clipboardAction) {
  7343. this.clipboardAction.destroy();
  7344. this.clipboardAction = null;
  7345. }
  7346. }
  7347. }], [{
  7348. key: 'isSupported',
  7349. value: function isSupported() {
  7350. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
  7351. var actions = typeof action === 'string' ? [action] : action;
  7352. var support = !!document.queryCommandSupported;
  7353. actions.forEach(function (action) {
  7354. support = support && !!document.queryCommandSupported(action);
  7355. });
  7356. return support;
  7357. }
  7358. }]);
  7359. return Clipboard;
  7360. }(_tinyEmitter2.default);
  7361. /**
  7362. * Helper function to retrieve attribute value.
  7363. * @param {String} suffix
  7364. * @param {Element} element
  7365. */
  7366. function getAttributeValue(suffix, element) {
  7367. var attribute = 'data-clipboard-' + suffix;
  7368. if (!element.hasAttribute(attribute)) {
  7369. return;
  7370. }
  7371. return element.getAttribute(attribute);
  7372. }
  7373. module.exports = Clipboard;
  7374. /***/ }),
  7375. /* 1 */
  7376. /***/ (function(module, exports, __webpack_require__) {
  7377. "use strict";
  7378. 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; };
  7379. 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; }; }();
  7380. var _select = __webpack_require__(2);
  7381. var _select2 = _interopRequireDefault(_select);
  7382. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7383. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7384. /**
  7385. * Inner class which performs selection from either `text` or `target`
  7386. * properties and then executes copy or cut operations.
  7387. */
  7388. var ClipboardAction = function () {
  7389. /**
  7390. * @param {Object} options
  7391. */
  7392. function ClipboardAction(options) {
  7393. _classCallCheck(this, ClipboardAction);
  7394. this.resolveOptions(options);
  7395. this.initSelection();
  7396. }
  7397. /**
  7398. * Defines base properties passed from constructor.
  7399. * @param {Object} options
  7400. */
  7401. _createClass(ClipboardAction, [{
  7402. key: 'resolveOptions',
  7403. value: function resolveOptions() {
  7404. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  7405. this.action = options.action;
  7406. this.container = options.container;
  7407. this.emitter = options.emitter;
  7408. this.target = options.target;
  7409. this.text = options.text;
  7410. this.trigger = options.trigger;
  7411. this.selectedText = '';
  7412. }
  7413. /**
  7414. * Decides which selection strategy is going to be applied based
  7415. * on the existence of `text` and `target` properties.
  7416. */
  7417. }, {
  7418. key: 'initSelection',
  7419. value: function initSelection() {
  7420. if (this.text) {
  7421. this.selectFake();
  7422. } else if (this.target) {
  7423. this.selectTarget();
  7424. }
  7425. }
  7426. /**
  7427. * Creates a fake textarea element, sets its value from `text` property,
  7428. * and makes a selection on it.
  7429. */
  7430. }, {
  7431. key: 'selectFake',
  7432. value: function selectFake() {
  7433. var _this = this;
  7434. var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
  7435. this.removeFake();
  7436. this.fakeHandlerCallback = function () {
  7437. return _this.removeFake();
  7438. };
  7439. this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;
  7440. this.fakeElem = document.createElement('textarea');
  7441. // Prevent zooming on iOS
  7442. this.fakeElem.style.fontSize = '12pt';
  7443. // Reset box model
  7444. this.fakeElem.style.border = '0';
  7445. this.fakeElem.style.padding = '0';
  7446. this.fakeElem.style.margin = '0';
  7447. // Move element out of screen horizontally
  7448. this.fakeElem.style.position = 'absolute';
  7449. this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
  7450. // Move element to the same position vertically
  7451. var yPosition = window.pageYOffset || document.documentElement.scrollTop;
  7452. this.fakeElem.style.top = yPosition + 'px';
  7453. this.fakeElem.setAttribute('readonly', '');
  7454. this.fakeElem.value = this.text;
  7455. this.container.appendChild(this.fakeElem);
  7456. this.selectedText = (0, _select2.default)(this.fakeElem);
  7457. this.copyText();
  7458. }
  7459. /**
  7460. * Only removes the fake element after another click event, that way
  7461. * a user can hit `Ctrl+C` to copy because selection still exists.
  7462. */
  7463. }, {
  7464. key: 'removeFake',
  7465. value: function removeFake() {
  7466. if (this.fakeHandler) {
  7467. this.container.removeEventListener('click', this.fakeHandlerCallback);
  7468. this.fakeHandler = null;
  7469. this.fakeHandlerCallback = null;
  7470. }
  7471. if (this.fakeElem) {
  7472. this.container.removeChild(this.fakeElem);
  7473. this.fakeElem = null;
  7474. }
  7475. }
  7476. /**
  7477. * Selects the content from element passed on `target` property.
  7478. */
  7479. }, {
  7480. key: 'selectTarget',
  7481. value: function selectTarget() {
  7482. this.selectedText = (0, _select2.default)(this.target);
  7483. this.copyText();
  7484. }
  7485. /**
  7486. * Executes the copy operation based on the current selection.
  7487. */
  7488. }, {
  7489. key: 'copyText',
  7490. value: function copyText() {
  7491. var succeeded = void 0;
  7492. try {
  7493. succeeded = document.execCommand(this.action);
  7494. } catch (err) {
  7495. succeeded = false;
  7496. }
  7497. this.handleResult(succeeded);
  7498. }
  7499. /**
  7500. * Fires an event based on the copy operation result.
  7501. * @param {Boolean} succeeded
  7502. */
  7503. }, {
  7504. key: 'handleResult',
  7505. value: function handleResult(succeeded) {
  7506. this.emitter.emit(succeeded ? 'success' : 'error', {
  7507. action: this.action,
  7508. text: this.selectedText,
  7509. trigger: this.trigger,
  7510. clearSelection: this.clearSelection.bind(this)
  7511. });
  7512. }
  7513. /**
  7514. * Moves focus away from `target` and back to the trigger, removes current selection.
  7515. */
  7516. }, {
  7517. key: 'clearSelection',
  7518. value: function clearSelection() {
  7519. if (this.trigger) {
  7520. this.trigger.focus();
  7521. }
  7522. window.getSelection().removeAllRanges();
  7523. }
  7524. /**
  7525. * Sets the `action` to be performed which can be either 'copy' or 'cut'.
  7526. * @param {String} action
  7527. */
  7528. }, {
  7529. key: 'destroy',
  7530. /**
  7531. * Destroy lifecycle.
  7532. */
  7533. value: function destroy() {
  7534. this.removeFake();
  7535. }
  7536. }, {
  7537. key: 'action',
  7538. set: function set() {
  7539. var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
  7540. this._action = action;
  7541. if (this._action !== 'copy' && this._action !== 'cut') {
  7542. throw new Error('Invalid "action" value, use either "copy" or "cut"');
  7543. }
  7544. }
  7545. /**
  7546. * Gets the `action` property.
  7547. * @return {String}
  7548. */
  7549. ,
  7550. get: function get() {
  7551. return this._action;
  7552. }
  7553. /**
  7554. * Sets the `target` property using an element
  7555. * that will be have its content copied.
  7556. * @param {Element} target
  7557. */
  7558. }, {
  7559. key: 'target',
  7560. set: function set(target) {
  7561. if (target !== undefined) {
  7562. if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {
  7563. if (this.action === 'copy' && target.hasAttribute('disabled')) {
  7564. throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
  7565. }
  7566. if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
  7567. throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
  7568. }
  7569. this._target = target;
  7570. } else {
  7571. throw new Error('Invalid "target" value, use a valid Element');
  7572. }
  7573. }
  7574. }
  7575. /**
  7576. * Gets the `target` property.
  7577. * @return {String|HTMLElement}
  7578. */
  7579. ,
  7580. get: function get() {
  7581. return this._target;
  7582. }
  7583. }]);
  7584. return ClipboardAction;
  7585. }();
  7586. module.exports = ClipboardAction;
  7587. /***/ }),
  7588. /* 2 */
  7589. /***/ (function(module, exports) {
  7590. function select(element) {
  7591. var selectedText;
  7592. if (element.nodeName === 'SELECT') {
  7593. element.focus();
  7594. selectedText = element.value;
  7595. }
  7596. else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
  7597. var isReadOnly = element.hasAttribute('readonly');
  7598. if (!isReadOnly) {
  7599. element.setAttribute('readonly', '');
  7600. }
  7601. element.select();
  7602. element.setSelectionRange(0, element.value.length);
  7603. if (!isReadOnly) {
  7604. element.removeAttribute('readonly');
  7605. }
  7606. selectedText = element.value;
  7607. }
  7608. else {
  7609. if (element.hasAttribute('contenteditable')) {
  7610. element.focus();
  7611. }
  7612. var selection = window.getSelection();
  7613. var range = document.createRange();
  7614. range.selectNodeContents(element);
  7615. selection.removeAllRanges();
  7616. selection.addRange(range);
  7617. selectedText = selection.toString();
  7618. }
  7619. return selectedText;
  7620. }
  7621. module.exports = select;
  7622. /***/ }),
  7623. /* 3 */
  7624. /***/ (function(module, exports) {
  7625. function E () {
  7626. // Keep this empty so it's easier to inherit from
  7627. // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
  7628. }
  7629. E.prototype = {
  7630. on: function (name, callback, ctx) {
  7631. var e = this.e || (this.e = {});
  7632. (e[name] || (e[name] = [])).push({
  7633. fn: callback,
  7634. ctx: ctx
  7635. });
  7636. return this;
  7637. },
  7638. once: function (name, callback, ctx) {
  7639. var self = this;
  7640. function listener () {
  7641. self.off(name, listener);
  7642. callback.apply(ctx, arguments);
  7643. };
  7644. listener._ = callback
  7645. return this.on(name, listener, ctx);
  7646. },
  7647. emit: function (name) {
  7648. var data = [].slice.call(arguments, 1);
  7649. var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
  7650. var i = 0;
  7651. var len = evtArr.length;
  7652. for (i; i < len; i++) {
  7653. evtArr[i].fn.apply(evtArr[i].ctx, data);
  7654. }
  7655. return this;
  7656. },
  7657. off: function (name, callback) {
  7658. var e = this.e || (this.e = {});
  7659. var evts = e[name];
  7660. var liveEvents = [];
  7661. if (evts && callback) {
  7662. for (var i = 0, len = evts.length; i < len; i++) {
  7663. if (evts[i].fn !== callback && evts[i].fn._ !== callback)
  7664. liveEvents.push(evts[i]);
  7665. }
  7666. }
  7667. // Remove event from queue to prevent memory leak
  7668. // Suggested by https://github.com/lazd
  7669. // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
  7670. (liveEvents.length)
  7671. ? e[name] = liveEvents
  7672. : delete e[name];
  7673. return this;
  7674. }
  7675. };
  7676. module.exports = E;
  7677. /***/ }),
  7678. /* 4 */
  7679. /***/ (function(module, exports, __webpack_require__) {
  7680. var is = __webpack_require__(5);
  7681. var delegate = __webpack_require__(6);
  7682. /**
  7683. * Validates all params and calls the right
  7684. * listener function based on its target type.
  7685. *
  7686. * @param {String|HTMLElement|HTMLCollection|NodeList} target
  7687. * @param {String} type
  7688. * @param {Function} callback
  7689. * @return {Object}
  7690. */
  7691. function listen(target, type, callback) {
  7692. if (!target && !type && !callback) {
  7693. throw new Error('Missing required arguments');
  7694. }
  7695. if (!is.string(type)) {
  7696. throw new TypeError('Second argument must be a String');
  7697. }
  7698. if (!is.fn(callback)) {
  7699. throw new TypeError('Third argument must be a Function');
  7700. }
  7701. if (is.node(target)) {
  7702. return listenNode(target, type, callback);
  7703. }
  7704. else if (is.nodeList(target)) {
  7705. return listenNodeList(target, type, callback);
  7706. }
  7707. else if (is.string(target)) {
  7708. return listenSelector(target, type, callback);
  7709. }
  7710. else {
  7711. throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
  7712. }
  7713. }
  7714. /**
  7715. * Adds an event listener to a HTML element
  7716. * and returns a remove listener function.
  7717. *
  7718. * @param {HTMLElement} node
  7719. * @param {String} type
  7720. * @param {Function} callback
  7721. * @return {Object}
  7722. */
  7723. function listenNode(node, type, callback) {
  7724. node.addEventListener(type, callback);
  7725. return {
  7726. destroy: function() {
  7727. node.removeEventListener(type, callback);
  7728. }
  7729. }
  7730. }
  7731. /**
  7732. * Add an event listener to a list of HTML elements
  7733. * and returns a remove listener function.
  7734. *
  7735. * @param {NodeList|HTMLCollection} nodeList
  7736. * @param {String} type
  7737. * @param {Function} callback
  7738. * @return {Object}
  7739. */
  7740. function listenNodeList(nodeList, type, callback) {
  7741. Array.prototype.forEach.call(nodeList, function(node) {
  7742. node.addEventListener(type, callback);
  7743. });
  7744. return {
  7745. destroy: function() {
  7746. Array.prototype.forEach.call(nodeList, function(node) {
  7747. node.removeEventListener(type, callback);
  7748. });
  7749. }
  7750. }
  7751. }
  7752. /**
  7753. * Add an event listener to a selector
  7754. * and returns a remove listener function.
  7755. *
  7756. * @param {String} selector
  7757. * @param {String} type
  7758. * @param {Function} callback
  7759. * @return {Object}
  7760. */
  7761. function listenSelector(selector, type, callback) {
  7762. return delegate(document.body, selector, type, callback);
  7763. }
  7764. module.exports = listen;
  7765. /***/ }),
  7766. /* 5 */
  7767. /***/ (function(module, exports) {
  7768. /**
  7769. * Check if argument is a HTML element.
  7770. *
  7771. * @param {Object} value
  7772. * @return {Boolean}
  7773. */
  7774. exports.node = function(value) {
  7775. return value !== undefined
  7776. && value instanceof HTMLElement
  7777. && value.nodeType === 1;
  7778. };
  7779. /**
  7780. * Check if argument is a list of HTML elements.
  7781. *
  7782. * @param {Object} value
  7783. * @return {Boolean}
  7784. */
  7785. exports.nodeList = function(value) {
  7786. var type = Object.prototype.toString.call(value);
  7787. return value !== undefined
  7788. && (type === '[object NodeList]' || type === '[object HTMLCollection]')
  7789. && ('length' in value)
  7790. && (value.length === 0 || exports.node(value[0]));
  7791. };
  7792. /**
  7793. * Check if argument is a string.
  7794. *
  7795. * @param {Object} value
  7796. * @return {Boolean}
  7797. */
  7798. exports.string = function(value) {
  7799. return typeof value === 'string'
  7800. || value instanceof String;
  7801. };
  7802. /**
  7803. * Check if argument is a function.
  7804. *
  7805. * @param {Object} value
  7806. * @return {Boolean}
  7807. */
  7808. exports.fn = function(value) {
  7809. var type = Object.prototype.toString.call(value);
  7810. return type === '[object Function]';
  7811. };
  7812. /***/ }),
  7813. /* 6 */
  7814. /***/ (function(module, exports, __webpack_require__) {
  7815. var closest = __webpack_require__(7);
  7816. /**
  7817. * Delegates event to a selector.
  7818. *
  7819. * @param {Element} element
  7820. * @param {String} selector
  7821. * @param {String} type
  7822. * @param {Function} callback
  7823. * @param {Boolean} useCapture
  7824. * @return {Object}
  7825. */
  7826. function _delegate(element, selector, type, callback, useCapture) {
  7827. var listenerFn = listener.apply(this, arguments);
  7828. element.addEventListener(type, listenerFn, useCapture);
  7829. return {
  7830. destroy: function() {
  7831. element.removeEventListener(type, listenerFn, useCapture);
  7832. }
  7833. }
  7834. }
  7835. /**
  7836. * Delegates event to a selector.
  7837. *
  7838. * @param {Element|String|Array} [elements]
  7839. * @param {String} selector
  7840. * @param {String} type
  7841. * @param {Function} callback
  7842. * @param {Boolean} useCapture
  7843. * @return {Object}
  7844. */
  7845. function delegate(elements, selector, type, callback, useCapture) {
  7846. // Handle the regular Element usage
  7847. if (typeof elements.addEventListener === 'function') {
  7848. return _delegate.apply(null, arguments);
  7849. }
  7850. // Handle Element-less usage, it defaults to global delegation
  7851. if (typeof type === 'function') {
  7852. // Use `document` as the first parameter, then apply arguments
  7853. // This is a short way to .unshift `arguments` without running into deoptimizations
  7854. return _delegate.bind(null, document).apply(null, arguments);
  7855. }
  7856. // Handle Selector-based usage
  7857. if (typeof elements === 'string') {
  7858. elements = document.querySelectorAll(elements);
  7859. }
  7860. // Handle Array-like based usage
  7861. return Array.prototype.map.call(elements, function (element) {
  7862. return _delegate(element, selector, type, callback, useCapture);
  7863. });
  7864. }
  7865. /**
  7866. * Finds closest match and invokes callback.
  7867. *
  7868. * @param {Element} element
  7869. * @param {String} selector
  7870. * @param {String} type
  7871. * @param {Function} callback
  7872. * @return {Function}
  7873. */
  7874. function listener(element, selector, type, callback) {
  7875. return function(e) {
  7876. e.delegateTarget = closest(e.target, selector);
  7877. if (e.delegateTarget) {
  7878. callback.call(element, e);
  7879. }
  7880. }
  7881. }
  7882. module.exports = delegate;
  7883. /***/ }),
  7884. /* 7 */
  7885. /***/ (function(module, exports) {
  7886. var DOCUMENT_NODE_TYPE = 9;
  7887. /**
  7888. * A polyfill for Element.matches()
  7889. */
  7890. if (typeof Element !== 'undefined' && !Element.prototype.matches) {
  7891. var proto = Element.prototype;
  7892. proto.matches = proto.matchesSelector ||
  7893. proto.mozMatchesSelector ||
  7894. proto.msMatchesSelector ||
  7895. proto.oMatchesSelector ||
  7896. proto.webkitMatchesSelector;
  7897. }
  7898. /**
  7899. * Finds the closest parent that matches a selector.
  7900. *
  7901. * @param {Element} element
  7902. * @param {String} selector
  7903. * @return {Function}
  7904. */
  7905. function closest (element, selector) {
  7906. while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
  7907. if (typeof element.matches === 'function' &&
  7908. element.matches(selector)) {
  7909. return element;
  7910. }
  7911. element = element.parentNode;
  7912. }
  7913. }
  7914. module.exports = closest;
  7915. /***/ })
  7916. /******/ ]);
  7917. });
  7918. /***/ }),
  7919. /***/ "./node_modules/ieee754/index.js":
  7920. /*!***************************************!*\
  7921. !*** ./node_modules/ieee754/index.js ***!
  7922. \***************************************/
  7923. /*! no static exports found */
  7924. /***/ (function(module, exports) {
  7925. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  7926. var e, m
  7927. var eLen = (nBytes * 8) - mLen - 1
  7928. var eMax = (1 << eLen) - 1
  7929. var eBias = eMax >> 1
  7930. var nBits = -7
  7931. var i = isLE ? (nBytes - 1) : 0
  7932. var d = isLE ? -1 : 1
  7933. var s = buffer[offset + i]
  7934. i += d
  7935. e = s & ((1 << (-nBits)) - 1)
  7936. s >>= (-nBits)
  7937. nBits += eLen
  7938. for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7939. m = e & ((1 << (-nBits)) - 1)
  7940. e >>= (-nBits)
  7941. nBits += mLen
  7942. for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
  7943. if (e === 0) {
  7944. e = 1 - eBias
  7945. } else if (e === eMax) {
  7946. return m ? NaN : ((s ? -1 : 1) * Infinity)
  7947. } else {
  7948. m = m + Math.pow(2, mLen)
  7949. e = e - eBias
  7950. }
  7951. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  7952. }
  7953. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  7954. var e, m, c
  7955. var eLen = (nBytes * 8) - mLen - 1
  7956. var eMax = (1 << eLen) - 1
  7957. var eBias = eMax >> 1
  7958. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  7959. var i = isLE ? 0 : (nBytes - 1)
  7960. var d = isLE ? 1 : -1
  7961. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  7962. value = Math.abs(value)
  7963. if (isNaN(value) || value === Infinity) {
  7964. m = isNaN(value) ? 1 : 0
  7965. e = eMax
  7966. } else {
  7967. e = Math.floor(Math.log(value) / Math.LN2)
  7968. if (value * (c = Math.pow(2, -e)) < 1) {
  7969. e--
  7970. c *= 2
  7971. }
  7972. if (e + eBias >= 1) {
  7973. value += rt / c
  7974. } else {
  7975. value += rt * Math.pow(2, 1 - eBias)
  7976. }
  7977. if (value * c >= 2) {
  7978. e++
  7979. c /= 2
  7980. }
  7981. if (e + eBias >= eMax) {
  7982. m = 0
  7983. e = eMax
  7984. } else if (e + eBias >= 1) {
  7985. m = ((value * c) - 1) * Math.pow(2, mLen)
  7986. e = e + eBias
  7987. } else {
  7988. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  7989. e = 0
  7990. }
  7991. }
  7992. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  7993. e = (e << mLen) | m
  7994. eLen += mLen
  7995. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  7996. buffer[offset + i - d] |= s * 128
  7997. }
  7998. /***/ }),
  7999. /***/ "./node_modules/isarray/index.js":
  8000. /*!***************************************!*\
  8001. !*** ./node_modules/isarray/index.js ***!
  8002. \***************************************/
  8003. /*! no static exports found */
  8004. /***/ (function(module, exports) {
  8005. var toString = {}.toString;
  8006. module.exports = Array.isArray || function (arr) {
  8007. return toString.call(arr) == '[object Array]';
  8008. };
  8009. /***/ }),
  8010. /***/ "./node_modules/jquery/dist/jquery.js":
  8011. /*!********************************************!*\
  8012. !*** ./node_modules/jquery/dist/jquery.js ***!
  8013. \********************************************/
  8014. /*! no static exports found */
  8015. /***/ (function(module, exports, __webpack_require__) {
  8016. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  8017. * jQuery JavaScript Library v3.4.1
  8018. * https://jquery.com/
  8019. *
  8020. * Includes Sizzle.js
  8021. * https://sizzlejs.com/
  8022. *
  8023. * Copyright JS Foundation and other contributors
  8024. * Released under the MIT license
  8025. * https://jquery.org/license
  8026. *
  8027. * Date: 2019-05-01T21:04Z
  8028. */
  8029. ( function( global, factory ) {
  8030. "use strict";
  8031. if ( true && typeof module.exports === "object" ) {
  8032. // For CommonJS and CommonJS-like environments where a proper `window`
  8033. // is present, execute the factory and get jQuery.
  8034. // For environments that do not have a `window` with a `document`
  8035. // (such as Node.js), expose a factory as module.exports.
  8036. // This accentuates the need for the creation of a real `window`.
  8037. // e.g. var jQuery = require("jquery")(window);
  8038. // See ticket #14549 for more info.
  8039. module.exports = global.document ?
  8040. factory( global, true ) :
  8041. function( w ) {
  8042. if ( !w.document ) {
  8043. throw new Error( "jQuery requires a window with a document" );
  8044. }
  8045. return factory( w );
  8046. };
  8047. } else {
  8048. factory( global );
  8049. }
  8050. // Pass this if window is not defined yet
  8051. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  8052. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  8053. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  8054. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  8055. // enough that all such attempts are guarded in a try block.
  8056. "use strict";
  8057. var arr = [];
  8058. var document = window.document;
  8059. var getProto = Object.getPrototypeOf;
  8060. var slice = arr.slice;
  8061. var concat = arr.concat;
  8062. var push = arr.push;
  8063. var indexOf = arr.indexOf;
  8064. var class2type = {};
  8065. var toString = class2type.toString;
  8066. var hasOwn = class2type.hasOwnProperty;
  8067. var fnToString = hasOwn.toString;
  8068. var ObjectFunctionString = fnToString.call( Object );
  8069. var support = {};
  8070. var isFunction = function isFunction( obj ) {
  8071. // Support: Chrome <=57, Firefox <=52
  8072. // In some browsers, typeof returns "function" for HTML <object> elements
  8073. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  8074. // We don't want to classify *any* DOM node as a function.
  8075. return typeof obj === "function" && typeof obj.nodeType !== "number";
  8076. };
  8077. var isWindow = function isWindow( obj ) {
  8078. return obj != null && obj === obj.window;
  8079. };
  8080. var preservedScriptAttributes = {
  8081. type: true,
  8082. src: true,
  8083. nonce: true,
  8084. noModule: true
  8085. };
  8086. function DOMEval( code, node, doc ) {
  8087. doc = doc || document;
  8088. var i, val,
  8089. script = doc.createElement( "script" );
  8090. script.text = code;
  8091. if ( node ) {
  8092. for ( i in preservedScriptAttributes ) {
  8093. // Support: Firefox 64+, Edge 18+
  8094. // Some browsers don't support the "nonce" property on scripts.
  8095. // On the other hand, just using `getAttribute` is not enough as
  8096. // the `nonce` attribute is reset to an empty string whenever it
  8097. // becomes browsing-context connected.
  8098. // See https://github.com/whatwg/html/issues/2369
  8099. // See https://html.spec.whatwg.org/#nonce-attributes
  8100. // The `node.getAttribute` check was added for the sake of
  8101. // `jQuery.globalEval` so that it can fake a nonce-containing node
  8102. // via an object.
  8103. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  8104. if ( val ) {
  8105. script.setAttribute( i, val );
  8106. }
  8107. }
  8108. }
  8109. doc.head.appendChild( script ).parentNode.removeChild( script );
  8110. }
  8111. function toType( obj ) {
  8112. if ( obj == null ) {
  8113. return obj + "";
  8114. }
  8115. // Support: Android <=2.3 only (functionish RegExp)
  8116. return typeof obj === "object" || typeof obj === "function" ?
  8117. class2type[ toString.call( obj ) ] || "object" :
  8118. typeof obj;
  8119. }
  8120. /* global Symbol */
  8121. // Defining this global in .eslintrc.json would create a danger of using the global
  8122. // unguarded in another place, it seems safer to define global only for this module
  8123. var
  8124. version = "3.4.1",
  8125. // Define a local copy of jQuery
  8126. jQuery = function( selector, context ) {
  8127. // The jQuery object is actually just the init constructor 'enhanced'
  8128. // Need init if jQuery is called (just allow error to be thrown if not included)
  8129. return new jQuery.fn.init( selector, context );
  8130. },
  8131. // Support: Android <=4.0 only
  8132. // Make sure we trim BOM and NBSP
  8133. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  8134. jQuery.fn = jQuery.prototype = {
  8135. // The current version of jQuery being used
  8136. jquery: version,
  8137. constructor: jQuery,
  8138. // The default length of a jQuery object is 0
  8139. length: 0,
  8140. toArray: function() {
  8141. return slice.call( this );
  8142. },
  8143. // Get the Nth element in the matched element set OR
  8144. // Get the whole matched element set as a clean array
  8145. get: function( num ) {
  8146. // Return all the elements in a clean array
  8147. if ( num == null ) {
  8148. return slice.call( this );
  8149. }
  8150. // Return just the one element from the set
  8151. return num < 0 ? this[ num + this.length ] : this[ num ];
  8152. },
  8153. // Take an array of elements and push it onto the stack
  8154. // (returning the new matched element set)
  8155. pushStack: function( elems ) {
  8156. // Build a new jQuery matched element set
  8157. var ret = jQuery.merge( this.constructor(), elems );
  8158. // Add the old object onto the stack (as a reference)
  8159. ret.prevObject = this;
  8160. // Return the newly-formed element set
  8161. return ret;
  8162. },
  8163. // Execute a callback for every element in the matched set.
  8164. each: function( callback ) {
  8165. return jQuery.each( this, callback );
  8166. },
  8167. map: function( callback ) {
  8168. return this.pushStack( jQuery.map( this, function( elem, i ) {
  8169. return callback.call( elem, i, elem );
  8170. } ) );
  8171. },
  8172. slice: function() {
  8173. return this.pushStack( slice.apply( this, arguments ) );
  8174. },
  8175. first: function() {
  8176. return this.eq( 0 );
  8177. },
  8178. last: function() {
  8179. return this.eq( -1 );
  8180. },
  8181. eq: function( i ) {
  8182. var len = this.length,
  8183. j = +i + ( i < 0 ? len : 0 );
  8184. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  8185. },
  8186. end: function() {
  8187. return this.prevObject || this.constructor();
  8188. },
  8189. // For internal use only.
  8190. // Behaves like an Array's method, not like a jQuery method.
  8191. push: push,
  8192. sort: arr.sort,
  8193. splice: arr.splice
  8194. };
  8195. jQuery.extend = jQuery.fn.extend = function() {
  8196. var options, name, src, copy, copyIsArray, clone,
  8197. target = arguments[ 0 ] || {},
  8198. i = 1,
  8199. length = arguments.length,
  8200. deep = false;
  8201. // Handle a deep copy situation
  8202. if ( typeof target === "boolean" ) {
  8203. deep = target;
  8204. // Skip the boolean and the target
  8205. target = arguments[ i ] || {};
  8206. i++;
  8207. }
  8208. // Handle case when target is a string or something (possible in deep copy)
  8209. if ( typeof target !== "object" && !isFunction( target ) ) {
  8210. target = {};
  8211. }
  8212. // Extend jQuery itself if only one argument is passed
  8213. if ( i === length ) {
  8214. target = this;
  8215. i--;
  8216. }
  8217. for ( ; i < length; i++ ) {
  8218. // Only deal with non-null/undefined values
  8219. if ( ( options = arguments[ i ] ) != null ) {
  8220. // Extend the base object
  8221. for ( name in options ) {
  8222. copy = options[ name ];
  8223. // Prevent Object.prototype pollution
  8224. // Prevent never-ending loop
  8225. if ( name === "__proto__" || target === copy ) {
  8226. continue;
  8227. }
  8228. // Recurse if we're merging plain objects or arrays
  8229. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  8230. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  8231. src = target[ name ];
  8232. // Ensure proper type for the source value
  8233. if ( copyIsArray && !Array.isArray( src ) ) {
  8234. clone = [];
  8235. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  8236. clone = {};
  8237. } else {
  8238. clone = src;
  8239. }
  8240. copyIsArray = false;
  8241. // Never move original objects, clone them
  8242. target[ name ] = jQuery.extend( deep, clone, copy );
  8243. // Don't bring in undefined values
  8244. } else if ( copy !== undefined ) {
  8245. target[ name ] = copy;
  8246. }
  8247. }
  8248. }
  8249. }
  8250. // Return the modified object
  8251. return target;
  8252. };
  8253. jQuery.extend( {
  8254. // Unique for each copy of jQuery on the page
  8255. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  8256. // Assume jQuery is ready without the ready module
  8257. isReady: true,
  8258. error: function( msg ) {
  8259. throw new Error( msg );
  8260. },
  8261. noop: function() {},
  8262. isPlainObject: function( obj ) {
  8263. var proto, Ctor;
  8264. // Detect obvious negatives
  8265. // Use toString instead of jQuery.type to catch host objects
  8266. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  8267. return false;
  8268. }
  8269. proto = getProto( obj );
  8270. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  8271. if ( !proto ) {
  8272. return true;
  8273. }
  8274. // Objects with prototype are plain iff they were constructed by a global Object function
  8275. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  8276. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  8277. },
  8278. isEmptyObject: function( obj ) {
  8279. var name;
  8280. for ( name in obj ) {
  8281. return false;
  8282. }
  8283. return true;
  8284. },
  8285. // Evaluates a script in a global context
  8286. globalEval: function( code, options ) {
  8287. DOMEval( code, { nonce: options && options.nonce } );
  8288. },
  8289. each: function( obj, callback ) {
  8290. var length, i = 0;
  8291. if ( isArrayLike( obj ) ) {
  8292. length = obj.length;
  8293. for ( ; i < length; i++ ) {
  8294. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  8295. break;
  8296. }
  8297. }
  8298. } else {
  8299. for ( i in obj ) {
  8300. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  8301. break;
  8302. }
  8303. }
  8304. }
  8305. return obj;
  8306. },
  8307. // Support: Android <=4.0 only
  8308. trim: function( text ) {
  8309. return text == null ?
  8310. "" :
  8311. ( text + "" ).replace( rtrim, "" );
  8312. },
  8313. // results is for internal usage only
  8314. makeArray: function( arr, results ) {
  8315. var ret = results || [];
  8316. if ( arr != null ) {
  8317. if ( isArrayLike( Object( arr ) ) ) {
  8318. jQuery.merge( ret,
  8319. typeof arr === "string" ?
  8320. [ arr ] : arr
  8321. );
  8322. } else {
  8323. push.call( ret, arr );
  8324. }
  8325. }
  8326. return ret;
  8327. },
  8328. inArray: function( elem, arr, i ) {
  8329. return arr == null ? -1 : indexOf.call( arr, elem, i );
  8330. },
  8331. // Support: Android <=4.0 only, PhantomJS 1 only
  8332. // push.apply(_, arraylike) throws on ancient WebKit
  8333. merge: function( first, second ) {
  8334. var len = +second.length,
  8335. j = 0,
  8336. i = first.length;
  8337. for ( ; j < len; j++ ) {
  8338. first[ i++ ] = second[ j ];
  8339. }
  8340. first.length = i;
  8341. return first;
  8342. },
  8343. grep: function( elems, callback, invert ) {
  8344. var callbackInverse,
  8345. matches = [],
  8346. i = 0,
  8347. length = elems.length,
  8348. callbackExpect = !invert;
  8349. // Go through the array, only saving the items
  8350. // that pass the validator function
  8351. for ( ; i < length; i++ ) {
  8352. callbackInverse = !callback( elems[ i ], i );
  8353. if ( callbackInverse !== callbackExpect ) {
  8354. matches.push( elems[ i ] );
  8355. }
  8356. }
  8357. return matches;
  8358. },
  8359. // arg is for internal usage only
  8360. map: function( elems, callback, arg ) {
  8361. var length, value,
  8362. i = 0,
  8363. ret = [];
  8364. // Go through the array, translating each of the items to their new values
  8365. if ( isArrayLike( elems ) ) {
  8366. length = elems.length;
  8367. for ( ; i < length; i++ ) {
  8368. value = callback( elems[ i ], i, arg );
  8369. if ( value != null ) {
  8370. ret.push( value );
  8371. }
  8372. }
  8373. // Go through every key on the object,
  8374. } else {
  8375. for ( i in elems ) {
  8376. value = callback( elems[ i ], i, arg );
  8377. if ( value != null ) {
  8378. ret.push( value );
  8379. }
  8380. }
  8381. }
  8382. // Flatten any nested arrays
  8383. return concat.apply( [], ret );
  8384. },
  8385. // A global GUID counter for objects
  8386. guid: 1,
  8387. // jQuery.support is not used in Core but other projects attach their
  8388. // properties to it so it needs to exist.
  8389. support: support
  8390. } );
  8391. if ( typeof Symbol === "function" ) {
  8392. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  8393. }
  8394. // Populate the class2type map
  8395. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  8396. function( i, name ) {
  8397. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  8398. } );
  8399. function isArrayLike( obj ) {
  8400. // Support: real iOS 8.2 only (not reproducible in simulator)
  8401. // `in` check used to prevent JIT error (gh-2145)
  8402. // hasOwn isn't used here due to false negatives
  8403. // regarding Nodelist length in IE
  8404. var length = !!obj && "length" in obj && obj.length,
  8405. type = toType( obj );
  8406. if ( isFunction( obj ) || isWindow( obj ) ) {
  8407. return false;
  8408. }
  8409. return type === "array" || length === 0 ||
  8410. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  8411. }
  8412. var Sizzle =
  8413. /*!
  8414. * Sizzle CSS Selector Engine v2.3.4
  8415. * https://sizzlejs.com/
  8416. *
  8417. * Copyright JS Foundation and other contributors
  8418. * Released under the MIT license
  8419. * https://js.foundation/
  8420. *
  8421. * Date: 2019-04-08
  8422. */
  8423. (function( window ) {
  8424. var i,
  8425. support,
  8426. Expr,
  8427. getText,
  8428. isXML,
  8429. tokenize,
  8430. compile,
  8431. select,
  8432. outermostContext,
  8433. sortInput,
  8434. hasDuplicate,
  8435. // Local document vars
  8436. setDocument,
  8437. document,
  8438. docElem,
  8439. documentIsHTML,
  8440. rbuggyQSA,
  8441. rbuggyMatches,
  8442. matches,
  8443. contains,
  8444. // Instance-specific data
  8445. expando = "sizzle" + 1 * new Date(),
  8446. preferredDoc = window.document,
  8447. dirruns = 0,
  8448. done = 0,
  8449. classCache = createCache(),
  8450. tokenCache = createCache(),
  8451. compilerCache = createCache(),
  8452. nonnativeSelectorCache = createCache(),
  8453. sortOrder = function( a, b ) {
  8454. if ( a === b ) {
  8455. hasDuplicate = true;
  8456. }
  8457. return 0;
  8458. },
  8459. // Instance methods
  8460. hasOwn = ({}).hasOwnProperty,
  8461. arr = [],
  8462. pop = arr.pop,
  8463. push_native = arr.push,
  8464. push = arr.push,
  8465. slice = arr.slice,
  8466. // Use a stripped-down indexOf as it's faster than native
  8467. // https://jsperf.com/thor-indexof-vs-for/5
  8468. indexOf = function( list, elem ) {
  8469. var i = 0,
  8470. len = list.length;
  8471. for ( ; i < len; i++ ) {
  8472. if ( list[i] === elem ) {
  8473. return i;
  8474. }
  8475. }
  8476. return -1;
  8477. },
  8478. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  8479. // Regular expressions
  8480. // http://www.w3.org/TR/css3-selectors/#whitespace
  8481. whitespace = "[\\x20\\t\\r\\n\\f]",
  8482. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  8483. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  8484. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  8485. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  8486. // Operator (capture 2)
  8487. "*([*^$|!~]?=)" + whitespace +
  8488. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  8489. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  8490. "*\\]",
  8491. pseudos = ":(" + identifier + ")(?:\\((" +
  8492. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  8493. // 1. quoted (capture 3; capture 4 or capture 5)
  8494. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  8495. // 2. simple (capture 6)
  8496. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  8497. // 3. anything else (capture 2)
  8498. ".*" +
  8499. ")\\)|)",
  8500. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  8501. rwhitespace = new RegExp( whitespace + "+", "g" ),
  8502. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  8503. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  8504. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  8505. rdescend = new RegExp( whitespace + "|>" ),
  8506. rpseudo = new RegExp( pseudos ),
  8507. ridentifier = new RegExp( "^" + identifier + "$" ),
  8508. matchExpr = {
  8509. "ID": new RegExp( "^#(" + identifier + ")" ),
  8510. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  8511. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  8512. "ATTR": new RegExp( "^" + attributes ),
  8513. "PSEUDO": new RegExp( "^" + pseudos ),
  8514. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  8515. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  8516. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  8517. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  8518. // For use in libraries implementing .is()
  8519. // We use this for POS matching in `select`
  8520. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  8521. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  8522. },
  8523. rhtml = /HTML$/i,
  8524. rinputs = /^(?:input|select|textarea|button)$/i,
  8525. rheader = /^h\d$/i,
  8526. rnative = /^[^{]+\{\s*\[native \w/,
  8527. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  8528. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  8529. rsibling = /[+~]/,
  8530. // CSS escapes
  8531. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  8532. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  8533. funescape = function( _, escaped, escapedWhitespace ) {
  8534. var high = "0x" + escaped - 0x10000;
  8535. // NaN means non-codepoint
  8536. // Support: Firefox<24
  8537. // Workaround erroneous numeric interpretation of +"0x"
  8538. return high !== high || escapedWhitespace ?
  8539. escaped :
  8540. high < 0 ?
  8541. // BMP codepoint
  8542. String.fromCharCode( high + 0x10000 ) :
  8543. // Supplemental Plane codepoint (surrogate pair)
  8544. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  8545. },
  8546. // CSS string/identifier serialization
  8547. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  8548. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  8549. fcssescape = function( ch, asCodePoint ) {
  8550. if ( asCodePoint ) {
  8551. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  8552. if ( ch === "\0" ) {
  8553. return "\uFFFD";
  8554. }
  8555. // Control characters and (dependent upon position) numbers get escaped as code points
  8556. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  8557. }
  8558. // Other potentially-special ASCII characters get backslash-escaped
  8559. return "\\" + ch;
  8560. },
  8561. // Used for iframes
  8562. // See setDocument()
  8563. // Removing the function wrapper causes a "Permission Denied"
  8564. // error in IE
  8565. unloadHandler = function() {
  8566. setDocument();
  8567. },
  8568. inDisabledFieldset = addCombinator(
  8569. function( elem ) {
  8570. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  8571. },
  8572. { dir: "parentNode", next: "legend" }
  8573. );
  8574. // Optimize for push.apply( _, NodeList )
  8575. try {
  8576. push.apply(
  8577. (arr = slice.call( preferredDoc.childNodes )),
  8578. preferredDoc.childNodes
  8579. );
  8580. // Support: Android<4.0
  8581. // Detect silently failing push.apply
  8582. arr[ preferredDoc.childNodes.length ].nodeType;
  8583. } catch ( e ) {
  8584. push = { apply: arr.length ?
  8585. // Leverage slice if possible
  8586. function( target, els ) {
  8587. push_native.apply( target, slice.call(els) );
  8588. } :
  8589. // Support: IE<9
  8590. // Otherwise append directly
  8591. function( target, els ) {
  8592. var j = target.length,
  8593. i = 0;
  8594. // Can't trust NodeList.length
  8595. while ( (target[j++] = els[i++]) ) {}
  8596. target.length = j - 1;
  8597. }
  8598. };
  8599. }
  8600. function Sizzle( selector, context, results, seed ) {
  8601. var m, i, elem, nid, match, groups, newSelector,
  8602. newContext = context && context.ownerDocument,
  8603. // nodeType defaults to 9, since context defaults to document
  8604. nodeType = context ? context.nodeType : 9;
  8605. results = results || [];
  8606. // Return early from calls with invalid selector or context
  8607. if ( typeof selector !== "string" || !selector ||
  8608. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  8609. return results;
  8610. }
  8611. // Try to shortcut find operations (as opposed to filters) in HTML documents
  8612. if ( !seed ) {
  8613. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  8614. setDocument( context );
  8615. }
  8616. context = context || document;
  8617. if ( documentIsHTML ) {
  8618. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  8619. // (excepting DocumentFragment context, where the methods don't exist)
  8620. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  8621. // ID selector
  8622. if ( (m = match[1]) ) {
  8623. // Document context
  8624. if ( nodeType === 9 ) {
  8625. if ( (elem = context.getElementById( m )) ) {
  8626. // Support: IE, Opera, Webkit
  8627. // TODO: identify versions
  8628. // getElementById can match elements by name instead of ID
  8629. if ( elem.id === m ) {
  8630. results.push( elem );
  8631. return results;
  8632. }
  8633. } else {
  8634. return results;
  8635. }
  8636. // Element context
  8637. } else {
  8638. // Support: IE, Opera, Webkit
  8639. // TODO: identify versions
  8640. // getElementById can match elements by name instead of ID
  8641. if ( newContext && (elem = newContext.getElementById( m )) &&
  8642. contains( context, elem ) &&
  8643. elem.id === m ) {
  8644. results.push( elem );
  8645. return results;
  8646. }
  8647. }
  8648. // Type selector
  8649. } else if ( match[2] ) {
  8650. push.apply( results, context.getElementsByTagName( selector ) );
  8651. return results;
  8652. // Class selector
  8653. } else if ( (m = match[3]) && support.getElementsByClassName &&
  8654. context.getElementsByClassName ) {
  8655. push.apply( results, context.getElementsByClassName( m ) );
  8656. return results;
  8657. }
  8658. }
  8659. // Take advantage of querySelectorAll
  8660. if ( support.qsa &&
  8661. !nonnativeSelectorCache[ selector + " " ] &&
  8662. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  8663. // Support: IE 8 only
  8664. // Exclude object elements
  8665. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  8666. newSelector = selector;
  8667. newContext = context;
  8668. // qSA considers elements outside a scoping root when evaluating child or
  8669. // descendant combinators, which is not what we want.
  8670. // In such cases, we work around the behavior by prefixing every selector in the
  8671. // list with an ID selector referencing the scope context.
  8672. // Thanks to Andrew Dupont for this technique.
  8673. if ( nodeType === 1 && rdescend.test( selector ) ) {
  8674. // Capture the context ID, setting it first if necessary
  8675. if ( (nid = context.getAttribute( "id" )) ) {
  8676. nid = nid.replace( rcssescape, fcssescape );
  8677. } else {
  8678. context.setAttribute( "id", (nid = expando) );
  8679. }
  8680. // Prefix every selector in the list
  8681. groups = tokenize( selector );
  8682. i = groups.length;
  8683. while ( i-- ) {
  8684. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  8685. }
  8686. newSelector = groups.join( "," );
  8687. // Expand context for sibling selectors
  8688. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  8689. context;
  8690. }
  8691. try {
  8692. push.apply( results,
  8693. newContext.querySelectorAll( newSelector )
  8694. );
  8695. return results;
  8696. } catch ( qsaError ) {
  8697. nonnativeSelectorCache( selector, true );
  8698. } finally {
  8699. if ( nid === expando ) {
  8700. context.removeAttribute( "id" );
  8701. }
  8702. }
  8703. }
  8704. }
  8705. }
  8706. // All others
  8707. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  8708. }
  8709. /**
  8710. * Create key-value caches of limited size
  8711. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  8712. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  8713. * deleting the oldest entry
  8714. */
  8715. function createCache() {
  8716. var keys = [];
  8717. function cache( key, value ) {
  8718. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  8719. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  8720. // Only keep the most recent entries
  8721. delete cache[ keys.shift() ];
  8722. }
  8723. return (cache[ key + " " ] = value);
  8724. }
  8725. return cache;
  8726. }
  8727. /**
  8728. * Mark a function for special use by Sizzle
  8729. * @param {Function} fn The function to mark
  8730. */
  8731. function markFunction( fn ) {
  8732. fn[ expando ] = true;
  8733. return fn;
  8734. }
  8735. /**
  8736. * Support testing using an element
  8737. * @param {Function} fn Passed the created element and returns a boolean result
  8738. */
  8739. function assert( fn ) {
  8740. var el = document.createElement("fieldset");
  8741. try {
  8742. return !!fn( el );
  8743. } catch (e) {
  8744. return false;
  8745. } finally {
  8746. // Remove from its parent by default
  8747. if ( el.parentNode ) {
  8748. el.parentNode.removeChild( el );
  8749. }
  8750. // release memory in IE
  8751. el = null;
  8752. }
  8753. }
  8754. /**
  8755. * Adds the same handler for all of the specified attrs
  8756. * @param {String} attrs Pipe-separated list of attributes
  8757. * @param {Function} handler The method that will be applied
  8758. */
  8759. function addHandle( attrs, handler ) {
  8760. var arr = attrs.split("|"),
  8761. i = arr.length;
  8762. while ( i-- ) {
  8763. Expr.attrHandle[ arr[i] ] = handler;
  8764. }
  8765. }
  8766. /**
  8767. * Checks document order of two siblings
  8768. * @param {Element} a
  8769. * @param {Element} b
  8770. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  8771. */
  8772. function siblingCheck( a, b ) {
  8773. var cur = b && a,
  8774. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  8775. a.sourceIndex - b.sourceIndex;
  8776. // Use IE sourceIndex if available on both nodes
  8777. if ( diff ) {
  8778. return diff;
  8779. }
  8780. // Check if b follows a
  8781. if ( cur ) {
  8782. while ( (cur = cur.nextSibling) ) {
  8783. if ( cur === b ) {
  8784. return -1;
  8785. }
  8786. }
  8787. }
  8788. return a ? 1 : -1;
  8789. }
  8790. /**
  8791. * Returns a function to use in pseudos for input types
  8792. * @param {String} type
  8793. */
  8794. function createInputPseudo( type ) {
  8795. return function( elem ) {
  8796. var name = elem.nodeName.toLowerCase();
  8797. return name === "input" && elem.type === type;
  8798. };
  8799. }
  8800. /**
  8801. * Returns a function to use in pseudos for buttons
  8802. * @param {String} type
  8803. */
  8804. function createButtonPseudo( type ) {
  8805. return function( elem ) {
  8806. var name = elem.nodeName.toLowerCase();
  8807. return (name === "input" || name === "button") && elem.type === type;
  8808. };
  8809. }
  8810. /**
  8811. * Returns a function to use in pseudos for :enabled/:disabled
  8812. * @param {Boolean} disabled true for :disabled; false for :enabled
  8813. */
  8814. function createDisabledPseudo( disabled ) {
  8815. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  8816. return function( elem ) {
  8817. // Only certain elements can match :enabled or :disabled
  8818. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  8819. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  8820. if ( "form" in elem ) {
  8821. // Check for inherited disabledness on relevant non-disabled elements:
  8822. // * listed form-associated elements in a disabled fieldset
  8823. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  8824. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  8825. // * option elements in a disabled optgroup
  8826. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  8827. // All such elements have a "form" property.
  8828. if ( elem.parentNode && elem.disabled === false ) {
  8829. // Option elements defer to a parent optgroup if present
  8830. if ( "label" in elem ) {
  8831. if ( "label" in elem.parentNode ) {
  8832. return elem.parentNode.disabled === disabled;
  8833. } else {
  8834. return elem.disabled === disabled;
  8835. }
  8836. }
  8837. // Support: IE 6 - 11
  8838. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  8839. return elem.isDisabled === disabled ||
  8840. // Where there is no isDisabled, check manually
  8841. /* jshint -W018 */
  8842. elem.isDisabled !== !disabled &&
  8843. inDisabledFieldset( elem ) === disabled;
  8844. }
  8845. return elem.disabled === disabled;
  8846. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  8847. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  8848. // even exist on them, let alone have a boolean value.
  8849. } else if ( "label" in elem ) {
  8850. return elem.disabled === disabled;
  8851. }
  8852. // Remaining elements are neither :enabled nor :disabled
  8853. return false;
  8854. };
  8855. }
  8856. /**
  8857. * Returns a function to use in pseudos for positionals
  8858. * @param {Function} fn
  8859. */
  8860. function createPositionalPseudo( fn ) {
  8861. return markFunction(function( argument ) {
  8862. argument = +argument;
  8863. return markFunction(function( seed, matches ) {
  8864. var j,
  8865. matchIndexes = fn( [], seed.length, argument ),
  8866. i = matchIndexes.length;
  8867. // Match elements found at the specified indexes
  8868. while ( i-- ) {
  8869. if ( seed[ (j = matchIndexes[i]) ] ) {
  8870. seed[j] = !(matches[j] = seed[j]);
  8871. }
  8872. }
  8873. });
  8874. });
  8875. }
  8876. /**
  8877. * Checks a node for validity as a Sizzle context
  8878. * @param {Element|Object=} context
  8879. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  8880. */
  8881. function testContext( context ) {
  8882. return context && typeof context.getElementsByTagName !== "undefined" && context;
  8883. }
  8884. // Expose support vars for convenience
  8885. support = Sizzle.support = {};
  8886. /**
  8887. * Detects XML nodes
  8888. * @param {Element|Object} elem An element or a document
  8889. * @returns {Boolean} True iff elem is a non-HTML XML node
  8890. */
  8891. isXML = Sizzle.isXML = function( elem ) {
  8892. var namespace = elem.namespaceURI,
  8893. docElem = (elem.ownerDocument || elem).documentElement;
  8894. // Support: IE <=8
  8895. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  8896. // https://bugs.jquery.com/ticket/4833
  8897. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  8898. };
  8899. /**
  8900. * Sets document-related variables once based on the current document
  8901. * @param {Element|Object} [doc] An element or document object to use to set the document
  8902. * @returns {Object} Returns the current document
  8903. */
  8904. setDocument = Sizzle.setDocument = function( node ) {
  8905. var hasCompare, subWindow,
  8906. doc = node ? node.ownerDocument || node : preferredDoc;
  8907. // Return early if doc is invalid or already selected
  8908. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  8909. return document;
  8910. }
  8911. // Update global variables
  8912. document = doc;
  8913. docElem = document.documentElement;
  8914. documentIsHTML = !isXML( document );
  8915. // Support: IE 9-11, Edge
  8916. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  8917. if ( preferredDoc !== document &&
  8918. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  8919. // Support: IE 11, Edge
  8920. if ( subWindow.addEventListener ) {
  8921. subWindow.addEventListener( "unload", unloadHandler, false );
  8922. // Support: IE 9 - 10 only
  8923. } else if ( subWindow.attachEvent ) {
  8924. subWindow.attachEvent( "onunload", unloadHandler );
  8925. }
  8926. }
  8927. /* Attributes
  8928. ---------------------------------------------------------------------- */
  8929. // Support: IE<8
  8930. // Verify that getAttribute really returns attributes and not properties
  8931. // (excepting IE8 booleans)
  8932. support.attributes = assert(function( el ) {
  8933. el.className = "i";
  8934. return !el.getAttribute("className");
  8935. });
  8936. /* getElement(s)By*
  8937. ---------------------------------------------------------------------- */
  8938. // Check if getElementsByTagName("*") returns only elements
  8939. support.getElementsByTagName = assert(function( el ) {
  8940. el.appendChild( document.createComment("") );
  8941. return !el.getElementsByTagName("*").length;
  8942. });
  8943. // Support: IE<9
  8944. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  8945. // Support: IE<10
  8946. // Check if getElementById returns elements by name
  8947. // The broken getElementById methods don't pick up programmatically-set names,
  8948. // so use a roundabout getElementsByName test
  8949. support.getById = assert(function( el ) {
  8950. docElem.appendChild( el ).id = expando;
  8951. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  8952. });
  8953. // ID filter and find
  8954. if ( support.getById ) {
  8955. Expr.filter["ID"] = function( id ) {
  8956. var attrId = id.replace( runescape, funescape );
  8957. return function( elem ) {
  8958. return elem.getAttribute("id") === attrId;
  8959. };
  8960. };
  8961. Expr.find["ID"] = function( id, context ) {
  8962. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8963. var elem = context.getElementById( id );
  8964. return elem ? [ elem ] : [];
  8965. }
  8966. };
  8967. } else {
  8968. Expr.filter["ID"] = function( id ) {
  8969. var attrId = id.replace( runescape, funescape );
  8970. return function( elem ) {
  8971. var node = typeof elem.getAttributeNode !== "undefined" &&
  8972. elem.getAttributeNode("id");
  8973. return node && node.value === attrId;
  8974. };
  8975. };
  8976. // Support: IE 6 - 7 only
  8977. // getElementById is not reliable as a find shortcut
  8978. Expr.find["ID"] = function( id, context ) {
  8979. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  8980. var node, i, elems,
  8981. elem = context.getElementById( id );
  8982. if ( elem ) {
  8983. // Verify the id attribute
  8984. node = elem.getAttributeNode("id");
  8985. if ( node && node.value === id ) {
  8986. return [ elem ];
  8987. }
  8988. // Fall back on getElementsByName
  8989. elems = context.getElementsByName( id );
  8990. i = 0;
  8991. while ( (elem = elems[i++]) ) {
  8992. node = elem.getAttributeNode("id");
  8993. if ( node && node.value === id ) {
  8994. return [ elem ];
  8995. }
  8996. }
  8997. }
  8998. return [];
  8999. }
  9000. };
  9001. }
  9002. // Tag
  9003. Expr.find["TAG"] = support.getElementsByTagName ?
  9004. function( tag, context ) {
  9005. if ( typeof context.getElementsByTagName !== "undefined" ) {
  9006. return context.getElementsByTagName( tag );
  9007. // DocumentFragment nodes don't have gEBTN
  9008. } else if ( support.qsa ) {
  9009. return context.querySelectorAll( tag );
  9010. }
  9011. } :
  9012. function( tag, context ) {
  9013. var elem,
  9014. tmp = [],
  9015. i = 0,
  9016. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  9017. results = context.getElementsByTagName( tag );
  9018. // Filter out possible comments
  9019. if ( tag === "*" ) {
  9020. while ( (elem = results[i++]) ) {
  9021. if ( elem.nodeType === 1 ) {
  9022. tmp.push( elem );
  9023. }
  9024. }
  9025. return tmp;
  9026. }
  9027. return results;
  9028. };
  9029. // Class
  9030. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  9031. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  9032. return context.getElementsByClassName( className );
  9033. }
  9034. };
  9035. /* QSA/matchesSelector
  9036. ---------------------------------------------------------------------- */
  9037. // QSA and matchesSelector support
  9038. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  9039. rbuggyMatches = [];
  9040. // qSa(:focus) reports false when true (Chrome 21)
  9041. // We allow this because of a bug in IE8/9 that throws an error
  9042. // whenever `document.activeElement` is accessed on an iframe
  9043. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  9044. // See https://bugs.jquery.com/ticket/13378
  9045. rbuggyQSA = [];
  9046. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  9047. // Build QSA regex
  9048. // Regex strategy adopted from Diego Perini
  9049. assert(function( el ) {
  9050. // Select is set to empty string on purpose
  9051. // This is to test IE's treatment of not explicitly
  9052. // setting a boolean content attribute,
  9053. // since its presence should be enough
  9054. // https://bugs.jquery.com/ticket/12359
  9055. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  9056. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  9057. "<option selected=''></option></select>";
  9058. // Support: IE8, Opera 11-12.16
  9059. // Nothing should be selected when empty strings follow ^= or $= or *=
  9060. // The test attribute must be unknown in Opera but "safe" for WinRT
  9061. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  9062. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  9063. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  9064. }
  9065. // Support: IE8
  9066. // Boolean attributes and "value" are not treated correctly
  9067. if ( !el.querySelectorAll("[selected]").length ) {
  9068. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  9069. }
  9070. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  9071. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  9072. rbuggyQSA.push("~=");
  9073. }
  9074. // Webkit/Opera - :checked should return selected option elements
  9075. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  9076. // IE8 throws error here and will not see later tests
  9077. if ( !el.querySelectorAll(":checked").length ) {
  9078. rbuggyQSA.push(":checked");
  9079. }
  9080. // Support: Safari 8+, iOS 8+
  9081. // https://bugs.webkit.org/show_bug.cgi?id=136851
  9082. // In-page `selector#id sibling-combinator selector` fails
  9083. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  9084. rbuggyQSA.push(".#.+[+~]");
  9085. }
  9086. });
  9087. assert(function( el ) {
  9088. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  9089. "<select disabled='disabled'><option/></select>";
  9090. // Support: Windows 8 Native Apps
  9091. // The type and name attributes are restricted during .innerHTML assignment
  9092. var input = document.createElement("input");
  9093. input.setAttribute( "type", "hidden" );
  9094. el.appendChild( input ).setAttribute( "name", "D" );
  9095. // Support: IE8
  9096. // Enforce case-sensitivity of name attribute
  9097. if ( el.querySelectorAll("[name=d]").length ) {
  9098. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  9099. }
  9100. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  9101. // IE8 throws error here and will not see later tests
  9102. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  9103. rbuggyQSA.push( ":enabled", ":disabled" );
  9104. }
  9105. // Support: IE9-11+
  9106. // IE's :disabled selector does not pick up the children of disabled fieldsets
  9107. docElem.appendChild( el ).disabled = true;
  9108. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  9109. rbuggyQSA.push( ":enabled", ":disabled" );
  9110. }
  9111. // Opera 10-11 does not throw on post-comma invalid pseudos
  9112. el.querySelectorAll("*,:x");
  9113. rbuggyQSA.push(",.*:");
  9114. });
  9115. }
  9116. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  9117. docElem.webkitMatchesSelector ||
  9118. docElem.mozMatchesSelector ||
  9119. docElem.oMatchesSelector ||
  9120. docElem.msMatchesSelector) )) ) {
  9121. assert(function( el ) {
  9122. // Check to see if it's possible to do matchesSelector
  9123. // on a disconnected node (IE 9)
  9124. support.disconnectedMatch = matches.call( el, "*" );
  9125. // This should fail with an exception
  9126. // Gecko does not error, returns false instead
  9127. matches.call( el, "[s!='']:x" );
  9128. rbuggyMatches.push( "!=", pseudos );
  9129. });
  9130. }
  9131. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  9132. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  9133. /* Contains
  9134. ---------------------------------------------------------------------- */
  9135. hasCompare = rnative.test( docElem.compareDocumentPosition );
  9136. // Element contains another
  9137. // Purposefully self-exclusive
  9138. // As in, an element does not contain itself
  9139. contains = hasCompare || rnative.test( docElem.contains ) ?
  9140. function( a, b ) {
  9141. var adown = a.nodeType === 9 ? a.documentElement : a,
  9142. bup = b && b.parentNode;
  9143. return a === bup || !!( bup && bup.nodeType === 1 && (
  9144. adown.contains ?
  9145. adown.contains( bup ) :
  9146. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  9147. ));
  9148. } :
  9149. function( a, b ) {
  9150. if ( b ) {
  9151. while ( (b = b.parentNode) ) {
  9152. if ( b === a ) {
  9153. return true;
  9154. }
  9155. }
  9156. }
  9157. return false;
  9158. };
  9159. /* Sorting
  9160. ---------------------------------------------------------------------- */
  9161. // Document order sorting
  9162. sortOrder = hasCompare ?
  9163. function( a, b ) {
  9164. // Flag for duplicate removal
  9165. if ( a === b ) {
  9166. hasDuplicate = true;
  9167. return 0;
  9168. }
  9169. // Sort on method existence if only one input has compareDocumentPosition
  9170. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  9171. if ( compare ) {
  9172. return compare;
  9173. }
  9174. // Calculate position if both inputs belong to the same document
  9175. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  9176. a.compareDocumentPosition( b ) :
  9177. // Otherwise we know they are disconnected
  9178. 1;
  9179. // Disconnected nodes
  9180. if ( compare & 1 ||
  9181. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  9182. // Choose the first element that is related to our preferred document
  9183. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  9184. return -1;
  9185. }
  9186. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  9187. return 1;
  9188. }
  9189. // Maintain original order
  9190. return sortInput ?
  9191. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  9192. 0;
  9193. }
  9194. return compare & 4 ? -1 : 1;
  9195. } :
  9196. function( a, b ) {
  9197. // Exit early if the nodes are identical
  9198. if ( a === b ) {
  9199. hasDuplicate = true;
  9200. return 0;
  9201. }
  9202. var cur,
  9203. i = 0,
  9204. aup = a.parentNode,
  9205. bup = b.parentNode,
  9206. ap = [ a ],
  9207. bp = [ b ];
  9208. // Parentless nodes are either documents or disconnected
  9209. if ( !aup || !bup ) {
  9210. return a === document ? -1 :
  9211. b === document ? 1 :
  9212. aup ? -1 :
  9213. bup ? 1 :
  9214. sortInput ?
  9215. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  9216. 0;
  9217. // If the nodes are siblings, we can do a quick check
  9218. } else if ( aup === bup ) {
  9219. return siblingCheck( a, b );
  9220. }
  9221. // Otherwise we need full lists of their ancestors for comparison
  9222. cur = a;
  9223. while ( (cur = cur.parentNode) ) {
  9224. ap.unshift( cur );
  9225. }
  9226. cur = b;
  9227. while ( (cur = cur.parentNode) ) {
  9228. bp.unshift( cur );
  9229. }
  9230. // Walk down the tree looking for a discrepancy
  9231. while ( ap[i] === bp[i] ) {
  9232. i++;
  9233. }
  9234. return i ?
  9235. // Do a sibling check if the nodes have a common ancestor
  9236. siblingCheck( ap[i], bp[i] ) :
  9237. // Otherwise nodes in our document sort first
  9238. ap[i] === preferredDoc ? -1 :
  9239. bp[i] === preferredDoc ? 1 :
  9240. 0;
  9241. };
  9242. return document;
  9243. };
  9244. Sizzle.matches = function( expr, elements ) {
  9245. return Sizzle( expr, null, null, elements );
  9246. };
  9247. Sizzle.matchesSelector = function( elem, expr ) {
  9248. // Set document vars if needed
  9249. if ( ( elem.ownerDocument || elem ) !== document ) {
  9250. setDocument( elem );
  9251. }
  9252. if ( support.matchesSelector && documentIsHTML &&
  9253. !nonnativeSelectorCache[ expr + " " ] &&
  9254. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  9255. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  9256. try {
  9257. var ret = matches.call( elem, expr );
  9258. // IE 9's matchesSelector returns false on disconnected nodes
  9259. if ( ret || support.disconnectedMatch ||
  9260. // As well, disconnected nodes are said to be in a document
  9261. // fragment in IE 9
  9262. elem.document && elem.document.nodeType !== 11 ) {
  9263. return ret;
  9264. }
  9265. } catch (e) {
  9266. nonnativeSelectorCache( expr, true );
  9267. }
  9268. }
  9269. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  9270. };
  9271. Sizzle.contains = function( context, elem ) {
  9272. // Set document vars if needed
  9273. if ( ( context.ownerDocument || context ) !== document ) {
  9274. setDocument( context );
  9275. }
  9276. return contains( context, elem );
  9277. };
  9278. Sizzle.attr = function( elem, name ) {
  9279. // Set document vars if needed
  9280. if ( ( elem.ownerDocument || elem ) !== document ) {
  9281. setDocument( elem );
  9282. }
  9283. var fn = Expr.attrHandle[ name.toLowerCase() ],
  9284. // Don't get fooled by Object.prototype properties (jQuery #13807)
  9285. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  9286. fn( elem, name, !documentIsHTML ) :
  9287. undefined;
  9288. return val !== undefined ?
  9289. val :
  9290. support.attributes || !documentIsHTML ?
  9291. elem.getAttribute( name ) :
  9292. (val = elem.getAttributeNode(name)) && val.specified ?
  9293. val.value :
  9294. null;
  9295. };
  9296. Sizzle.escape = function( sel ) {
  9297. return (sel + "").replace( rcssescape, fcssescape );
  9298. };
  9299. Sizzle.error = function( msg ) {
  9300. throw new Error( "Syntax error, unrecognized expression: " + msg );
  9301. };
  9302. /**
  9303. * Document sorting and removing duplicates
  9304. * @param {ArrayLike} results
  9305. */
  9306. Sizzle.uniqueSort = function( results ) {
  9307. var elem,
  9308. duplicates = [],
  9309. j = 0,
  9310. i = 0;
  9311. // Unless we *know* we can detect duplicates, assume their presence
  9312. hasDuplicate = !support.detectDuplicates;
  9313. sortInput = !support.sortStable && results.slice( 0 );
  9314. results.sort( sortOrder );
  9315. if ( hasDuplicate ) {
  9316. while ( (elem = results[i++]) ) {
  9317. if ( elem === results[ i ] ) {
  9318. j = duplicates.push( i );
  9319. }
  9320. }
  9321. while ( j-- ) {
  9322. results.splice( duplicates[ j ], 1 );
  9323. }
  9324. }
  9325. // Clear input after sorting to release objects
  9326. // See https://github.com/jquery/sizzle/pull/225
  9327. sortInput = null;
  9328. return results;
  9329. };
  9330. /**
  9331. * Utility function for retrieving the text value of an array of DOM nodes
  9332. * @param {Array|Element} elem
  9333. */
  9334. getText = Sizzle.getText = function( elem ) {
  9335. var node,
  9336. ret = "",
  9337. i = 0,
  9338. nodeType = elem.nodeType;
  9339. if ( !nodeType ) {
  9340. // If no nodeType, this is expected to be an array
  9341. while ( (node = elem[i++]) ) {
  9342. // Do not traverse comment nodes
  9343. ret += getText( node );
  9344. }
  9345. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  9346. // Use textContent for elements
  9347. // innerText usage removed for consistency of new lines (jQuery #11153)
  9348. if ( typeof elem.textContent === "string" ) {
  9349. return elem.textContent;
  9350. } else {
  9351. // Traverse its children
  9352. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  9353. ret += getText( elem );
  9354. }
  9355. }
  9356. } else if ( nodeType === 3 || nodeType === 4 ) {
  9357. return elem.nodeValue;
  9358. }
  9359. // Do not include comment or processing instruction nodes
  9360. return ret;
  9361. };
  9362. Expr = Sizzle.selectors = {
  9363. // Can be adjusted by the user
  9364. cacheLength: 50,
  9365. createPseudo: markFunction,
  9366. match: matchExpr,
  9367. attrHandle: {},
  9368. find: {},
  9369. relative: {
  9370. ">": { dir: "parentNode", first: true },
  9371. " ": { dir: "parentNode" },
  9372. "+": { dir: "previousSibling", first: true },
  9373. "~": { dir: "previousSibling" }
  9374. },
  9375. preFilter: {
  9376. "ATTR": function( match ) {
  9377. match[1] = match[1].replace( runescape, funescape );
  9378. // Move the given value to match[3] whether quoted or unquoted
  9379. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  9380. if ( match[2] === "~=" ) {
  9381. match[3] = " " + match[3] + " ";
  9382. }
  9383. return match.slice( 0, 4 );
  9384. },
  9385. "CHILD": function( match ) {
  9386. /* matches from matchExpr["CHILD"]
  9387. 1 type (only|nth|...)
  9388. 2 what (child|of-type)
  9389. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  9390. 4 xn-component of xn+y argument ([+-]?\d*n|)
  9391. 5 sign of xn-component
  9392. 6 x of xn-component
  9393. 7 sign of y-component
  9394. 8 y of y-component
  9395. */
  9396. match[1] = match[1].toLowerCase();
  9397. if ( match[1].slice( 0, 3 ) === "nth" ) {
  9398. // nth-* requires argument
  9399. if ( !match[3] ) {
  9400. Sizzle.error( match[0] );
  9401. }
  9402. // numeric x and y parameters for Expr.filter.CHILD
  9403. // remember that false/true cast respectively to 0/1
  9404. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  9405. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  9406. // other types prohibit arguments
  9407. } else if ( match[3] ) {
  9408. Sizzle.error( match[0] );
  9409. }
  9410. return match;
  9411. },
  9412. "PSEUDO": function( match ) {
  9413. var excess,
  9414. unquoted = !match[6] && match[2];
  9415. if ( matchExpr["CHILD"].test( match[0] ) ) {
  9416. return null;
  9417. }
  9418. // Accept quoted arguments as-is
  9419. if ( match[3] ) {
  9420. match[2] = match[4] || match[5] || "";
  9421. // Strip excess characters from unquoted arguments
  9422. } else if ( unquoted && rpseudo.test( unquoted ) &&
  9423. // Get excess from tokenize (recursively)
  9424. (excess = tokenize( unquoted, true )) &&
  9425. // advance to the next closing parenthesis
  9426. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  9427. // excess is a negative index
  9428. match[0] = match[0].slice( 0, excess );
  9429. match[2] = unquoted.slice( 0, excess );
  9430. }
  9431. // Return only captures needed by the pseudo filter method (type and argument)
  9432. return match.slice( 0, 3 );
  9433. }
  9434. },
  9435. filter: {
  9436. "TAG": function( nodeNameSelector ) {
  9437. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  9438. return nodeNameSelector === "*" ?
  9439. function() { return true; } :
  9440. function( elem ) {
  9441. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  9442. };
  9443. },
  9444. "CLASS": function( className ) {
  9445. var pattern = classCache[ className + " " ];
  9446. return pattern ||
  9447. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  9448. classCache( className, function( elem ) {
  9449. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  9450. });
  9451. },
  9452. "ATTR": function( name, operator, check ) {
  9453. return function( elem ) {
  9454. var result = Sizzle.attr( elem, name );
  9455. if ( result == null ) {
  9456. return operator === "!=";
  9457. }
  9458. if ( !operator ) {
  9459. return true;
  9460. }
  9461. result += "";
  9462. return operator === "=" ? result === check :
  9463. operator === "!=" ? result !== check :
  9464. operator === "^=" ? check && result.indexOf( check ) === 0 :
  9465. operator === "*=" ? check && result.indexOf( check ) > -1 :
  9466. operator === "$=" ? check && result.slice( -check.length ) === check :
  9467. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  9468. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  9469. false;
  9470. };
  9471. },
  9472. "CHILD": function( type, what, argument, first, last ) {
  9473. var simple = type.slice( 0, 3 ) !== "nth",
  9474. forward = type.slice( -4 ) !== "last",
  9475. ofType = what === "of-type";
  9476. return first === 1 && last === 0 ?
  9477. // Shortcut for :nth-*(n)
  9478. function( elem ) {
  9479. return !!elem.parentNode;
  9480. } :
  9481. function( elem, context, xml ) {
  9482. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  9483. dir = simple !== forward ? "nextSibling" : "previousSibling",
  9484. parent = elem.parentNode,
  9485. name = ofType && elem.nodeName.toLowerCase(),
  9486. useCache = !xml && !ofType,
  9487. diff = false;
  9488. if ( parent ) {
  9489. // :(first|last|only)-(child|of-type)
  9490. if ( simple ) {
  9491. while ( dir ) {
  9492. node = elem;
  9493. while ( (node = node[ dir ]) ) {
  9494. if ( ofType ?
  9495. node.nodeName.toLowerCase() === name :
  9496. node.nodeType === 1 ) {
  9497. return false;
  9498. }
  9499. }
  9500. // Reverse direction for :only-* (if we haven't yet done so)
  9501. start = dir = type === "only" && !start && "nextSibling";
  9502. }
  9503. return true;
  9504. }
  9505. start = [ forward ? parent.firstChild : parent.lastChild ];
  9506. // non-xml :nth-child(...) stores cache data on `parent`
  9507. if ( forward && useCache ) {
  9508. // Seek `elem` from a previously-cached index
  9509. // ...in a gzip-friendly way
  9510. node = parent;
  9511. outerCache = node[ expando ] || (node[ expando ] = {});
  9512. // Support: IE <9 only
  9513. // Defend against cloned attroperties (jQuery gh-1709)
  9514. uniqueCache = outerCache[ node.uniqueID ] ||
  9515. (outerCache[ node.uniqueID ] = {});
  9516. cache = uniqueCache[ type ] || [];
  9517. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  9518. diff = nodeIndex && cache[ 2 ];
  9519. node = nodeIndex && parent.childNodes[ nodeIndex ];
  9520. while ( (node = ++nodeIndex && node && node[ dir ] ||
  9521. // Fallback to seeking `elem` from the start
  9522. (diff = nodeIndex = 0) || start.pop()) ) {
  9523. // When found, cache indexes on `parent` and break
  9524. if ( node.nodeType === 1 && ++diff && node === elem ) {
  9525. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  9526. break;
  9527. }
  9528. }
  9529. } else {
  9530. // Use previously-cached element index if available
  9531. if ( useCache ) {
  9532. // ...in a gzip-friendly way
  9533. node = elem;
  9534. outerCache = node[ expando ] || (node[ expando ] = {});
  9535. // Support: IE <9 only
  9536. // Defend against cloned attroperties (jQuery gh-1709)
  9537. uniqueCache = outerCache[ node.uniqueID ] ||
  9538. (outerCache[ node.uniqueID ] = {});
  9539. cache = uniqueCache[ type ] || [];
  9540. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  9541. diff = nodeIndex;
  9542. }
  9543. // xml :nth-child(...)
  9544. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  9545. if ( diff === false ) {
  9546. // Use the same loop as above to seek `elem` from the start
  9547. while ( (node = ++nodeIndex && node && node[ dir ] ||
  9548. (diff = nodeIndex = 0) || start.pop()) ) {
  9549. if ( ( ofType ?
  9550. node.nodeName.toLowerCase() === name :
  9551. node.nodeType === 1 ) &&
  9552. ++diff ) {
  9553. // Cache the index of each encountered element
  9554. if ( useCache ) {
  9555. outerCache = node[ expando ] || (node[ expando ] = {});
  9556. // Support: IE <9 only
  9557. // Defend against cloned attroperties (jQuery gh-1709)
  9558. uniqueCache = outerCache[ node.uniqueID ] ||
  9559. (outerCache[ node.uniqueID ] = {});
  9560. uniqueCache[ type ] = [ dirruns, diff ];
  9561. }
  9562. if ( node === elem ) {
  9563. break;
  9564. }
  9565. }
  9566. }
  9567. }
  9568. }
  9569. // Incorporate the offset, then check against cycle size
  9570. diff -= last;
  9571. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  9572. }
  9573. };
  9574. },
  9575. "PSEUDO": function( pseudo, argument ) {
  9576. // pseudo-class names are case-insensitive
  9577. // http://www.w3.org/TR/selectors/#pseudo-classes
  9578. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  9579. // Remember that setFilters inherits from pseudos
  9580. var args,
  9581. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  9582. Sizzle.error( "unsupported pseudo: " + pseudo );
  9583. // The user may use createPseudo to indicate that
  9584. // arguments are needed to create the filter function
  9585. // just as Sizzle does
  9586. if ( fn[ expando ] ) {
  9587. return fn( argument );
  9588. }
  9589. // But maintain support for old signatures
  9590. if ( fn.length > 1 ) {
  9591. args = [ pseudo, pseudo, "", argument ];
  9592. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  9593. markFunction(function( seed, matches ) {
  9594. var idx,
  9595. matched = fn( seed, argument ),
  9596. i = matched.length;
  9597. while ( i-- ) {
  9598. idx = indexOf( seed, matched[i] );
  9599. seed[ idx ] = !( matches[ idx ] = matched[i] );
  9600. }
  9601. }) :
  9602. function( elem ) {
  9603. return fn( elem, 0, args );
  9604. };
  9605. }
  9606. return fn;
  9607. }
  9608. },
  9609. pseudos: {
  9610. // Potentially complex pseudos
  9611. "not": markFunction(function( selector ) {
  9612. // Trim the selector passed to compile
  9613. // to avoid treating leading and trailing
  9614. // spaces as combinators
  9615. var input = [],
  9616. results = [],
  9617. matcher = compile( selector.replace( rtrim, "$1" ) );
  9618. return matcher[ expando ] ?
  9619. markFunction(function( seed, matches, context, xml ) {
  9620. var elem,
  9621. unmatched = matcher( seed, null, xml, [] ),
  9622. i = seed.length;
  9623. // Match elements unmatched by `matcher`
  9624. while ( i-- ) {
  9625. if ( (elem = unmatched[i]) ) {
  9626. seed[i] = !(matches[i] = elem);
  9627. }
  9628. }
  9629. }) :
  9630. function( elem, context, xml ) {
  9631. input[0] = elem;
  9632. matcher( input, null, xml, results );
  9633. // Don't keep the element (issue #299)
  9634. input[0] = null;
  9635. return !results.pop();
  9636. };
  9637. }),
  9638. "has": markFunction(function( selector ) {
  9639. return function( elem ) {
  9640. return Sizzle( selector, elem ).length > 0;
  9641. };
  9642. }),
  9643. "contains": markFunction(function( text ) {
  9644. text = text.replace( runescape, funescape );
  9645. return function( elem ) {
  9646. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  9647. };
  9648. }),
  9649. // "Whether an element is represented by a :lang() selector
  9650. // is based solely on the element's language value
  9651. // being equal to the identifier C,
  9652. // or beginning with the identifier C immediately followed by "-".
  9653. // The matching of C against the element's language value is performed case-insensitively.
  9654. // The identifier C does not have to be a valid language name."
  9655. // http://www.w3.org/TR/selectors/#lang-pseudo
  9656. "lang": markFunction( function( lang ) {
  9657. // lang value must be a valid identifier
  9658. if ( !ridentifier.test(lang || "") ) {
  9659. Sizzle.error( "unsupported lang: " + lang );
  9660. }
  9661. lang = lang.replace( runescape, funescape ).toLowerCase();
  9662. return function( elem ) {
  9663. var elemLang;
  9664. do {
  9665. if ( (elemLang = documentIsHTML ?
  9666. elem.lang :
  9667. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  9668. elemLang = elemLang.toLowerCase();
  9669. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  9670. }
  9671. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  9672. return false;
  9673. };
  9674. }),
  9675. // Miscellaneous
  9676. "target": function( elem ) {
  9677. var hash = window.location && window.location.hash;
  9678. return hash && hash.slice( 1 ) === elem.id;
  9679. },
  9680. "root": function( elem ) {
  9681. return elem === docElem;
  9682. },
  9683. "focus": function( elem ) {
  9684. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  9685. },
  9686. // Boolean properties
  9687. "enabled": createDisabledPseudo( false ),
  9688. "disabled": createDisabledPseudo( true ),
  9689. "checked": function( elem ) {
  9690. // In CSS3, :checked should return both checked and selected elements
  9691. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  9692. var nodeName = elem.nodeName.toLowerCase();
  9693. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  9694. },
  9695. "selected": function( elem ) {
  9696. // Accessing this property makes selected-by-default
  9697. // options in Safari work properly
  9698. if ( elem.parentNode ) {
  9699. elem.parentNode.selectedIndex;
  9700. }
  9701. return elem.selected === true;
  9702. },
  9703. // Contents
  9704. "empty": function( elem ) {
  9705. // http://www.w3.org/TR/selectors/#empty-pseudo
  9706. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  9707. // but not by others (comment: 8; processing instruction: 7; etc.)
  9708. // nodeType < 6 works because attributes (2) do not appear as children
  9709. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  9710. if ( elem.nodeType < 6 ) {
  9711. return false;
  9712. }
  9713. }
  9714. return true;
  9715. },
  9716. "parent": function( elem ) {
  9717. return !Expr.pseudos["empty"]( elem );
  9718. },
  9719. // Element/input types
  9720. "header": function( elem ) {
  9721. return rheader.test( elem.nodeName );
  9722. },
  9723. "input": function( elem ) {
  9724. return rinputs.test( elem.nodeName );
  9725. },
  9726. "button": function( elem ) {
  9727. var name = elem.nodeName.toLowerCase();
  9728. return name === "input" && elem.type === "button" || name === "button";
  9729. },
  9730. "text": function( elem ) {
  9731. var attr;
  9732. return elem.nodeName.toLowerCase() === "input" &&
  9733. elem.type === "text" &&
  9734. // Support: IE<8
  9735. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  9736. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  9737. },
  9738. // Position-in-collection
  9739. "first": createPositionalPseudo(function() {
  9740. return [ 0 ];
  9741. }),
  9742. "last": createPositionalPseudo(function( matchIndexes, length ) {
  9743. return [ length - 1 ];
  9744. }),
  9745. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9746. return [ argument < 0 ? argument + length : argument ];
  9747. }),
  9748. "even": createPositionalPseudo(function( matchIndexes, length ) {
  9749. var i = 0;
  9750. for ( ; i < length; i += 2 ) {
  9751. matchIndexes.push( i );
  9752. }
  9753. return matchIndexes;
  9754. }),
  9755. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  9756. var i = 1;
  9757. for ( ; i < length; i += 2 ) {
  9758. matchIndexes.push( i );
  9759. }
  9760. return matchIndexes;
  9761. }),
  9762. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9763. var i = argument < 0 ?
  9764. argument + length :
  9765. argument > length ?
  9766. length :
  9767. argument;
  9768. for ( ; --i >= 0; ) {
  9769. matchIndexes.push( i );
  9770. }
  9771. return matchIndexes;
  9772. }),
  9773. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  9774. var i = argument < 0 ? argument + length : argument;
  9775. for ( ; ++i < length; ) {
  9776. matchIndexes.push( i );
  9777. }
  9778. return matchIndexes;
  9779. })
  9780. }
  9781. };
  9782. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  9783. // Add button/input type pseudos
  9784. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  9785. Expr.pseudos[ i ] = createInputPseudo( i );
  9786. }
  9787. for ( i in { submit: true, reset: true } ) {
  9788. Expr.pseudos[ i ] = createButtonPseudo( i );
  9789. }
  9790. // Easy API for creating new setFilters
  9791. function setFilters() {}
  9792. setFilters.prototype = Expr.filters = Expr.pseudos;
  9793. Expr.setFilters = new setFilters();
  9794. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  9795. var matched, match, tokens, type,
  9796. soFar, groups, preFilters,
  9797. cached = tokenCache[ selector + " " ];
  9798. if ( cached ) {
  9799. return parseOnly ? 0 : cached.slice( 0 );
  9800. }
  9801. soFar = selector;
  9802. groups = [];
  9803. preFilters = Expr.preFilter;
  9804. while ( soFar ) {
  9805. // Comma and first run
  9806. if ( !matched || (match = rcomma.exec( soFar )) ) {
  9807. if ( match ) {
  9808. // Don't consume trailing commas as valid
  9809. soFar = soFar.slice( match[0].length ) || soFar;
  9810. }
  9811. groups.push( (tokens = []) );
  9812. }
  9813. matched = false;
  9814. // Combinators
  9815. if ( (match = rcombinators.exec( soFar )) ) {
  9816. matched = match.shift();
  9817. tokens.push({
  9818. value: matched,
  9819. // Cast descendant combinators to space
  9820. type: match[0].replace( rtrim, " " )
  9821. });
  9822. soFar = soFar.slice( matched.length );
  9823. }
  9824. // Filters
  9825. for ( type in Expr.filter ) {
  9826. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  9827. (match = preFilters[ type ]( match ))) ) {
  9828. matched = match.shift();
  9829. tokens.push({
  9830. value: matched,
  9831. type: type,
  9832. matches: match
  9833. });
  9834. soFar = soFar.slice( matched.length );
  9835. }
  9836. }
  9837. if ( !matched ) {
  9838. break;
  9839. }
  9840. }
  9841. // Return the length of the invalid excess
  9842. // if we're just parsing
  9843. // Otherwise, throw an error or return tokens
  9844. return parseOnly ?
  9845. soFar.length :
  9846. soFar ?
  9847. Sizzle.error( selector ) :
  9848. // Cache the tokens
  9849. tokenCache( selector, groups ).slice( 0 );
  9850. };
  9851. function toSelector( tokens ) {
  9852. var i = 0,
  9853. len = tokens.length,
  9854. selector = "";
  9855. for ( ; i < len; i++ ) {
  9856. selector += tokens[i].value;
  9857. }
  9858. return selector;
  9859. }
  9860. function addCombinator( matcher, combinator, base ) {
  9861. var dir = combinator.dir,
  9862. skip = combinator.next,
  9863. key = skip || dir,
  9864. checkNonElements = base && key === "parentNode",
  9865. doneName = done++;
  9866. return combinator.first ?
  9867. // Check against closest ancestor/preceding element
  9868. function( elem, context, xml ) {
  9869. while ( (elem = elem[ dir ]) ) {
  9870. if ( elem.nodeType === 1 || checkNonElements ) {
  9871. return matcher( elem, context, xml );
  9872. }
  9873. }
  9874. return false;
  9875. } :
  9876. // Check against all ancestor/preceding elements
  9877. function( elem, context, xml ) {
  9878. var oldCache, uniqueCache, outerCache,
  9879. newCache = [ dirruns, doneName ];
  9880. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  9881. if ( xml ) {
  9882. while ( (elem = elem[ dir ]) ) {
  9883. if ( elem.nodeType === 1 || checkNonElements ) {
  9884. if ( matcher( elem, context, xml ) ) {
  9885. return true;
  9886. }
  9887. }
  9888. }
  9889. } else {
  9890. while ( (elem = elem[ dir ]) ) {
  9891. if ( elem.nodeType === 1 || checkNonElements ) {
  9892. outerCache = elem[ expando ] || (elem[ expando ] = {});
  9893. // Support: IE <9 only
  9894. // Defend against cloned attroperties (jQuery gh-1709)
  9895. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  9896. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  9897. elem = elem[ dir ] || elem;
  9898. } else if ( (oldCache = uniqueCache[ key ]) &&
  9899. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  9900. // Assign to newCache so results back-propagate to previous elements
  9901. return (newCache[ 2 ] = oldCache[ 2 ]);
  9902. } else {
  9903. // Reuse newcache so results back-propagate to previous elements
  9904. uniqueCache[ key ] = newCache;
  9905. // A match means we're done; a fail means we have to keep checking
  9906. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  9907. return true;
  9908. }
  9909. }
  9910. }
  9911. }
  9912. }
  9913. return false;
  9914. };
  9915. }
  9916. function elementMatcher( matchers ) {
  9917. return matchers.length > 1 ?
  9918. function( elem, context, xml ) {
  9919. var i = matchers.length;
  9920. while ( i-- ) {
  9921. if ( !matchers[i]( elem, context, xml ) ) {
  9922. return false;
  9923. }
  9924. }
  9925. return true;
  9926. } :
  9927. matchers[0];
  9928. }
  9929. function multipleContexts( selector, contexts, results ) {
  9930. var i = 0,
  9931. len = contexts.length;
  9932. for ( ; i < len; i++ ) {
  9933. Sizzle( selector, contexts[i], results );
  9934. }
  9935. return results;
  9936. }
  9937. function condense( unmatched, map, filter, context, xml ) {
  9938. var elem,
  9939. newUnmatched = [],
  9940. i = 0,
  9941. len = unmatched.length,
  9942. mapped = map != null;
  9943. for ( ; i < len; i++ ) {
  9944. if ( (elem = unmatched[i]) ) {
  9945. if ( !filter || filter( elem, context, xml ) ) {
  9946. newUnmatched.push( elem );
  9947. if ( mapped ) {
  9948. map.push( i );
  9949. }
  9950. }
  9951. }
  9952. }
  9953. return newUnmatched;
  9954. }
  9955. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  9956. if ( postFilter && !postFilter[ expando ] ) {
  9957. postFilter = setMatcher( postFilter );
  9958. }
  9959. if ( postFinder && !postFinder[ expando ] ) {
  9960. postFinder = setMatcher( postFinder, postSelector );
  9961. }
  9962. return markFunction(function( seed, results, context, xml ) {
  9963. var temp, i, elem,
  9964. preMap = [],
  9965. postMap = [],
  9966. preexisting = results.length,
  9967. // Get initial elements from seed or context
  9968. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  9969. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  9970. matcherIn = preFilter && ( seed || !selector ) ?
  9971. condense( elems, preMap, preFilter, context, xml ) :
  9972. elems,
  9973. matcherOut = matcher ?
  9974. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  9975. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  9976. // ...intermediate processing is necessary
  9977. [] :
  9978. // ...otherwise use results directly
  9979. results :
  9980. matcherIn;
  9981. // Find primary matches
  9982. if ( matcher ) {
  9983. matcher( matcherIn, matcherOut, context, xml );
  9984. }
  9985. // Apply postFilter
  9986. if ( postFilter ) {
  9987. temp = condense( matcherOut, postMap );
  9988. postFilter( temp, [], context, xml );
  9989. // Un-match failing elements by moving them back to matcherIn
  9990. i = temp.length;
  9991. while ( i-- ) {
  9992. if ( (elem = temp[i]) ) {
  9993. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  9994. }
  9995. }
  9996. }
  9997. if ( seed ) {
  9998. if ( postFinder || preFilter ) {
  9999. if ( postFinder ) {
  10000. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  10001. temp = [];
  10002. i = matcherOut.length;
  10003. while ( i-- ) {
  10004. if ( (elem = matcherOut[i]) ) {
  10005. // Restore matcherIn since elem is not yet a final match
  10006. temp.push( (matcherIn[i] = elem) );
  10007. }
  10008. }
  10009. postFinder( null, (matcherOut = []), temp, xml );
  10010. }
  10011. // Move matched elements from seed to results to keep them synchronized
  10012. i = matcherOut.length;
  10013. while ( i-- ) {
  10014. if ( (elem = matcherOut[i]) &&
  10015. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  10016. seed[temp] = !(results[temp] = elem);
  10017. }
  10018. }
  10019. }
  10020. // Add elements to results, through postFinder if defined
  10021. } else {
  10022. matcherOut = condense(
  10023. matcherOut === results ?
  10024. matcherOut.splice( preexisting, matcherOut.length ) :
  10025. matcherOut
  10026. );
  10027. if ( postFinder ) {
  10028. postFinder( null, results, matcherOut, xml );
  10029. } else {
  10030. push.apply( results, matcherOut );
  10031. }
  10032. }
  10033. });
  10034. }
  10035. function matcherFromTokens( tokens ) {
  10036. var checkContext, matcher, j,
  10037. len = tokens.length,
  10038. leadingRelative = Expr.relative[ tokens[0].type ],
  10039. implicitRelative = leadingRelative || Expr.relative[" "],
  10040. i = leadingRelative ? 1 : 0,
  10041. // The foundational matcher ensures that elements are reachable from top-level context(s)
  10042. matchContext = addCombinator( function( elem ) {
  10043. return elem === checkContext;
  10044. }, implicitRelative, true ),
  10045. matchAnyContext = addCombinator( function( elem ) {
  10046. return indexOf( checkContext, elem ) > -1;
  10047. }, implicitRelative, true ),
  10048. matchers = [ function( elem, context, xml ) {
  10049. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  10050. (checkContext = context).nodeType ?
  10051. matchContext( elem, context, xml ) :
  10052. matchAnyContext( elem, context, xml ) );
  10053. // Avoid hanging onto element (issue #299)
  10054. checkContext = null;
  10055. return ret;
  10056. } ];
  10057. for ( ; i < len; i++ ) {
  10058. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  10059. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  10060. } else {
  10061. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  10062. // Return special upon seeing a positional matcher
  10063. if ( matcher[ expando ] ) {
  10064. // Find the next relative operator (if any) for proper handling
  10065. j = ++i;
  10066. for ( ; j < len; j++ ) {
  10067. if ( Expr.relative[ tokens[j].type ] ) {
  10068. break;
  10069. }
  10070. }
  10071. return setMatcher(
  10072. i > 1 && elementMatcher( matchers ),
  10073. i > 1 && toSelector(
  10074. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  10075. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  10076. ).replace( rtrim, "$1" ),
  10077. matcher,
  10078. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  10079. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  10080. j < len && toSelector( tokens )
  10081. );
  10082. }
  10083. matchers.push( matcher );
  10084. }
  10085. }
  10086. return elementMatcher( matchers );
  10087. }
  10088. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  10089. var bySet = setMatchers.length > 0,
  10090. byElement = elementMatchers.length > 0,
  10091. superMatcher = function( seed, context, xml, results, outermost ) {
  10092. var elem, j, matcher,
  10093. matchedCount = 0,
  10094. i = "0",
  10095. unmatched = seed && [],
  10096. setMatched = [],
  10097. contextBackup = outermostContext,
  10098. // We must always have either seed elements or outermost context
  10099. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  10100. // Use integer dirruns iff this is the outermost matcher
  10101. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  10102. len = elems.length;
  10103. if ( outermost ) {
  10104. outermostContext = context === document || context || outermost;
  10105. }
  10106. // Add elements passing elementMatchers directly to results
  10107. // Support: IE<9, Safari
  10108. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  10109. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  10110. if ( byElement && elem ) {
  10111. j = 0;
  10112. if ( !context && elem.ownerDocument !== document ) {
  10113. setDocument( elem );
  10114. xml = !documentIsHTML;
  10115. }
  10116. while ( (matcher = elementMatchers[j++]) ) {
  10117. if ( matcher( elem, context || document, xml) ) {
  10118. results.push( elem );
  10119. break;
  10120. }
  10121. }
  10122. if ( outermost ) {
  10123. dirruns = dirrunsUnique;
  10124. }
  10125. }
  10126. // Track unmatched elements for set filters
  10127. if ( bySet ) {
  10128. // They will have gone through all possible matchers
  10129. if ( (elem = !matcher && elem) ) {
  10130. matchedCount--;
  10131. }
  10132. // Lengthen the array for every element, matched or not
  10133. if ( seed ) {
  10134. unmatched.push( elem );
  10135. }
  10136. }
  10137. }
  10138. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  10139. // makes the latter nonnegative.
  10140. matchedCount += i;
  10141. // Apply set filters to unmatched elements
  10142. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  10143. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  10144. // no element matchers and no seed.
  10145. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  10146. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  10147. // numerically zero.
  10148. if ( bySet && i !== matchedCount ) {
  10149. j = 0;
  10150. while ( (matcher = setMatchers[j++]) ) {
  10151. matcher( unmatched, setMatched, context, xml );
  10152. }
  10153. if ( seed ) {
  10154. // Reintegrate element matches to eliminate the need for sorting
  10155. if ( matchedCount > 0 ) {
  10156. while ( i-- ) {
  10157. if ( !(unmatched[i] || setMatched[i]) ) {
  10158. setMatched[i] = pop.call( results );
  10159. }
  10160. }
  10161. }
  10162. // Discard index placeholder values to get only actual matches
  10163. setMatched = condense( setMatched );
  10164. }
  10165. // Add matches to results
  10166. push.apply( results, setMatched );
  10167. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  10168. if ( outermost && !seed && setMatched.length > 0 &&
  10169. ( matchedCount + setMatchers.length ) > 1 ) {
  10170. Sizzle.uniqueSort( results );
  10171. }
  10172. }
  10173. // Override manipulation of globals by nested matchers
  10174. if ( outermost ) {
  10175. dirruns = dirrunsUnique;
  10176. outermostContext = contextBackup;
  10177. }
  10178. return unmatched;
  10179. };
  10180. return bySet ?
  10181. markFunction( superMatcher ) :
  10182. superMatcher;
  10183. }
  10184. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  10185. var i,
  10186. setMatchers = [],
  10187. elementMatchers = [],
  10188. cached = compilerCache[ selector + " " ];
  10189. if ( !cached ) {
  10190. // Generate a function of recursive functions that can be used to check each element
  10191. if ( !match ) {
  10192. match = tokenize( selector );
  10193. }
  10194. i = match.length;
  10195. while ( i-- ) {
  10196. cached = matcherFromTokens( match[i] );
  10197. if ( cached[ expando ] ) {
  10198. setMatchers.push( cached );
  10199. } else {
  10200. elementMatchers.push( cached );
  10201. }
  10202. }
  10203. // Cache the compiled function
  10204. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  10205. // Save selector and tokenization
  10206. cached.selector = selector;
  10207. }
  10208. return cached;
  10209. };
  10210. /**
  10211. * A low-level selection function that works with Sizzle's compiled
  10212. * selector functions
  10213. * @param {String|Function} selector A selector or a pre-compiled
  10214. * selector function built with Sizzle.compile
  10215. * @param {Element} context
  10216. * @param {Array} [results]
  10217. * @param {Array} [seed] A set of elements to match against
  10218. */
  10219. select = Sizzle.select = function( selector, context, results, seed ) {
  10220. var i, tokens, token, type, find,
  10221. compiled = typeof selector === "function" && selector,
  10222. match = !seed && tokenize( (selector = compiled.selector || selector) );
  10223. results = results || [];
  10224. // Try to minimize operations if there is only one selector in the list and no seed
  10225. // (the latter of which guarantees us context)
  10226. if ( match.length === 1 ) {
  10227. // Reduce context if the leading compound selector is an ID
  10228. tokens = match[0] = match[0].slice( 0 );
  10229. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  10230. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  10231. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  10232. if ( !context ) {
  10233. return results;
  10234. // Precompiled matchers will still verify ancestry, so step up a level
  10235. } else if ( compiled ) {
  10236. context = context.parentNode;
  10237. }
  10238. selector = selector.slice( tokens.shift().value.length );
  10239. }
  10240. // Fetch a seed set for right-to-left matching
  10241. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  10242. while ( i-- ) {
  10243. token = tokens[i];
  10244. // Abort if we hit a combinator
  10245. if ( Expr.relative[ (type = token.type) ] ) {
  10246. break;
  10247. }
  10248. if ( (find = Expr.find[ type ]) ) {
  10249. // Search, expanding context for leading sibling combinators
  10250. if ( (seed = find(
  10251. token.matches[0].replace( runescape, funescape ),
  10252. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  10253. )) ) {
  10254. // If seed is empty or no tokens remain, we can return early
  10255. tokens.splice( i, 1 );
  10256. selector = seed.length && toSelector( tokens );
  10257. if ( !selector ) {
  10258. push.apply( results, seed );
  10259. return results;
  10260. }
  10261. break;
  10262. }
  10263. }
  10264. }
  10265. }
  10266. // Compile and execute a filtering function if one is not provided
  10267. // Provide `match` to avoid retokenization if we modified the selector above
  10268. ( compiled || compile( selector, match ) )(
  10269. seed,
  10270. context,
  10271. !documentIsHTML,
  10272. results,
  10273. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  10274. );
  10275. return results;
  10276. };
  10277. // One-time assignments
  10278. // Sort stability
  10279. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  10280. // Support: Chrome 14-35+
  10281. // Always assume duplicates if they aren't passed to the comparison function
  10282. support.detectDuplicates = !!hasDuplicate;
  10283. // Initialize against the default document
  10284. setDocument();
  10285. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  10286. // Detached nodes confoundingly follow *each other*
  10287. support.sortDetached = assert(function( el ) {
  10288. // Should return 1, but returns 4 (following)
  10289. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  10290. });
  10291. // Support: IE<8
  10292. // Prevent attribute/property "interpolation"
  10293. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  10294. if ( !assert(function( el ) {
  10295. el.innerHTML = "<a href='#'></a>";
  10296. return el.firstChild.getAttribute("href") === "#" ;
  10297. }) ) {
  10298. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  10299. if ( !isXML ) {
  10300. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  10301. }
  10302. });
  10303. }
  10304. // Support: IE<9
  10305. // Use defaultValue in place of getAttribute("value")
  10306. if ( !support.attributes || !assert(function( el ) {
  10307. el.innerHTML = "<input/>";
  10308. el.firstChild.setAttribute( "value", "" );
  10309. return el.firstChild.getAttribute( "value" ) === "";
  10310. }) ) {
  10311. addHandle( "value", function( elem, name, isXML ) {
  10312. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  10313. return elem.defaultValue;
  10314. }
  10315. });
  10316. }
  10317. // Support: IE<9
  10318. // Use getAttributeNode to fetch booleans when getAttribute lies
  10319. if ( !assert(function( el ) {
  10320. return el.getAttribute("disabled") == null;
  10321. }) ) {
  10322. addHandle( booleans, function( elem, name, isXML ) {
  10323. var val;
  10324. if ( !isXML ) {
  10325. return elem[ name ] === true ? name.toLowerCase() :
  10326. (val = elem.getAttributeNode( name )) && val.specified ?
  10327. val.value :
  10328. null;
  10329. }
  10330. });
  10331. }
  10332. return Sizzle;
  10333. })( window );
  10334. jQuery.find = Sizzle;
  10335. jQuery.expr = Sizzle.selectors;
  10336. // Deprecated
  10337. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  10338. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  10339. jQuery.text = Sizzle.getText;
  10340. jQuery.isXMLDoc = Sizzle.isXML;
  10341. jQuery.contains = Sizzle.contains;
  10342. jQuery.escapeSelector = Sizzle.escape;
  10343. var dir = function( elem, dir, until ) {
  10344. var matched = [],
  10345. truncate = until !== undefined;
  10346. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  10347. if ( elem.nodeType === 1 ) {
  10348. if ( truncate && jQuery( elem ).is( until ) ) {
  10349. break;
  10350. }
  10351. matched.push( elem );
  10352. }
  10353. }
  10354. return matched;
  10355. };
  10356. var siblings = function( n, elem ) {
  10357. var matched = [];
  10358. for ( ; n; n = n.nextSibling ) {
  10359. if ( n.nodeType === 1 && n !== elem ) {
  10360. matched.push( n );
  10361. }
  10362. }
  10363. return matched;
  10364. };
  10365. var rneedsContext = jQuery.expr.match.needsContext;
  10366. function nodeName( elem, name ) {
  10367. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  10368. };
  10369. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  10370. // Implement the identical functionality for filter and not
  10371. function winnow( elements, qualifier, not ) {
  10372. if ( isFunction( qualifier ) ) {
  10373. return jQuery.grep( elements, function( elem, i ) {
  10374. return !!qualifier.call( elem, i, elem ) !== not;
  10375. } );
  10376. }
  10377. // Single element
  10378. if ( qualifier.nodeType ) {
  10379. return jQuery.grep( elements, function( elem ) {
  10380. return ( elem === qualifier ) !== not;
  10381. } );
  10382. }
  10383. // Arraylike of elements (jQuery, arguments, Array)
  10384. if ( typeof qualifier !== "string" ) {
  10385. return jQuery.grep( elements, function( elem ) {
  10386. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  10387. } );
  10388. }
  10389. // Filtered directly for both simple and complex selectors
  10390. return jQuery.filter( qualifier, elements, not );
  10391. }
  10392. jQuery.filter = function( expr, elems, not ) {
  10393. var elem = elems[ 0 ];
  10394. if ( not ) {
  10395. expr = ":not(" + expr + ")";
  10396. }
  10397. if ( elems.length === 1 && elem.nodeType === 1 ) {
  10398. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  10399. }
  10400. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  10401. return elem.nodeType === 1;
  10402. } ) );
  10403. };
  10404. jQuery.fn.extend( {
  10405. find: function( selector ) {
  10406. var i, ret,
  10407. len = this.length,
  10408. self = this;
  10409. if ( typeof selector !== "string" ) {
  10410. return this.pushStack( jQuery( selector ).filter( function() {
  10411. for ( i = 0; i < len; i++ ) {
  10412. if ( jQuery.contains( self[ i ], this ) ) {
  10413. return true;
  10414. }
  10415. }
  10416. } ) );
  10417. }
  10418. ret = this.pushStack( [] );
  10419. for ( i = 0; i < len; i++ ) {
  10420. jQuery.find( selector, self[ i ], ret );
  10421. }
  10422. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  10423. },
  10424. filter: function( selector ) {
  10425. return this.pushStack( winnow( this, selector || [], false ) );
  10426. },
  10427. not: function( selector ) {
  10428. return this.pushStack( winnow( this, selector || [], true ) );
  10429. },
  10430. is: function( selector ) {
  10431. return !!winnow(
  10432. this,
  10433. // If this is a positional/relative selector, check membership in the returned set
  10434. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  10435. typeof selector === "string" && rneedsContext.test( selector ) ?
  10436. jQuery( selector ) :
  10437. selector || [],
  10438. false
  10439. ).length;
  10440. }
  10441. } );
  10442. // Initialize a jQuery object
  10443. // A central reference to the root jQuery(document)
  10444. var rootjQuery,
  10445. // A simple way to check for HTML strings
  10446. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  10447. // Strict HTML recognition (#11290: must start with <)
  10448. // Shortcut simple #id case for speed
  10449. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  10450. init = jQuery.fn.init = function( selector, context, root ) {
  10451. var match, elem;
  10452. // HANDLE: $(""), $(null), $(undefined), $(false)
  10453. if ( !selector ) {
  10454. return this;
  10455. }
  10456. // Method init() accepts an alternate rootjQuery
  10457. // so migrate can support jQuery.sub (gh-2101)
  10458. root = root || rootjQuery;
  10459. // Handle HTML strings
  10460. if ( typeof selector === "string" ) {
  10461. if ( selector[ 0 ] === "<" &&
  10462. selector[ selector.length - 1 ] === ">" &&
  10463. selector.length >= 3 ) {
  10464. // Assume that strings that start and end with <> are HTML and skip the regex check
  10465. match = [ null, selector, null ];
  10466. } else {
  10467. match = rquickExpr.exec( selector );
  10468. }
  10469. // Match html or make sure no context is specified for #id
  10470. if ( match && ( match[ 1 ] || !context ) ) {
  10471. // HANDLE: $(html) -> $(array)
  10472. if ( match[ 1 ] ) {
  10473. context = context instanceof jQuery ? context[ 0 ] : context;
  10474. // Option to run scripts is true for back-compat
  10475. // Intentionally let the error be thrown if parseHTML is not present
  10476. jQuery.merge( this, jQuery.parseHTML(
  10477. match[ 1 ],
  10478. context && context.nodeType ? context.ownerDocument || context : document,
  10479. true
  10480. ) );
  10481. // HANDLE: $(html, props)
  10482. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  10483. for ( match in context ) {
  10484. // Properties of context are called as methods if possible
  10485. if ( isFunction( this[ match ] ) ) {
  10486. this[ match ]( context[ match ] );
  10487. // ...and otherwise set as attributes
  10488. } else {
  10489. this.attr( match, context[ match ] );
  10490. }
  10491. }
  10492. }
  10493. return this;
  10494. // HANDLE: $(#id)
  10495. } else {
  10496. elem = document.getElementById( match[ 2 ] );
  10497. if ( elem ) {
  10498. // Inject the element directly into the jQuery object
  10499. this[ 0 ] = elem;
  10500. this.length = 1;
  10501. }
  10502. return this;
  10503. }
  10504. // HANDLE: $(expr, $(...))
  10505. } else if ( !context || context.jquery ) {
  10506. return ( context || root ).find( selector );
  10507. // HANDLE: $(expr, context)
  10508. // (which is just equivalent to: $(context).find(expr)
  10509. } else {
  10510. return this.constructor( context ).find( selector );
  10511. }
  10512. // HANDLE: $(DOMElement)
  10513. } else if ( selector.nodeType ) {
  10514. this[ 0 ] = selector;
  10515. this.length = 1;
  10516. return this;
  10517. // HANDLE: $(function)
  10518. // Shortcut for document ready
  10519. } else if ( isFunction( selector ) ) {
  10520. return root.ready !== undefined ?
  10521. root.ready( selector ) :
  10522. // Execute immediately if ready is not present
  10523. selector( jQuery );
  10524. }
  10525. return jQuery.makeArray( selector, this );
  10526. };
  10527. // Give the init function the jQuery prototype for later instantiation
  10528. init.prototype = jQuery.fn;
  10529. // Initialize central reference
  10530. rootjQuery = jQuery( document );
  10531. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  10532. // Methods guaranteed to produce a unique set when starting from a unique set
  10533. guaranteedUnique = {
  10534. children: true,
  10535. contents: true,
  10536. next: true,
  10537. prev: true
  10538. };
  10539. jQuery.fn.extend( {
  10540. has: function( target ) {
  10541. var targets = jQuery( target, this ),
  10542. l = targets.length;
  10543. return this.filter( function() {
  10544. var i = 0;
  10545. for ( ; i < l; i++ ) {
  10546. if ( jQuery.contains( this, targets[ i ] ) ) {
  10547. return true;
  10548. }
  10549. }
  10550. } );
  10551. },
  10552. closest: function( selectors, context ) {
  10553. var cur,
  10554. i = 0,
  10555. l = this.length,
  10556. matched = [],
  10557. targets = typeof selectors !== "string" && jQuery( selectors );
  10558. // Positional selectors never match, since there's no _selection_ context
  10559. if ( !rneedsContext.test( selectors ) ) {
  10560. for ( ; i < l; i++ ) {
  10561. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  10562. // Always skip document fragments
  10563. if ( cur.nodeType < 11 && ( targets ?
  10564. targets.index( cur ) > -1 :
  10565. // Don't pass non-elements to Sizzle
  10566. cur.nodeType === 1 &&
  10567. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  10568. matched.push( cur );
  10569. break;
  10570. }
  10571. }
  10572. }
  10573. }
  10574. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  10575. },
  10576. // Determine the position of an element within the set
  10577. index: function( elem ) {
  10578. // No argument, return index in parent
  10579. if ( !elem ) {
  10580. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  10581. }
  10582. // Index in selector
  10583. if ( typeof elem === "string" ) {
  10584. return indexOf.call( jQuery( elem ), this[ 0 ] );
  10585. }
  10586. // Locate the position of the desired element
  10587. return indexOf.call( this,
  10588. // If it receives a jQuery object, the first element is used
  10589. elem.jquery ? elem[ 0 ] : elem
  10590. );
  10591. },
  10592. add: function( selector, context ) {
  10593. return this.pushStack(
  10594. jQuery.uniqueSort(
  10595. jQuery.merge( this.get(), jQuery( selector, context ) )
  10596. )
  10597. );
  10598. },
  10599. addBack: function( selector ) {
  10600. return this.add( selector == null ?
  10601. this.prevObject : this.prevObject.filter( selector )
  10602. );
  10603. }
  10604. } );
  10605. function sibling( cur, dir ) {
  10606. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  10607. return cur;
  10608. }
  10609. jQuery.each( {
  10610. parent: function( elem ) {
  10611. var parent = elem.parentNode;
  10612. return parent && parent.nodeType !== 11 ? parent : null;
  10613. },
  10614. parents: function( elem ) {
  10615. return dir( elem, "parentNode" );
  10616. },
  10617. parentsUntil: function( elem, i, until ) {
  10618. return dir( elem, "parentNode", until );
  10619. },
  10620. next: function( elem ) {
  10621. return sibling( elem, "nextSibling" );
  10622. },
  10623. prev: function( elem ) {
  10624. return sibling( elem, "previousSibling" );
  10625. },
  10626. nextAll: function( elem ) {
  10627. return dir( elem, "nextSibling" );
  10628. },
  10629. prevAll: function( elem ) {
  10630. return dir( elem, "previousSibling" );
  10631. },
  10632. nextUntil: function( elem, i, until ) {
  10633. return dir( elem, "nextSibling", until );
  10634. },
  10635. prevUntil: function( elem, i, until ) {
  10636. return dir( elem, "previousSibling", until );
  10637. },
  10638. siblings: function( elem ) {
  10639. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  10640. },
  10641. children: function( elem ) {
  10642. return siblings( elem.firstChild );
  10643. },
  10644. contents: function( elem ) {
  10645. if ( typeof elem.contentDocument !== "undefined" ) {
  10646. return elem.contentDocument;
  10647. }
  10648. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  10649. // Treat the template element as a regular one in browsers that
  10650. // don't support it.
  10651. if ( nodeName( elem, "template" ) ) {
  10652. elem = elem.content || elem;
  10653. }
  10654. return jQuery.merge( [], elem.childNodes );
  10655. }
  10656. }, function( name, fn ) {
  10657. jQuery.fn[ name ] = function( until, selector ) {
  10658. var matched = jQuery.map( this, fn, until );
  10659. if ( name.slice( -5 ) !== "Until" ) {
  10660. selector = until;
  10661. }
  10662. if ( selector && typeof selector === "string" ) {
  10663. matched = jQuery.filter( selector, matched );
  10664. }
  10665. if ( this.length > 1 ) {
  10666. // Remove duplicates
  10667. if ( !guaranteedUnique[ name ] ) {
  10668. jQuery.uniqueSort( matched );
  10669. }
  10670. // Reverse order for parents* and prev-derivatives
  10671. if ( rparentsprev.test( name ) ) {
  10672. matched.reverse();
  10673. }
  10674. }
  10675. return this.pushStack( matched );
  10676. };
  10677. } );
  10678. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  10679. // Convert String-formatted options into Object-formatted ones
  10680. function createOptions( options ) {
  10681. var object = {};
  10682. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  10683. object[ flag ] = true;
  10684. } );
  10685. return object;
  10686. }
  10687. /*
  10688. * Create a callback list using the following parameters:
  10689. *
  10690. * options: an optional list of space-separated options that will change how
  10691. * the callback list behaves or a more traditional option object
  10692. *
  10693. * By default a callback list will act like an event callback list and can be
  10694. * "fired" multiple times.
  10695. *
  10696. * Possible options:
  10697. *
  10698. * once: will ensure the callback list can only be fired once (like a Deferred)
  10699. *
  10700. * memory: will keep track of previous values and will call any callback added
  10701. * after the list has been fired right away with the latest "memorized"
  10702. * values (like a Deferred)
  10703. *
  10704. * unique: will ensure a callback can only be added once (no duplicate in the list)
  10705. *
  10706. * stopOnFalse: interrupt callings when a callback returns false
  10707. *
  10708. */
  10709. jQuery.Callbacks = function( options ) {
  10710. // Convert options from String-formatted to Object-formatted if needed
  10711. // (we check in cache first)
  10712. options = typeof options === "string" ?
  10713. createOptions( options ) :
  10714. jQuery.extend( {}, options );
  10715. var // Flag to know if list is currently firing
  10716. firing,
  10717. // Last fire value for non-forgettable lists
  10718. memory,
  10719. // Flag to know if list was already fired
  10720. fired,
  10721. // Flag to prevent firing
  10722. locked,
  10723. // Actual callback list
  10724. list = [],
  10725. // Queue of execution data for repeatable lists
  10726. queue = [],
  10727. // Index of currently firing callback (modified by add/remove as needed)
  10728. firingIndex = -1,
  10729. // Fire callbacks
  10730. fire = function() {
  10731. // Enforce single-firing
  10732. locked = locked || options.once;
  10733. // Execute callbacks for all pending executions,
  10734. // respecting firingIndex overrides and runtime changes
  10735. fired = firing = true;
  10736. for ( ; queue.length; firingIndex = -1 ) {
  10737. memory = queue.shift();
  10738. while ( ++firingIndex < list.length ) {
  10739. // Run callback and check for early termination
  10740. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  10741. options.stopOnFalse ) {
  10742. // Jump to end and forget the data so .add doesn't re-fire
  10743. firingIndex = list.length;
  10744. memory = false;
  10745. }
  10746. }
  10747. }
  10748. // Forget the data if we're done with it
  10749. if ( !options.memory ) {
  10750. memory = false;
  10751. }
  10752. firing = false;
  10753. // Clean up if we're done firing for good
  10754. if ( locked ) {
  10755. // Keep an empty list if we have data for future add calls
  10756. if ( memory ) {
  10757. list = [];
  10758. // Otherwise, this object is spent
  10759. } else {
  10760. list = "";
  10761. }
  10762. }
  10763. },
  10764. // Actual Callbacks object
  10765. self = {
  10766. // Add a callback or a collection of callbacks to the list
  10767. add: function() {
  10768. if ( list ) {
  10769. // If we have memory from a past run, we should fire after adding
  10770. if ( memory && !firing ) {
  10771. firingIndex = list.length - 1;
  10772. queue.push( memory );
  10773. }
  10774. ( function add( args ) {
  10775. jQuery.each( args, function( _, arg ) {
  10776. if ( isFunction( arg ) ) {
  10777. if ( !options.unique || !self.has( arg ) ) {
  10778. list.push( arg );
  10779. }
  10780. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  10781. // Inspect recursively
  10782. add( arg );
  10783. }
  10784. } );
  10785. } )( arguments );
  10786. if ( memory && !firing ) {
  10787. fire();
  10788. }
  10789. }
  10790. return this;
  10791. },
  10792. // Remove a callback from the list
  10793. remove: function() {
  10794. jQuery.each( arguments, function( _, arg ) {
  10795. var index;
  10796. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  10797. list.splice( index, 1 );
  10798. // Handle firing indexes
  10799. if ( index <= firingIndex ) {
  10800. firingIndex--;
  10801. }
  10802. }
  10803. } );
  10804. return this;
  10805. },
  10806. // Check if a given callback is in the list.
  10807. // If no argument is given, return whether or not list has callbacks attached.
  10808. has: function( fn ) {
  10809. return fn ?
  10810. jQuery.inArray( fn, list ) > -1 :
  10811. list.length > 0;
  10812. },
  10813. // Remove all callbacks from the list
  10814. empty: function() {
  10815. if ( list ) {
  10816. list = [];
  10817. }
  10818. return this;
  10819. },
  10820. // Disable .fire and .add
  10821. // Abort any current/pending executions
  10822. // Clear all callbacks and values
  10823. disable: function() {
  10824. locked = queue = [];
  10825. list = memory = "";
  10826. return this;
  10827. },
  10828. disabled: function() {
  10829. return !list;
  10830. },
  10831. // Disable .fire
  10832. // Also disable .add unless we have memory (since it would have no effect)
  10833. // Abort any pending executions
  10834. lock: function() {
  10835. locked = queue = [];
  10836. if ( !memory && !firing ) {
  10837. list = memory = "";
  10838. }
  10839. return this;
  10840. },
  10841. locked: function() {
  10842. return !!locked;
  10843. },
  10844. // Call all callbacks with the given context and arguments
  10845. fireWith: function( context, args ) {
  10846. if ( !locked ) {
  10847. args = args || [];
  10848. args = [ context, args.slice ? args.slice() : args ];
  10849. queue.push( args );
  10850. if ( !firing ) {
  10851. fire();
  10852. }
  10853. }
  10854. return this;
  10855. },
  10856. // Call all the callbacks with the given arguments
  10857. fire: function() {
  10858. self.fireWith( this, arguments );
  10859. return this;
  10860. },
  10861. // To know if the callbacks have already been called at least once
  10862. fired: function() {
  10863. return !!fired;
  10864. }
  10865. };
  10866. return self;
  10867. };
  10868. function Identity( v ) {
  10869. return v;
  10870. }
  10871. function Thrower( ex ) {
  10872. throw ex;
  10873. }
  10874. function adoptValue( value, resolve, reject, noValue ) {
  10875. var method;
  10876. try {
  10877. // Check for promise aspect first to privilege synchronous behavior
  10878. if ( value && isFunction( ( method = value.promise ) ) ) {
  10879. method.call( value ).done( resolve ).fail( reject );
  10880. // Other thenables
  10881. } else if ( value && isFunction( ( method = value.then ) ) ) {
  10882. method.call( value, resolve, reject );
  10883. // Other non-thenables
  10884. } else {
  10885. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  10886. // * false: [ value ].slice( 0 ) => resolve( value )
  10887. // * true: [ value ].slice( 1 ) => resolve()
  10888. resolve.apply( undefined, [ value ].slice( noValue ) );
  10889. }
  10890. // For Promises/A+, convert exceptions into rejections
  10891. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  10892. // Deferred#then to conditionally suppress rejection.
  10893. } catch ( value ) {
  10894. // Support: Android 4.0 only
  10895. // Strict mode functions invoked without .call/.apply get global-object context
  10896. reject.apply( undefined, [ value ] );
  10897. }
  10898. }
  10899. jQuery.extend( {
  10900. Deferred: function( func ) {
  10901. var tuples = [
  10902. // action, add listener, callbacks,
  10903. // ... .then handlers, argument index, [final state]
  10904. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  10905. jQuery.Callbacks( "memory" ), 2 ],
  10906. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  10907. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  10908. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  10909. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  10910. ],
  10911. state = "pending",
  10912. promise = {
  10913. state: function() {
  10914. return state;
  10915. },
  10916. always: function() {
  10917. deferred.done( arguments ).fail( arguments );
  10918. return this;
  10919. },
  10920. "catch": function( fn ) {
  10921. return promise.then( null, fn );
  10922. },
  10923. // Keep pipe for back-compat
  10924. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  10925. var fns = arguments;
  10926. return jQuery.Deferred( function( newDefer ) {
  10927. jQuery.each( tuples, function( i, tuple ) {
  10928. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  10929. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  10930. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  10931. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  10932. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  10933. deferred[ tuple[ 1 ] ]( function() {
  10934. var returned = fn && fn.apply( this, arguments );
  10935. if ( returned && isFunction( returned.promise ) ) {
  10936. returned.promise()
  10937. .progress( newDefer.notify )
  10938. .done( newDefer.resolve )
  10939. .fail( newDefer.reject );
  10940. } else {
  10941. newDefer[ tuple[ 0 ] + "With" ](
  10942. this,
  10943. fn ? [ returned ] : arguments
  10944. );
  10945. }
  10946. } );
  10947. } );
  10948. fns = null;
  10949. } ).promise();
  10950. },
  10951. then: function( onFulfilled, onRejected, onProgress ) {
  10952. var maxDepth = 0;
  10953. function resolve( depth, deferred, handler, special ) {
  10954. return function() {
  10955. var that = this,
  10956. args = arguments,
  10957. mightThrow = function() {
  10958. var returned, then;
  10959. // Support: Promises/A+ section 2.3.3.3.3
  10960. // https://promisesaplus.com/#point-59
  10961. // Ignore double-resolution attempts
  10962. if ( depth < maxDepth ) {
  10963. return;
  10964. }
  10965. returned = handler.apply( that, args );
  10966. // Support: Promises/A+ section 2.3.1
  10967. // https://promisesaplus.com/#point-48
  10968. if ( returned === deferred.promise() ) {
  10969. throw new TypeError( "Thenable self-resolution" );
  10970. }
  10971. // Support: Promises/A+ sections 2.3.3.1, 3.5
  10972. // https://promisesaplus.com/#point-54
  10973. // https://promisesaplus.com/#point-75
  10974. // Retrieve `then` only once
  10975. then = returned &&
  10976. // Support: Promises/A+ section 2.3.4
  10977. // https://promisesaplus.com/#point-64
  10978. // Only check objects and functions for thenability
  10979. ( typeof returned === "object" ||
  10980. typeof returned === "function" ) &&
  10981. returned.then;
  10982. // Handle a returned thenable
  10983. if ( isFunction( then ) ) {
  10984. // Special processors (notify) just wait for resolution
  10985. if ( special ) {
  10986. then.call(
  10987. returned,
  10988. resolve( maxDepth, deferred, Identity, special ),
  10989. resolve( maxDepth, deferred, Thrower, special )
  10990. );
  10991. // Normal processors (resolve) also hook into progress
  10992. } else {
  10993. // ...and disregard older resolution values
  10994. maxDepth++;
  10995. then.call(
  10996. returned,
  10997. resolve( maxDepth, deferred, Identity, special ),
  10998. resolve( maxDepth, deferred, Thrower, special ),
  10999. resolve( maxDepth, deferred, Identity,
  11000. deferred.notifyWith )
  11001. );
  11002. }
  11003. // Handle all other returned values
  11004. } else {
  11005. // Only substitute handlers pass on context
  11006. // and multiple values (non-spec behavior)
  11007. if ( handler !== Identity ) {
  11008. that = undefined;
  11009. args = [ returned ];
  11010. }
  11011. // Process the value(s)
  11012. // Default process is resolve
  11013. ( special || deferred.resolveWith )( that, args );
  11014. }
  11015. },
  11016. // Only normal processors (resolve) catch and reject exceptions
  11017. process = special ?
  11018. mightThrow :
  11019. function() {
  11020. try {
  11021. mightThrow();
  11022. } catch ( e ) {
  11023. if ( jQuery.Deferred.exceptionHook ) {
  11024. jQuery.Deferred.exceptionHook( e,
  11025. process.stackTrace );
  11026. }
  11027. // Support: Promises/A+ section 2.3.3.3.4.1
  11028. // https://promisesaplus.com/#point-61
  11029. // Ignore post-resolution exceptions
  11030. if ( depth + 1 >= maxDepth ) {
  11031. // Only substitute handlers pass on context
  11032. // and multiple values (non-spec behavior)
  11033. if ( handler !== Thrower ) {
  11034. that = undefined;
  11035. args = [ e ];
  11036. }
  11037. deferred.rejectWith( that, args );
  11038. }
  11039. }
  11040. };
  11041. // Support: Promises/A+ section 2.3.3.3.1
  11042. // https://promisesaplus.com/#point-57
  11043. // Re-resolve promises immediately to dodge false rejection from
  11044. // subsequent errors
  11045. if ( depth ) {
  11046. process();
  11047. } else {
  11048. // Call an optional hook to record the stack, in case of exception
  11049. // since it's otherwise lost when execution goes async
  11050. if ( jQuery.Deferred.getStackHook ) {
  11051. process.stackTrace = jQuery.Deferred.getStackHook();
  11052. }
  11053. window.setTimeout( process );
  11054. }
  11055. };
  11056. }
  11057. return jQuery.Deferred( function( newDefer ) {
  11058. // progress_handlers.add( ... )
  11059. tuples[ 0 ][ 3 ].add(
  11060. resolve(
  11061. 0,
  11062. newDefer,
  11063. isFunction( onProgress ) ?
  11064. onProgress :
  11065. Identity,
  11066. newDefer.notifyWith
  11067. )
  11068. );
  11069. // fulfilled_handlers.add( ... )
  11070. tuples[ 1 ][ 3 ].add(
  11071. resolve(
  11072. 0,
  11073. newDefer,
  11074. isFunction( onFulfilled ) ?
  11075. onFulfilled :
  11076. Identity
  11077. )
  11078. );
  11079. // rejected_handlers.add( ... )
  11080. tuples[ 2 ][ 3 ].add(
  11081. resolve(
  11082. 0,
  11083. newDefer,
  11084. isFunction( onRejected ) ?
  11085. onRejected :
  11086. Thrower
  11087. )
  11088. );
  11089. } ).promise();
  11090. },
  11091. // Get a promise for this deferred
  11092. // If obj is provided, the promise aspect is added to the object
  11093. promise: function( obj ) {
  11094. return obj != null ? jQuery.extend( obj, promise ) : promise;
  11095. }
  11096. },
  11097. deferred = {};
  11098. // Add list-specific methods
  11099. jQuery.each( tuples, function( i, tuple ) {
  11100. var list = tuple[ 2 ],
  11101. stateString = tuple[ 5 ];
  11102. // promise.progress = list.add
  11103. // promise.done = list.add
  11104. // promise.fail = list.add
  11105. promise[ tuple[ 1 ] ] = list.add;
  11106. // Handle state
  11107. if ( stateString ) {
  11108. list.add(
  11109. function() {
  11110. // state = "resolved" (i.e., fulfilled)
  11111. // state = "rejected"
  11112. state = stateString;
  11113. },
  11114. // rejected_callbacks.disable
  11115. // fulfilled_callbacks.disable
  11116. tuples[ 3 - i ][ 2 ].disable,
  11117. // rejected_handlers.disable
  11118. // fulfilled_handlers.disable
  11119. tuples[ 3 - i ][ 3 ].disable,
  11120. // progress_callbacks.lock
  11121. tuples[ 0 ][ 2 ].lock,
  11122. // progress_handlers.lock
  11123. tuples[ 0 ][ 3 ].lock
  11124. );
  11125. }
  11126. // progress_handlers.fire
  11127. // fulfilled_handlers.fire
  11128. // rejected_handlers.fire
  11129. list.add( tuple[ 3 ].fire );
  11130. // deferred.notify = function() { deferred.notifyWith(...) }
  11131. // deferred.resolve = function() { deferred.resolveWith(...) }
  11132. // deferred.reject = function() { deferred.rejectWith(...) }
  11133. deferred[ tuple[ 0 ] ] = function() {
  11134. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  11135. return this;
  11136. };
  11137. // deferred.notifyWith = list.fireWith
  11138. // deferred.resolveWith = list.fireWith
  11139. // deferred.rejectWith = list.fireWith
  11140. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  11141. } );
  11142. // Make the deferred a promise
  11143. promise.promise( deferred );
  11144. // Call given func if any
  11145. if ( func ) {
  11146. func.call( deferred, deferred );
  11147. }
  11148. // All done!
  11149. return deferred;
  11150. },
  11151. // Deferred helper
  11152. when: function( singleValue ) {
  11153. var
  11154. // count of uncompleted subordinates
  11155. remaining = arguments.length,
  11156. // count of unprocessed arguments
  11157. i = remaining,
  11158. // subordinate fulfillment data
  11159. resolveContexts = Array( i ),
  11160. resolveValues = slice.call( arguments ),
  11161. // the master Deferred
  11162. master = jQuery.Deferred(),
  11163. // subordinate callback factory
  11164. updateFunc = function( i ) {
  11165. return function( value ) {
  11166. resolveContexts[ i ] = this;
  11167. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  11168. if ( !( --remaining ) ) {
  11169. master.resolveWith( resolveContexts, resolveValues );
  11170. }
  11171. };
  11172. };
  11173. // Single- and empty arguments are adopted like Promise.resolve
  11174. if ( remaining <= 1 ) {
  11175. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  11176. !remaining );
  11177. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  11178. if ( master.state() === "pending" ||
  11179. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  11180. return master.then();
  11181. }
  11182. }
  11183. // Multiple arguments are aggregated like Promise.all array elements
  11184. while ( i-- ) {
  11185. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  11186. }
  11187. return master.promise();
  11188. }
  11189. } );
  11190. // These usually indicate a programmer mistake during development,
  11191. // warn about them ASAP rather than swallowing them by default.
  11192. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  11193. jQuery.Deferred.exceptionHook = function( error, stack ) {
  11194. // Support: IE 8 - 9 only
  11195. // Console exists when dev tools are open, which can happen at any time
  11196. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  11197. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  11198. }
  11199. };
  11200. jQuery.readyException = function( error ) {
  11201. window.setTimeout( function() {
  11202. throw error;
  11203. } );
  11204. };
  11205. // The deferred used on DOM ready
  11206. var readyList = jQuery.Deferred();
  11207. jQuery.fn.ready = function( fn ) {
  11208. readyList
  11209. .then( fn )
  11210. // Wrap jQuery.readyException in a function so that the lookup
  11211. // happens at the time of error handling instead of callback
  11212. // registration.
  11213. .catch( function( error ) {
  11214. jQuery.readyException( error );
  11215. } );
  11216. return this;
  11217. };
  11218. jQuery.extend( {
  11219. // Is the DOM ready to be used? Set to true once it occurs.
  11220. isReady: false,
  11221. // A counter to track how many items to wait for before
  11222. // the ready event fires. See #6781
  11223. readyWait: 1,
  11224. // Handle when the DOM is ready
  11225. ready: function( wait ) {
  11226. // Abort if there are pending holds or we're already ready
  11227. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  11228. return;
  11229. }
  11230. // Remember that the DOM is ready
  11231. jQuery.isReady = true;
  11232. // If a normal DOM Ready event fired, decrement, and wait if need be
  11233. if ( wait !== true && --jQuery.readyWait > 0 ) {
  11234. return;
  11235. }
  11236. // If there are functions bound, to execute
  11237. readyList.resolveWith( document, [ jQuery ] );
  11238. }
  11239. } );
  11240. jQuery.ready.then = readyList.then;
  11241. // The ready event handler and self cleanup method
  11242. function completed() {
  11243. document.removeEventListener( "DOMContentLoaded", completed );
  11244. window.removeEventListener( "load", completed );
  11245. jQuery.ready();
  11246. }
  11247. // Catch cases where $(document).ready() is called
  11248. // after the browser event has already occurred.
  11249. // Support: IE <=9 - 10 only
  11250. // Older IE sometimes signals "interactive" too soon
  11251. if ( document.readyState === "complete" ||
  11252. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  11253. // Handle it asynchronously to allow scripts the opportunity to delay ready
  11254. window.setTimeout( jQuery.ready );
  11255. } else {
  11256. // Use the handy event callback
  11257. document.addEventListener( "DOMContentLoaded", completed );
  11258. // A fallback to window.onload, that will always work
  11259. window.addEventListener( "load", completed );
  11260. }
  11261. // Multifunctional method to get and set values of a collection
  11262. // The value/s can optionally be executed if it's a function
  11263. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  11264. var i = 0,
  11265. len = elems.length,
  11266. bulk = key == null;
  11267. // Sets many values
  11268. if ( toType( key ) === "object" ) {
  11269. chainable = true;
  11270. for ( i in key ) {
  11271. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  11272. }
  11273. // Sets one value
  11274. } else if ( value !== undefined ) {
  11275. chainable = true;
  11276. if ( !isFunction( value ) ) {
  11277. raw = true;
  11278. }
  11279. if ( bulk ) {
  11280. // Bulk operations run against the entire set
  11281. if ( raw ) {
  11282. fn.call( elems, value );
  11283. fn = null;
  11284. // ...except when executing function values
  11285. } else {
  11286. bulk = fn;
  11287. fn = function( elem, key, value ) {
  11288. return bulk.call( jQuery( elem ), value );
  11289. };
  11290. }
  11291. }
  11292. if ( fn ) {
  11293. for ( ; i < len; i++ ) {
  11294. fn(
  11295. elems[ i ], key, raw ?
  11296. value :
  11297. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  11298. );
  11299. }
  11300. }
  11301. }
  11302. if ( chainable ) {
  11303. return elems;
  11304. }
  11305. // Gets
  11306. if ( bulk ) {
  11307. return fn.call( elems );
  11308. }
  11309. return len ? fn( elems[ 0 ], key ) : emptyGet;
  11310. };
  11311. // Matches dashed string for camelizing
  11312. var rmsPrefix = /^-ms-/,
  11313. rdashAlpha = /-([a-z])/g;
  11314. // Used by camelCase as callback to replace()
  11315. function fcamelCase( all, letter ) {
  11316. return letter.toUpperCase();
  11317. }
  11318. // Convert dashed to camelCase; used by the css and data modules
  11319. // Support: IE <=9 - 11, Edge 12 - 15
  11320. // Microsoft forgot to hump their vendor prefix (#9572)
  11321. function camelCase( string ) {
  11322. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  11323. }
  11324. var acceptData = function( owner ) {
  11325. // Accepts only:
  11326. // - Node
  11327. // - Node.ELEMENT_NODE
  11328. // - Node.DOCUMENT_NODE
  11329. // - Object
  11330. // - Any
  11331. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  11332. };
  11333. function Data() {
  11334. this.expando = jQuery.expando + Data.uid++;
  11335. }
  11336. Data.uid = 1;
  11337. Data.prototype = {
  11338. cache: function( owner ) {
  11339. // Check if the owner object already has a cache
  11340. var value = owner[ this.expando ];
  11341. // If not, create one
  11342. if ( !value ) {
  11343. value = {};
  11344. // We can accept data for non-element nodes in modern browsers,
  11345. // but we should not, see #8335.
  11346. // Always return an empty object.
  11347. if ( acceptData( owner ) ) {
  11348. // If it is a node unlikely to be stringify-ed or looped over
  11349. // use plain assignment
  11350. if ( owner.nodeType ) {
  11351. owner[ this.expando ] = value;
  11352. // Otherwise secure it in a non-enumerable property
  11353. // configurable must be true to allow the property to be
  11354. // deleted when data is removed
  11355. } else {
  11356. Object.defineProperty( owner, this.expando, {
  11357. value: value,
  11358. configurable: true
  11359. } );
  11360. }
  11361. }
  11362. }
  11363. return value;
  11364. },
  11365. set: function( owner, data, value ) {
  11366. var prop,
  11367. cache = this.cache( owner );
  11368. // Handle: [ owner, key, value ] args
  11369. // Always use camelCase key (gh-2257)
  11370. if ( typeof data === "string" ) {
  11371. cache[ camelCase( data ) ] = value;
  11372. // Handle: [ owner, { properties } ] args
  11373. } else {
  11374. // Copy the properties one-by-one to the cache object
  11375. for ( prop in data ) {
  11376. cache[ camelCase( prop ) ] = data[ prop ];
  11377. }
  11378. }
  11379. return cache;
  11380. },
  11381. get: function( owner, key ) {
  11382. return key === undefined ?
  11383. this.cache( owner ) :
  11384. // Always use camelCase key (gh-2257)
  11385. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  11386. },
  11387. access: function( owner, key, value ) {
  11388. // In cases where either:
  11389. //
  11390. // 1. No key was specified
  11391. // 2. A string key was specified, but no value provided
  11392. //
  11393. // Take the "read" path and allow the get method to determine
  11394. // which value to return, respectively either:
  11395. //
  11396. // 1. The entire cache object
  11397. // 2. The data stored at the key
  11398. //
  11399. if ( key === undefined ||
  11400. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  11401. return this.get( owner, key );
  11402. }
  11403. // When the key is not a string, or both a key and value
  11404. // are specified, set or extend (existing objects) with either:
  11405. //
  11406. // 1. An object of properties
  11407. // 2. A key and value
  11408. //
  11409. this.set( owner, key, value );
  11410. // Since the "set" path can have two possible entry points
  11411. // return the expected data based on which path was taken[*]
  11412. return value !== undefined ? value : key;
  11413. },
  11414. remove: function( owner, key ) {
  11415. var i,
  11416. cache = owner[ this.expando ];
  11417. if ( cache === undefined ) {
  11418. return;
  11419. }
  11420. if ( key !== undefined ) {
  11421. // Support array or space separated string of keys
  11422. if ( Array.isArray( key ) ) {
  11423. // If key is an array of keys...
  11424. // We always set camelCase keys, so remove that.
  11425. key = key.map( camelCase );
  11426. } else {
  11427. key = camelCase( key );
  11428. // If a key with the spaces exists, use it.
  11429. // Otherwise, create an array by matching non-whitespace
  11430. key = key in cache ?
  11431. [ key ] :
  11432. ( key.match( rnothtmlwhite ) || [] );
  11433. }
  11434. i = key.length;
  11435. while ( i-- ) {
  11436. delete cache[ key[ i ] ];
  11437. }
  11438. }
  11439. // Remove the expando if there's no more data
  11440. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  11441. // Support: Chrome <=35 - 45
  11442. // Webkit & Blink performance suffers when deleting properties
  11443. // from DOM nodes, so set to undefined instead
  11444. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  11445. if ( owner.nodeType ) {
  11446. owner[ this.expando ] = undefined;
  11447. } else {
  11448. delete owner[ this.expando ];
  11449. }
  11450. }
  11451. },
  11452. hasData: function( owner ) {
  11453. var cache = owner[ this.expando ];
  11454. return cache !== undefined && !jQuery.isEmptyObject( cache );
  11455. }
  11456. };
  11457. var dataPriv = new Data();
  11458. var dataUser = new Data();
  11459. // Implementation Summary
  11460. //
  11461. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  11462. // 2. Improve the module's maintainability by reducing the storage
  11463. // paths to a single mechanism.
  11464. // 3. Use the same single mechanism to support "private" and "user" data.
  11465. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  11466. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  11467. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  11468. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  11469. rmultiDash = /[A-Z]/g;
  11470. function getData( data ) {
  11471. if ( data === "true" ) {
  11472. return true;
  11473. }
  11474. if ( data === "false" ) {
  11475. return false;
  11476. }
  11477. if ( data === "null" ) {
  11478. return null;
  11479. }
  11480. // Only convert to a number if it doesn't change the string
  11481. if ( data === +data + "" ) {
  11482. return +data;
  11483. }
  11484. if ( rbrace.test( data ) ) {
  11485. return JSON.parse( data );
  11486. }
  11487. return data;
  11488. }
  11489. function dataAttr( elem, key, data ) {
  11490. var name;
  11491. // If nothing was found internally, try to fetch any
  11492. // data from the HTML5 data-* attribute
  11493. if ( data === undefined && elem.nodeType === 1 ) {
  11494. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  11495. data = elem.getAttribute( name );
  11496. if ( typeof data === "string" ) {
  11497. try {
  11498. data = getData( data );
  11499. } catch ( e ) {}
  11500. // Make sure we set the data so it isn't changed later
  11501. dataUser.set( elem, key, data );
  11502. } else {
  11503. data = undefined;
  11504. }
  11505. }
  11506. return data;
  11507. }
  11508. jQuery.extend( {
  11509. hasData: function( elem ) {
  11510. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  11511. },
  11512. data: function( elem, name, data ) {
  11513. return dataUser.access( elem, name, data );
  11514. },
  11515. removeData: function( elem, name ) {
  11516. dataUser.remove( elem, name );
  11517. },
  11518. // TODO: Now that all calls to _data and _removeData have been replaced
  11519. // with direct calls to dataPriv methods, these can be deprecated.
  11520. _data: function( elem, name, data ) {
  11521. return dataPriv.access( elem, name, data );
  11522. },
  11523. _removeData: function( elem, name ) {
  11524. dataPriv.remove( elem, name );
  11525. }
  11526. } );
  11527. jQuery.fn.extend( {
  11528. data: function( key, value ) {
  11529. var i, name, data,
  11530. elem = this[ 0 ],
  11531. attrs = elem && elem.attributes;
  11532. // Gets all values
  11533. if ( key === undefined ) {
  11534. if ( this.length ) {
  11535. data = dataUser.get( elem );
  11536. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  11537. i = attrs.length;
  11538. while ( i-- ) {
  11539. // Support: IE 11 only
  11540. // The attrs elements can be null (#14894)
  11541. if ( attrs[ i ] ) {
  11542. name = attrs[ i ].name;
  11543. if ( name.indexOf( "data-" ) === 0 ) {
  11544. name = camelCase( name.slice( 5 ) );
  11545. dataAttr( elem, name, data[ name ] );
  11546. }
  11547. }
  11548. }
  11549. dataPriv.set( elem, "hasDataAttrs", true );
  11550. }
  11551. }
  11552. return data;
  11553. }
  11554. // Sets multiple values
  11555. if ( typeof key === "object" ) {
  11556. return this.each( function() {
  11557. dataUser.set( this, key );
  11558. } );
  11559. }
  11560. return access( this, function( value ) {
  11561. var data;
  11562. // The calling jQuery object (element matches) is not empty
  11563. // (and therefore has an element appears at this[ 0 ]) and the
  11564. // `value` parameter was not undefined. An empty jQuery object
  11565. // will result in `undefined` for elem = this[ 0 ] which will
  11566. // throw an exception if an attempt to read a data cache is made.
  11567. if ( elem && value === undefined ) {
  11568. // Attempt to get data from the cache
  11569. // The key will always be camelCased in Data
  11570. data = dataUser.get( elem, key );
  11571. if ( data !== undefined ) {
  11572. return data;
  11573. }
  11574. // Attempt to "discover" the data in
  11575. // HTML5 custom data-* attrs
  11576. data = dataAttr( elem, key );
  11577. if ( data !== undefined ) {
  11578. return data;
  11579. }
  11580. // We tried really hard, but the data doesn't exist.
  11581. return;
  11582. }
  11583. // Set the data...
  11584. this.each( function() {
  11585. // We always store the camelCased key
  11586. dataUser.set( this, key, value );
  11587. } );
  11588. }, null, value, arguments.length > 1, null, true );
  11589. },
  11590. removeData: function( key ) {
  11591. return this.each( function() {
  11592. dataUser.remove( this, key );
  11593. } );
  11594. }
  11595. } );
  11596. jQuery.extend( {
  11597. queue: function( elem, type, data ) {
  11598. var queue;
  11599. if ( elem ) {
  11600. type = ( type || "fx" ) + "queue";
  11601. queue = dataPriv.get( elem, type );
  11602. // Speed up dequeue by getting out quickly if this is just a lookup
  11603. if ( data ) {
  11604. if ( !queue || Array.isArray( data ) ) {
  11605. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  11606. } else {
  11607. queue.push( data );
  11608. }
  11609. }
  11610. return queue || [];
  11611. }
  11612. },
  11613. dequeue: function( elem, type ) {
  11614. type = type || "fx";
  11615. var queue = jQuery.queue( elem, type ),
  11616. startLength = queue.length,
  11617. fn = queue.shift(),
  11618. hooks = jQuery._queueHooks( elem, type ),
  11619. next = function() {
  11620. jQuery.dequeue( elem, type );
  11621. };
  11622. // If the fx queue is dequeued, always remove the progress sentinel
  11623. if ( fn === "inprogress" ) {
  11624. fn = queue.shift();
  11625. startLength--;
  11626. }
  11627. if ( fn ) {
  11628. // Add a progress sentinel to prevent the fx queue from being
  11629. // automatically dequeued
  11630. if ( type === "fx" ) {
  11631. queue.unshift( "inprogress" );
  11632. }
  11633. // Clear up the last queue stop function
  11634. delete hooks.stop;
  11635. fn.call( elem, next, hooks );
  11636. }
  11637. if ( !startLength && hooks ) {
  11638. hooks.empty.fire();
  11639. }
  11640. },
  11641. // Not public - generate a queueHooks object, or return the current one
  11642. _queueHooks: function( elem, type ) {
  11643. var key = type + "queueHooks";
  11644. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  11645. empty: jQuery.Callbacks( "once memory" ).add( function() {
  11646. dataPriv.remove( elem, [ type + "queue", key ] );
  11647. } )
  11648. } );
  11649. }
  11650. } );
  11651. jQuery.fn.extend( {
  11652. queue: function( type, data ) {
  11653. var setter = 2;
  11654. if ( typeof type !== "string" ) {
  11655. data = type;
  11656. type = "fx";
  11657. setter--;
  11658. }
  11659. if ( arguments.length < setter ) {
  11660. return jQuery.queue( this[ 0 ], type );
  11661. }
  11662. return data === undefined ?
  11663. this :
  11664. this.each( function() {
  11665. var queue = jQuery.queue( this, type, data );
  11666. // Ensure a hooks for this queue
  11667. jQuery._queueHooks( this, type );
  11668. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  11669. jQuery.dequeue( this, type );
  11670. }
  11671. } );
  11672. },
  11673. dequeue: function( type ) {
  11674. return this.each( function() {
  11675. jQuery.dequeue( this, type );
  11676. } );
  11677. },
  11678. clearQueue: function( type ) {
  11679. return this.queue( type || "fx", [] );
  11680. },
  11681. // Get a promise resolved when queues of a certain type
  11682. // are emptied (fx is the type by default)
  11683. promise: function( type, obj ) {
  11684. var tmp,
  11685. count = 1,
  11686. defer = jQuery.Deferred(),
  11687. elements = this,
  11688. i = this.length,
  11689. resolve = function() {
  11690. if ( !( --count ) ) {
  11691. defer.resolveWith( elements, [ elements ] );
  11692. }
  11693. };
  11694. if ( typeof type !== "string" ) {
  11695. obj = type;
  11696. type = undefined;
  11697. }
  11698. type = type || "fx";
  11699. while ( i-- ) {
  11700. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  11701. if ( tmp && tmp.empty ) {
  11702. count++;
  11703. tmp.empty.add( resolve );
  11704. }
  11705. }
  11706. resolve();
  11707. return defer.promise( obj );
  11708. }
  11709. } );
  11710. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  11711. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  11712. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  11713. var documentElement = document.documentElement;
  11714. var isAttached = function( elem ) {
  11715. return jQuery.contains( elem.ownerDocument, elem );
  11716. },
  11717. composed = { composed: true };
  11718. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  11719. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  11720. // Support: iOS 10.0-10.2 only
  11721. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  11722. // leading to errors. We need to check for `getRootNode`.
  11723. if ( documentElement.getRootNode ) {
  11724. isAttached = function( elem ) {
  11725. return jQuery.contains( elem.ownerDocument, elem ) ||
  11726. elem.getRootNode( composed ) === elem.ownerDocument;
  11727. };
  11728. }
  11729. var isHiddenWithinTree = function( elem, el ) {
  11730. // isHiddenWithinTree might be called from jQuery#filter function;
  11731. // in that case, element will be second argument
  11732. elem = el || elem;
  11733. // Inline style trumps all
  11734. return elem.style.display === "none" ||
  11735. elem.style.display === "" &&
  11736. // Otherwise, check computed style
  11737. // Support: Firefox <=43 - 45
  11738. // Disconnected elements can have computed display: none, so first confirm that elem is
  11739. // in the document.
  11740. isAttached( elem ) &&
  11741. jQuery.css( elem, "display" ) === "none";
  11742. };
  11743. var swap = function( elem, options, callback, args ) {
  11744. var ret, name,
  11745. old = {};
  11746. // Remember the old values, and insert the new ones
  11747. for ( name in options ) {
  11748. old[ name ] = elem.style[ name ];
  11749. elem.style[ name ] = options[ name ];
  11750. }
  11751. ret = callback.apply( elem, args || [] );
  11752. // Revert the old values
  11753. for ( name in options ) {
  11754. elem.style[ name ] = old[ name ];
  11755. }
  11756. return ret;
  11757. };
  11758. function adjustCSS( elem, prop, valueParts, tween ) {
  11759. var adjusted, scale,
  11760. maxIterations = 20,
  11761. currentValue = tween ?
  11762. function() {
  11763. return tween.cur();
  11764. } :
  11765. function() {
  11766. return jQuery.css( elem, prop, "" );
  11767. },
  11768. initial = currentValue(),
  11769. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  11770. // Starting value computation is required for potential unit mismatches
  11771. initialInUnit = elem.nodeType &&
  11772. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  11773. rcssNum.exec( jQuery.css( elem, prop ) );
  11774. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  11775. // Support: Firefox <=54
  11776. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  11777. initial = initial / 2;
  11778. // Trust units reported by jQuery.css
  11779. unit = unit || initialInUnit[ 3 ];
  11780. // Iteratively approximate from a nonzero starting point
  11781. initialInUnit = +initial || 1;
  11782. while ( maxIterations-- ) {
  11783. // Evaluate and update our best guess (doubling guesses that zero out).
  11784. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  11785. jQuery.style( elem, prop, initialInUnit + unit );
  11786. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  11787. maxIterations = 0;
  11788. }
  11789. initialInUnit = initialInUnit / scale;
  11790. }
  11791. initialInUnit = initialInUnit * 2;
  11792. jQuery.style( elem, prop, initialInUnit + unit );
  11793. // Make sure we update the tween properties later on
  11794. valueParts = valueParts || [];
  11795. }
  11796. if ( valueParts ) {
  11797. initialInUnit = +initialInUnit || +initial || 0;
  11798. // Apply relative offset (+=/-=) if specified
  11799. adjusted = valueParts[ 1 ] ?
  11800. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  11801. +valueParts[ 2 ];
  11802. if ( tween ) {
  11803. tween.unit = unit;
  11804. tween.start = initialInUnit;
  11805. tween.end = adjusted;
  11806. }
  11807. }
  11808. return adjusted;
  11809. }
  11810. var defaultDisplayMap = {};
  11811. function getDefaultDisplay( elem ) {
  11812. var temp,
  11813. doc = elem.ownerDocument,
  11814. nodeName = elem.nodeName,
  11815. display = defaultDisplayMap[ nodeName ];
  11816. if ( display ) {
  11817. return display;
  11818. }
  11819. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  11820. display = jQuery.css( temp, "display" );
  11821. temp.parentNode.removeChild( temp );
  11822. if ( display === "none" ) {
  11823. display = "block";
  11824. }
  11825. defaultDisplayMap[ nodeName ] = display;
  11826. return display;
  11827. }
  11828. function showHide( elements, show ) {
  11829. var display, elem,
  11830. values = [],
  11831. index = 0,
  11832. length = elements.length;
  11833. // Determine new display value for elements that need to change
  11834. for ( ; index < length; index++ ) {
  11835. elem = elements[ index ];
  11836. if ( !elem.style ) {
  11837. continue;
  11838. }
  11839. display = elem.style.display;
  11840. if ( show ) {
  11841. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  11842. // check is required in this first loop unless we have a nonempty display value (either
  11843. // inline or about-to-be-restored)
  11844. if ( display === "none" ) {
  11845. values[ index ] = dataPriv.get( elem, "display" ) || null;
  11846. if ( !values[ index ] ) {
  11847. elem.style.display = "";
  11848. }
  11849. }
  11850. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  11851. values[ index ] = getDefaultDisplay( elem );
  11852. }
  11853. } else {
  11854. if ( display !== "none" ) {
  11855. values[ index ] = "none";
  11856. // Remember what we're overwriting
  11857. dataPriv.set( elem, "display", display );
  11858. }
  11859. }
  11860. }
  11861. // Set the display of the elements in a second loop to avoid constant reflow
  11862. for ( index = 0; index < length; index++ ) {
  11863. if ( values[ index ] != null ) {
  11864. elements[ index ].style.display = values[ index ];
  11865. }
  11866. }
  11867. return elements;
  11868. }
  11869. jQuery.fn.extend( {
  11870. show: function() {
  11871. return showHide( this, true );
  11872. },
  11873. hide: function() {
  11874. return showHide( this );
  11875. },
  11876. toggle: function( state ) {
  11877. if ( typeof state === "boolean" ) {
  11878. return state ? this.show() : this.hide();
  11879. }
  11880. return this.each( function() {
  11881. if ( isHiddenWithinTree( this ) ) {
  11882. jQuery( this ).show();
  11883. } else {
  11884. jQuery( this ).hide();
  11885. }
  11886. } );
  11887. }
  11888. } );
  11889. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  11890. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  11891. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  11892. // We have to close these tags to support XHTML (#13200)
  11893. var wrapMap = {
  11894. // Support: IE <=9 only
  11895. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  11896. // XHTML parsers do not magically insert elements in the
  11897. // same way that tag soup parsers do. So we cannot shorten
  11898. // this by omitting <tbody> or other required elements.
  11899. thead: [ 1, "<table>", "</table>" ],
  11900. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  11901. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  11902. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  11903. _default: [ 0, "", "" ]
  11904. };
  11905. // Support: IE <=9 only
  11906. wrapMap.optgroup = wrapMap.option;
  11907. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  11908. wrapMap.th = wrapMap.td;
  11909. function getAll( context, tag ) {
  11910. // Support: IE <=9 - 11 only
  11911. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  11912. var ret;
  11913. if ( typeof context.getElementsByTagName !== "undefined" ) {
  11914. ret = context.getElementsByTagName( tag || "*" );
  11915. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  11916. ret = context.querySelectorAll( tag || "*" );
  11917. } else {
  11918. ret = [];
  11919. }
  11920. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  11921. return jQuery.merge( [ context ], ret );
  11922. }
  11923. return ret;
  11924. }
  11925. // Mark scripts as having already been evaluated
  11926. function setGlobalEval( elems, refElements ) {
  11927. var i = 0,
  11928. l = elems.length;
  11929. for ( ; i < l; i++ ) {
  11930. dataPriv.set(
  11931. elems[ i ],
  11932. "globalEval",
  11933. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  11934. );
  11935. }
  11936. }
  11937. var rhtml = /<|&#?\w+;/;
  11938. function buildFragment( elems, context, scripts, selection, ignored ) {
  11939. var elem, tmp, tag, wrap, attached, j,
  11940. fragment = context.createDocumentFragment(),
  11941. nodes = [],
  11942. i = 0,
  11943. l = elems.length;
  11944. for ( ; i < l; i++ ) {
  11945. elem = elems[ i ];
  11946. if ( elem || elem === 0 ) {
  11947. // Add nodes directly
  11948. if ( toType( elem ) === "object" ) {
  11949. // Support: Android <=4.0 only, PhantomJS 1 only
  11950. // push.apply(_, arraylike) throws on ancient WebKit
  11951. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  11952. // Convert non-html into a text node
  11953. } else if ( !rhtml.test( elem ) ) {
  11954. nodes.push( context.createTextNode( elem ) );
  11955. // Convert html into DOM nodes
  11956. } else {
  11957. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  11958. // Deserialize a standard representation
  11959. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  11960. wrap = wrapMap[ tag ] || wrapMap._default;
  11961. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  11962. // Descend through wrappers to the right content
  11963. j = wrap[ 0 ];
  11964. while ( j-- ) {
  11965. tmp = tmp.lastChild;
  11966. }
  11967. // Support: Android <=4.0 only, PhantomJS 1 only
  11968. // push.apply(_, arraylike) throws on ancient WebKit
  11969. jQuery.merge( nodes, tmp.childNodes );
  11970. // Remember the top-level container
  11971. tmp = fragment.firstChild;
  11972. // Ensure the created nodes are orphaned (#12392)
  11973. tmp.textContent = "";
  11974. }
  11975. }
  11976. }
  11977. // Remove wrapper from fragment
  11978. fragment.textContent = "";
  11979. i = 0;
  11980. while ( ( elem = nodes[ i++ ] ) ) {
  11981. // Skip elements already in the context collection (trac-4087)
  11982. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  11983. if ( ignored ) {
  11984. ignored.push( elem );
  11985. }
  11986. continue;
  11987. }
  11988. attached = isAttached( elem );
  11989. // Append to fragment
  11990. tmp = getAll( fragment.appendChild( elem ), "script" );
  11991. // Preserve script evaluation history
  11992. if ( attached ) {
  11993. setGlobalEval( tmp );
  11994. }
  11995. // Capture executables
  11996. if ( scripts ) {
  11997. j = 0;
  11998. while ( ( elem = tmp[ j++ ] ) ) {
  11999. if ( rscriptType.test( elem.type || "" ) ) {
  12000. scripts.push( elem );
  12001. }
  12002. }
  12003. }
  12004. }
  12005. return fragment;
  12006. }
  12007. ( function() {
  12008. var fragment = document.createDocumentFragment(),
  12009. div = fragment.appendChild( document.createElement( "div" ) ),
  12010. input = document.createElement( "input" );
  12011. // Support: Android 4.0 - 4.3 only
  12012. // Check state lost if the name is set (#11217)
  12013. // Support: Windows Web Apps (WWA)
  12014. // `name` and `type` must use .setAttribute for WWA (#14901)
  12015. input.setAttribute( "type", "radio" );
  12016. input.setAttribute( "checked", "checked" );
  12017. input.setAttribute( "name", "t" );
  12018. div.appendChild( input );
  12019. // Support: Android <=4.1 only
  12020. // Older WebKit doesn't clone checked state correctly in fragments
  12021. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  12022. // Support: IE <=11 only
  12023. // Make sure textarea (and checkbox) defaultValue is properly cloned
  12024. div.innerHTML = "<textarea>x</textarea>";
  12025. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  12026. } )();
  12027. var
  12028. rkeyEvent = /^key/,
  12029. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  12030. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  12031. function returnTrue() {
  12032. return true;
  12033. }
  12034. function returnFalse() {
  12035. return false;
  12036. }
  12037. // Support: IE <=9 - 11+
  12038. // focus() and blur() are asynchronous, except when they are no-op.
  12039. // So expect focus to be synchronous when the element is already active,
  12040. // and blur to be synchronous when the element is not already active.
  12041. // (focus and blur are always synchronous in other supported browsers,
  12042. // this just defines when we can count on it).
  12043. function expectSync( elem, type ) {
  12044. return ( elem === safeActiveElement() ) === ( type === "focus" );
  12045. }
  12046. // Support: IE <=9 only
  12047. // Accessing document.activeElement can throw unexpectedly
  12048. // https://bugs.jquery.com/ticket/13393
  12049. function safeActiveElement() {
  12050. try {
  12051. return document.activeElement;
  12052. } catch ( err ) { }
  12053. }
  12054. function on( elem, types, selector, data, fn, one ) {
  12055. var origFn, type;
  12056. // Types can be a map of types/handlers
  12057. if ( typeof types === "object" ) {
  12058. // ( types-Object, selector, data )
  12059. if ( typeof selector !== "string" ) {
  12060. // ( types-Object, data )
  12061. data = data || selector;
  12062. selector = undefined;
  12063. }
  12064. for ( type in types ) {
  12065. on( elem, type, selector, data, types[ type ], one );
  12066. }
  12067. return elem;
  12068. }
  12069. if ( data == null && fn == null ) {
  12070. // ( types, fn )
  12071. fn = selector;
  12072. data = selector = undefined;
  12073. } else if ( fn == null ) {
  12074. if ( typeof selector === "string" ) {
  12075. // ( types, selector, fn )
  12076. fn = data;
  12077. data = undefined;
  12078. } else {
  12079. // ( types, data, fn )
  12080. fn = data;
  12081. data = selector;
  12082. selector = undefined;
  12083. }
  12084. }
  12085. if ( fn === false ) {
  12086. fn = returnFalse;
  12087. } else if ( !fn ) {
  12088. return elem;
  12089. }
  12090. if ( one === 1 ) {
  12091. origFn = fn;
  12092. fn = function( event ) {
  12093. // Can use an empty set, since event contains the info
  12094. jQuery().off( event );
  12095. return origFn.apply( this, arguments );
  12096. };
  12097. // Use same guid so caller can remove using origFn
  12098. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  12099. }
  12100. return elem.each( function() {
  12101. jQuery.event.add( this, types, fn, data, selector );
  12102. } );
  12103. }
  12104. /*
  12105. * Helper functions for managing events -- not part of the public interface.
  12106. * Props to Dean Edwards' addEvent library for many of the ideas.
  12107. */
  12108. jQuery.event = {
  12109. global: {},
  12110. add: function( elem, types, handler, data, selector ) {
  12111. var handleObjIn, eventHandle, tmp,
  12112. events, t, handleObj,
  12113. special, handlers, type, namespaces, origType,
  12114. elemData = dataPriv.get( elem );
  12115. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  12116. if ( !elemData ) {
  12117. return;
  12118. }
  12119. // Caller can pass in an object of custom data in lieu of the handler
  12120. if ( handler.handler ) {
  12121. handleObjIn = handler;
  12122. handler = handleObjIn.handler;
  12123. selector = handleObjIn.selector;
  12124. }
  12125. // Ensure that invalid selectors throw exceptions at attach time
  12126. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  12127. if ( selector ) {
  12128. jQuery.find.matchesSelector( documentElement, selector );
  12129. }
  12130. // Make sure that the handler has a unique ID, used to find/remove it later
  12131. if ( !handler.guid ) {
  12132. handler.guid = jQuery.guid++;
  12133. }
  12134. // Init the element's event structure and main handler, if this is the first
  12135. if ( !( events = elemData.events ) ) {
  12136. events = elemData.events = {};
  12137. }
  12138. if ( !( eventHandle = elemData.handle ) ) {
  12139. eventHandle = elemData.handle = function( e ) {
  12140. // Discard the second event of a jQuery.event.trigger() and
  12141. // when an event is called after a page has unloaded
  12142. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  12143. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  12144. };
  12145. }
  12146. // Handle multiple events separated by a space
  12147. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  12148. t = types.length;
  12149. while ( t-- ) {
  12150. tmp = rtypenamespace.exec( types[ t ] ) || [];
  12151. type = origType = tmp[ 1 ];
  12152. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  12153. // There *must* be a type, no attaching namespace-only handlers
  12154. if ( !type ) {
  12155. continue;
  12156. }
  12157. // If event changes its type, use the special event handlers for the changed type
  12158. special = jQuery.event.special[ type ] || {};
  12159. // If selector defined, determine special event api type, otherwise given type
  12160. type = ( selector ? special.delegateType : special.bindType ) || type;
  12161. // Update special based on newly reset type
  12162. special = jQuery.event.special[ type ] || {};
  12163. // handleObj is passed to all event handlers
  12164. handleObj = jQuery.extend( {
  12165. type: type,
  12166. origType: origType,
  12167. data: data,
  12168. handler: handler,
  12169. guid: handler.guid,
  12170. selector: selector,
  12171. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  12172. namespace: namespaces.join( "." )
  12173. }, handleObjIn );
  12174. // Init the event handler queue if we're the first
  12175. if ( !( handlers = events[ type ] ) ) {
  12176. handlers = events[ type ] = [];
  12177. handlers.delegateCount = 0;
  12178. // Only use addEventListener if the special events handler returns false
  12179. if ( !special.setup ||
  12180. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  12181. if ( elem.addEventListener ) {
  12182. elem.addEventListener( type, eventHandle );
  12183. }
  12184. }
  12185. }
  12186. if ( special.add ) {
  12187. special.add.call( elem, handleObj );
  12188. if ( !handleObj.handler.guid ) {
  12189. handleObj.handler.guid = handler.guid;
  12190. }
  12191. }
  12192. // Add to the element's handler list, delegates in front
  12193. if ( selector ) {
  12194. handlers.splice( handlers.delegateCount++, 0, handleObj );
  12195. } else {
  12196. handlers.push( handleObj );
  12197. }
  12198. // Keep track of which events have ever been used, for event optimization
  12199. jQuery.event.global[ type ] = true;
  12200. }
  12201. },
  12202. // Detach an event or set of events from an element
  12203. remove: function( elem, types, handler, selector, mappedTypes ) {
  12204. var j, origCount, tmp,
  12205. events, t, handleObj,
  12206. special, handlers, type, namespaces, origType,
  12207. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  12208. if ( !elemData || !( events = elemData.events ) ) {
  12209. return;
  12210. }
  12211. // Once for each type.namespace in types; type may be omitted
  12212. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  12213. t = types.length;
  12214. while ( t-- ) {
  12215. tmp = rtypenamespace.exec( types[ t ] ) || [];
  12216. type = origType = tmp[ 1 ];
  12217. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  12218. // Unbind all events (on this namespace, if provided) for the element
  12219. if ( !type ) {
  12220. for ( type in events ) {
  12221. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  12222. }
  12223. continue;
  12224. }
  12225. special = jQuery.event.special[ type ] || {};
  12226. type = ( selector ? special.delegateType : special.bindType ) || type;
  12227. handlers = events[ type ] || [];
  12228. tmp = tmp[ 2 ] &&
  12229. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  12230. // Remove matching events
  12231. origCount = j = handlers.length;
  12232. while ( j-- ) {
  12233. handleObj = handlers[ j ];
  12234. if ( ( mappedTypes || origType === handleObj.origType ) &&
  12235. ( !handler || handler.guid === handleObj.guid ) &&
  12236. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  12237. ( !selector || selector === handleObj.selector ||
  12238. selector === "**" && handleObj.selector ) ) {
  12239. handlers.splice( j, 1 );
  12240. if ( handleObj.selector ) {
  12241. handlers.delegateCount--;
  12242. }
  12243. if ( special.remove ) {
  12244. special.remove.call( elem, handleObj );
  12245. }
  12246. }
  12247. }
  12248. // Remove generic event handler if we removed something and no more handlers exist
  12249. // (avoids potential for endless recursion during removal of special event handlers)
  12250. if ( origCount && !handlers.length ) {
  12251. if ( !special.teardown ||
  12252. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  12253. jQuery.removeEvent( elem, type, elemData.handle );
  12254. }
  12255. delete events[ type ];
  12256. }
  12257. }
  12258. // Remove data and the expando if it's no longer used
  12259. if ( jQuery.isEmptyObject( events ) ) {
  12260. dataPriv.remove( elem, "handle events" );
  12261. }
  12262. },
  12263. dispatch: function( nativeEvent ) {
  12264. // Make a writable jQuery.Event from the native event object
  12265. var event = jQuery.event.fix( nativeEvent );
  12266. var i, j, ret, matched, handleObj, handlerQueue,
  12267. args = new Array( arguments.length ),
  12268. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  12269. special = jQuery.event.special[ event.type ] || {};
  12270. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  12271. args[ 0 ] = event;
  12272. for ( i = 1; i < arguments.length; i++ ) {
  12273. args[ i ] = arguments[ i ];
  12274. }
  12275. event.delegateTarget = this;
  12276. // Call the preDispatch hook for the mapped type, and let it bail if desired
  12277. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  12278. return;
  12279. }
  12280. // Determine handlers
  12281. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  12282. // Run delegates first; they may want to stop propagation beneath us
  12283. i = 0;
  12284. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  12285. event.currentTarget = matched.elem;
  12286. j = 0;
  12287. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  12288. !event.isImmediatePropagationStopped() ) {
  12289. // If the event is namespaced, then each handler is only invoked if it is
  12290. // specially universal or its namespaces are a superset of the event's.
  12291. if ( !event.rnamespace || handleObj.namespace === false ||
  12292. event.rnamespace.test( handleObj.namespace ) ) {
  12293. event.handleObj = handleObj;
  12294. event.data = handleObj.data;
  12295. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  12296. handleObj.handler ).apply( matched.elem, args );
  12297. if ( ret !== undefined ) {
  12298. if ( ( event.result = ret ) === false ) {
  12299. event.preventDefault();
  12300. event.stopPropagation();
  12301. }
  12302. }
  12303. }
  12304. }
  12305. }
  12306. // Call the postDispatch hook for the mapped type
  12307. if ( special.postDispatch ) {
  12308. special.postDispatch.call( this, event );
  12309. }
  12310. return event.result;
  12311. },
  12312. handlers: function( event, handlers ) {
  12313. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  12314. handlerQueue = [],
  12315. delegateCount = handlers.delegateCount,
  12316. cur = event.target;
  12317. // Find delegate handlers
  12318. if ( delegateCount &&
  12319. // Support: IE <=9
  12320. // Black-hole SVG <use> instance trees (trac-13180)
  12321. cur.nodeType &&
  12322. // Support: Firefox <=42
  12323. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  12324. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  12325. // Support: IE 11 only
  12326. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  12327. !( event.type === "click" && event.button >= 1 ) ) {
  12328. for ( ; cur !== this; cur = cur.parentNode || this ) {
  12329. // Don't check non-elements (#13208)
  12330. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  12331. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  12332. matchedHandlers = [];
  12333. matchedSelectors = {};
  12334. for ( i = 0; i < delegateCount; i++ ) {
  12335. handleObj = handlers[ i ];
  12336. // Don't conflict with Object.prototype properties (#13203)
  12337. sel = handleObj.selector + " ";
  12338. if ( matchedSelectors[ sel ] === undefined ) {
  12339. matchedSelectors[ sel ] = handleObj.needsContext ?
  12340. jQuery( sel, this ).index( cur ) > -1 :
  12341. jQuery.find( sel, this, null, [ cur ] ).length;
  12342. }
  12343. if ( matchedSelectors[ sel ] ) {
  12344. matchedHandlers.push( handleObj );
  12345. }
  12346. }
  12347. if ( matchedHandlers.length ) {
  12348. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  12349. }
  12350. }
  12351. }
  12352. }
  12353. // Add the remaining (directly-bound) handlers
  12354. cur = this;
  12355. if ( delegateCount < handlers.length ) {
  12356. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  12357. }
  12358. return handlerQueue;
  12359. },
  12360. addProp: function( name, hook ) {
  12361. Object.defineProperty( jQuery.Event.prototype, name, {
  12362. enumerable: true,
  12363. configurable: true,
  12364. get: isFunction( hook ) ?
  12365. function() {
  12366. if ( this.originalEvent ) {
  12367. return hook( this.originalEvent );
  12368. }
  12369. } :
  12370. function() {
  12371. if ( this.originalEvent ) {
  12372. return this.originalEvent[ name ];
  12373. }
  12374. },
  12375. set: function( value ) {
  12376. Object.defineProperty( this, name, {
  12377. enumerable: true,
  12378. configurable: true,
  12379. writable: true,
  12380. value: value
  12381. } );
  12382. }
  12383. } );
  12384. },
  12385. fix: function( originalEvent ) {
  12386. return originalEvent[ jQuery.expando ] ?
  12387. originalEvent :
  12388. new jQuery.Event( originalEvent );
  12389. },
  12390. special: {
  12391. load: {
  12392. // Prevent triggered image.load events from bubbling to window.load
  12393. noBubble: true
  12394. },
  12395. click: {
  12396. // Utilize native event to ensure correct state for checkable inputs
  12397. setup: function( data ) {
  12398. // For mutual compressibility with _default, replace `this` access with a local var.
  12399. // `|| data` is dead code meant only to preserve the variable through minification.
  12400. var el = this || data;
  12401. // Claim the first handler
  12402. if ( rcheckableType.test( el.type ) &&
  12403. el.click && nodeName( el, "input" ) ) {
  12404. // dataPriv.set( el, "click", ... )
  12405. leverageNative( el, "click", returnTrue );
  12406. }
  12407. // Return false to allow normal processing in the caller
  12408. return false;
  12409. },
  12410. trigger: function( data ) {
  12411. // For mutual compressibility with _default, replace `this` access with a local var.
  12412. // `|| data` is dead code meant only to preserve the variable through minification.
  12413. var el = this || data;
  12414. // Force setup before triggering a click
  12415. if ( rcheckableType.test( el.type ) &&
  12416. el.click && nodeName( el, "input" ) ) {
  12417. leverageNative( el, "click" );
  12418. }
  12419. // Return non-false to allow normal event-path propagation
  12420. return true;
  12421. },
  12422. // For cross-browser consistency, suppress native .click() on links
  12423. // Also prevent it if we're currently inside a leveraged native-event stack
  12424. _default: function( event ) {
  12425. var target = event.target;
  12426. return rcheckableType.test( target.type ) &&
  12427. target.click && nodeName( target, "input" ) &&
  12428. dataPriv.get( target, "click" ) ||
  12429. nodeName( target, "a" );
  12430. }
  12431. },
  12432. beforeunload: {
  12433. postDispatch: function( event ) {
  12434. // Support: Firefox 20+
  12435. // Firefox doesn't alert if the returnValue field is not set.
  12436. if ( event.result !== undefined && event.originalEvent ) {
  12437. event.originalEvent.returnValue = event.result;
  12438. }
  12439. }
  12440. }
  12441. }
  12442. };
  12443. // Ensure the presence of an event listener that handles manually-triggered
  12444. // synthetic events by interrupting progress until reinvoked in response to
  12445. // *native* events that it fires directly, ensuring that state changes have
  12446. // already occurred before other listeners are invoked.
  12447. function leverageNative( el, type, expectSync ) {
  12448. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  12449. if ( !expectSync ) {
  12450. if ( dataPriv.get( el, type ) === undefined ) {
  12451. jQuery.event.add( el, type, returnTrue );
  12452. }
  12453. return;
  12454. }
  12455. // Register the controller as a special universal handler for all event namespaces
  12456. dataPriv.set( el, type, false );
  12457. jQuery.event.add( el, type, {
  12458. namespace: false,
  12459. handler: function( event ) {
  12460. var notAsync, result,
  12461. saved = dataPriv.get( this, type );
  12462. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  12463. // Interrupt processing of the outer synthetic .trigger()ed event
  12464. // Saved data should be false in such cases, but might be a leftover capture object
  12465. // from an async native handler (gh-4350)
  12466. if ( !saved.length ) {
  12467. // Store arguments for use when handling the inner native event
  12468. // There will always be at least one argument (an event object), so this array
  12469. // will not be confused with a leftover capture object.
  12470. saved = slice.call( arguments );
  12471. dataPriv.set( this, type, saved );
  12472. // Trigger the native event and capture its result
  12473. // Support: IE <=9 - 11+
  12474. // focus() and blur() are asynchronous
  12475. notAsync = expectSync( this, type );
  12476. this[ type ]();
  12477. result = dataPriv.get( this, type );
  12478. if ( saved !== result || notAsync ) {
  12479. dataPriv.set( this, type, false );
  12480. } else {
  12481. result = {};
  12482. }
  12483. if ( saved !== result ) {
  12484. // Cancel the outer synthetic event
  12485. event.stopImmediatePropagation();
  12486. event.preventDefault();
  12487. return result.value;
  12488. }
  12489. // If this is an inner synthetic event for an event with a bubbling surrogate
  12490. // (focus or blur), assume that the surrogate already propagated from triggering the
  12491. // native event and prevent that from happening again here.
  12492. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  12493. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  12494. // less bad than duplication.
  12495. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  12496. event.stopPropagation();
  12497. }
  12498. // If this is a native event triggered above, everything is now in order
  12499. // Fire an inner synthetic event with the original arguments
  12500. } else if ( saved.length ) {
  12501. // ...and capture the result
  12502. dataPriv.set( this, type, {
  12503. value: jQuery.event.trigger(
  12504. // Support: IE <=9 - 11+
  12505. // Extend with the prototype to reset the above stopImmediatePropagation()
  12506. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  12507. saved.slice( 1 ),
  12508. this
  12509. )
  12510. } );
  12511. // Abort handling of the native event
  12512. event.stopImmediatePropagation();
  12513. }
  12514. }
  12515. } );
  12516. }
  12517. jQuery.removeEvent = function( elem, type, handle ) {
  12518. // This "if" is needed for plain objects
  12519. if ( elem.removeEventListener ) {
  12520. elem.removeEventListener( type, handle );
  12521. }
  12522. };
  12523. jQuery.Event = function( src, props ) {
  12524. // Allow instantiation without the 'new' keyword
  12525. if ( !( this instanceof jQuery.Event ) ) {
  12526. return new jQuery.Event( src, props );
  12527. }
  12528. // Event object
  12529. if ( src && src.type ) {
  12530. this.originalEvent = src;
  12531. this.type = src.type;
  12532. // Events bubbling up the document may have been marked as prevented
  12533. // by a handler lower down the tree; reflect the correct value.
  12534. this.isDefaultPrevented = src.defaultPrevented ||
  12535. src.defaultPrevented === undefined &&
  12536. // Support: Android <=2.3 only
  12537. src.returnValue === false ?
  12538. returnTrue :
  12539. returnFalse;
  12540. // Create target properties
  12541. // Support: Safari <=6 - 7 only
  12542. // Target should not be a text node (#504, #13143)
  12543. this.target = ( src.target && src.target.nodeType === 3 ) ?
  12544. src.target.parentNode :
  12545. src.target;
  12546. this.currentTarget = src.currentTarget;
  12547. this.relatedTarget = src.relatedTarget;
  12548. // Event type
  12549. } else {
  12550. this.type = src;
  12551. }
  12552. // Put explicitly provided properties onto the event object
  12553. if ( props ) {
  12554. jQuery.extend( this, props );
  12555. }
  12556. // Create a timestamp if incoming event doesn't have one
  12557. this.timeStamp = src && src.timeStamp || Date.now();
  12558. // Mark it as fixed
  12559. this[ jQuery.expando ] = true;
  12560. };
  12561. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  12562. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  12563. jQuery.Event.prototype = {
  12564. constructor: jQuery.Event,
  12565. isDefaultPrevented: returnFalse,
  12566. isPropagationStopped: returnFalse,
  12567. isImmediatePropagationStopped: returnFalse,
  12568. isSimulated: false,
  12569. preventDefault: function() {
  12570. var e = this.originalEvent;
  12571. this.isDefaultPrevented = returnTrue;
  12572. if ( e && !this.isSimulated ) {
  12573. e.preventDefault();
  12574. }
  12575. },
  12576. stopPropagation: function() {
  12577. var e = this.originalEvent;
  12578. this.isPropagationStopped = returnTrue;
  12579. if ( e && !this.isSimulated ) {
  12580. e.stopPropagation();
  12581. }
  12582. },
  12583. stopImmediatePropagation: function() {
  12584. var e = this.originalEvent;
  12585. this.isImmediatePropagationStopped = returnTrue;
  12586. if ( e && !this.isSimulated ) {
  12587. e.stopImmediatePropagation();
  12588. }
  12589. this.stopPropagation();
  12590. }
  12591. };
  12592. // Includes all common event props including KeyEvent and MouseEvent specific props
  12593. jQuery.each( {
  12594. altKey: true,
  12595. bubbles: true,
  12596. cancelable: true,
  12597. changedTouches: true,
  12598. ctrlKey: true,
  12599. detail: true,
  12600. eventPhase: true,
  12601. metaKey: true,
  12602. pageX: true,
  12603. pageY: true,
  12604. shiftKey: true,
  12605. view: true,
  12606. "char": true,
  12607. code: true,
  12608. charCode: true,
  12609. key: true,
  12610. keyCode: true,
  12611. button: true,
  12612. buttons: true,
  12613. clientX: true,
  12614. clientY: true,
  12615. offsetX: true,
  12616. offsetY: true,
  12617. pointerId: true,
  12618. pointerType: true,
  12619. screenX: true,
  12620. screenY: true,
  12621. targetTouches: true,
  12622. toElement: true,
  12623. touches: true,
  12624. which: function( event ) {
  12625. var button = event.button;
  12626. // Add which for key events
  12627. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  12628. return event.charCode != null ? event.charCode : event.keyCode;
  12629. }
  12630. // Add which for click: 1 === left; 2 === middle; 3 === right
  12631. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  12632. if ( button & 1 ) {
  12633. return 1;
  12634. }
  12635. if ( button & 2 ) {
  12636. return 3;
  12637. }
  12638. if ( button & 4 ) {
  12639. return 2;
  12640. }
  12641. return 0;
  12642. }
  12643. return event.which;
  12644. }
  12645. }, jQuery.event.addProp );
  12646. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  12647. jQuery.event.special[ type ] = {
  12648. // Utilize native event if possible so blur/focus sequence is correct
  12649. setup: function() {
  12650. // Claim the first handler
  12651. // dataPriv.set( this, "focus", ... )
  12652. // dataPriv.set( this, "blur", ... )
  12653. leverageNative( this, type, expectSync );
  12654. // Return false to allow normal processing in the caller
  12655. return false;
  12656. },
  12657. trigger: function() {
  12658. // Force setup before trigger
  12659. leverageNative( this, type );
  12660. // Return non-false to allow normal event-path propagation
  12661. return true;
  12662. },
  12663. delegateType: delegateType
  12664. };
  12665. } );
  12666. // Create mouseenter/leave events using mouseover/out and event-time checks
  12667. // so that event delegation works in jQuery.
  12668. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  12669. //
  12670. // Support: Safari 7 only
  12671. // Safari sends mouseenter too often; see:
  12672. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  12673. // for the description of the bug (it existed in older Chrome versions as well).
  12674. jQuery.each( {
  12675. mouseenter: "mouseover",
  12676. mouseleave: "mouseout",
  12677. pointerenter: "pointerover",
  12678. pointerleave: "pointerout"
  12679. }, function( orig, fix ) {
  12680. jQuery.event.special[ orig ] = {
  12681. delegateType: fix,
  12682. bindType: fix,
  12683. handle: function( event ) {
  12684. var ret,
  12685. target = this,
  12686. related = event.relatedTarget,
  12687. handleObj = event.handleObj;
  12688. // For mouseenter/leave call the handler if related is outside the target.
  12689. // NB: No relatedTarget if the mouse left/entered the browser window
  12690. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  12691. event.type = handleObj.origType;
  12692. ret = handleObj.handler.apply( this, arguments );
  12693. event.type = fix;
  12694. }
  12695. return ret;
  12696. }
  12697. };
  12698. } );
  12699. jQuery.fn.extend( {
  12700. on: function( types, selector, data, fn ) {
  12701. return on( this, types, selector, data, fn );
  12702. },
  12703. one: function( types, selector, data, fn ) {
  12704. return on( this, types, selector, data, fn, 1 );
  12705. },
  12706. off: function( types, selector, fn ) {
  12707. var handleObj, type;
  12708. if ( types && types.preventDefault && types.handleObj ) {
  12709. // ( event ) dispatched jQuery.Event
  12710. handleObj = types.handleObj;
  12711. jQuery( types.delegateTarget ).off(
  12712. handleObj.namespace ?
  12713. handleObj.origType + "." + handleObj.namespace :
  12714. handleObj.origType,
  12715. handleObj.selector,
  12716. handleObj.handler
  12717. );
  12718. return this;
  12719. }
  12720. if ( typeof types === "object" ) {
  12721. // ( types-object [, selector] )
  12722. for ( type in types ) {
  12723. this.off( type, selector, types[ type ] );
  12724. }
  12725. return this;
  12726. }
  12727. if ( selector === false || typeof selector === "function" ) {
  12728. // ( types [, fn] )
  12729. fn = selector;
  12730. selector = undefined;
  12731. }
  12732. if ( fn === false ) {
  12733. fn = returnFalse;
  12734. }
  12735. return this.each( function() {
  12736. jQuery.event.remove( this, types, fn, selector );
  12737. } );
  12738. }
  12739. } );
  12740. var
  12741. /* eslint-disable max-len */
  12742. // See https://github.com/eslint/eslint/issues/3229
  12743. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  12744. /* eslint-enable */
  12745. // Support: IE <=10 - 11, Edge 12 - 13 only
  12746. // In IE/Edge using regex groups here causes severe slowdowns.
  12747. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  12748. rnoInnerhtml = /<script|<style|<link/i,
  12749. // checked="checked" or checked
  12750. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  12751. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  12752. // Prefer a tbody over its parent table for containing new rows
  12753. function manipulationTarget( elem, content ) {
  12754. if ( nodeName( elem, "table" ) &&
  12755. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  12756. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  12757. }
  12758. return elem;
  12759. }
  12760. // Replace/restore the type attribute of script elements for safe DOM manipulation
  12761. function disableScript( elem ) {
  12762. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  12763. return elem;
  12764. }
  12765. function restoreScript( elem ) {
  12766. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  12767. elem.type = elem.type.slice( 5 );
  12768. } else {
  12769. elem.removeAttribute( "type" );
  12770. }
  12771. return elem;
  12772. }
  12773. function cloneCopyEvent( src, dest ) {
  12774. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  12775. if ( dest.nodeType !== 1 ) {
  12776. return;
  12777. }
  12778. // 1. Copy private data: events, handlers, etc.
  12779. if ( dataPriv.hasData( src ) ) {
  12780. pdataOld = dataPriv.access( src );
  12781. pdataCur = dataPriv.set( dest, pdataOld );
  12782. events = pdataOld.events;
  12783. if ( events ) {
  12784. delete pdataCur.handle;
  12785. pdataCur.events = {};
  12786. for ( type in events ) {
  12787. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  12788. jQuery.event.add( dest, type, events[ type ][ i ] );
  12789. }
  12790. }
  12791. }
  12792. }
  12793. // 2. Copy user data
  12794. if ( dataUser.hasData( src ) ) {
  12795. udataOld = dataUser.access( src );
  12796. udataCur = jQuery.extend( {}, udataOld );
  12797. dataUser.set( dest, udataCur );
  12798. }
  12799. }
  12800. // Fix IE bugs, see support tests
  12801. function fixInput( src, dest ) {
  12802. var nodeName = dest.nodeName.toLowerCase();
  12803. // Fails to persist the checked state of a cloned checkbox or radio button.
  12804. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  12805. dest.checked = src.checked;
  12806. // Fails to return the selected option to the default selected state when cloning options
  12807. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  12808. dest.defaultValue = src.defaultValue;
  12809. }
  12810. }
  12811. function domManip( collection, args, callback, ignored ) {
  12812. // Flatten any nested arrays
  12813. args = concat.apply( [], args );
  12814. var fragment, first, scripts, hasScripts, node, doc,
  12815. i = 0,
  12816. l = collection.length,
  12817. iNoClone = l - 1,
  12818. value = args[ 0 ],
  12819. valueIsFunction = isFunction( value );
  12820. // We can't cloneNode fragments that contain checked, in WebKit
  12821. if ( valueIsFunction ||
  12822. ( l > 1 && typeof value === "string" &&
  12823. !support.checkClone && rchecked.test( value ) ) ) {
  12824. return collection.each( function( index ) {
  12825. var self = collection.eq( index );
  12826. if ( valueIsFunction ) {
  12827. args[ 0 ] = value.call( this, index, self.html() );
  12828. }
  12829. domManip( self, args, callback, ignored );
  12830. } );
  12831. }
  12832. if ( l ) {
  12833. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  12834. first = fragment.firstChild;
  12835. if ( fragment.childNodes.length === 1 ) {
  12836. fragment = first;
  12837. }
  12838. // Require either new content or an interest in ignored elements to invoke the callback
  12839. if ( first || ignored ) {
  12840. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  12841. hasScripts = scripts.length;
  12842. // Use the original fragment for the last item
  12843. // instead of the first because it can end up
  12844. // being emptied incorrectly in certain situations (#8070).
  12845. for ( ; i < l; i++ ) {
  12846. node = fragment;
  12847. if ( i !== iNoClone ) {
  12848. node = jQuery.clone( node, true, true );
  12849. // Keep references to cloned scripts for later restoration
  12850. if ( hasScripts ) {
  12851. // Support: Android <=4.0 only, PhantomJS 1 only
  12852. // push.apply(_, arraylike) throws on ancient WebKit
  12853. jQuery.merge( scripts, getAll( node, "script" ) );
  12854. }
  12855. }
  12856. callback.call( collection[ i ], node, i );
  12857. }
  12858. if ( hasScripts ) {
  12859. doc = scripts[ scripts.length - 1 ].ownerDocument;
  12860. // Reenable scripts
  12861. jQuery.map( scripts, restoreScript );
  12862. // Evaluate executable scripts on first document insertion
  12863. for ( i = 0; i < hasScripts; i++ ) {
  12864. node = scripts[ i ];
  12865. if ( rscriptType.test( node.type || "" ) &&
  12866. !dataPriv.access( node, "globalEval" ) &&
  12867. jQuery.contains( doc, node ) ) {
  12868. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  12869. // Optional AJAX dependency, but won't run scripts if not present
  12870. if ( jQuery._evalUrl && !node.noModule ) {
  12871. jQuery._evalUrl( node.src, {
  12872. nonce: node.nonce || node.getAttribute( "nonce" )
  12873. } );
  12874. }
  12875. } else {
  12876. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  12877. }
  12878. }
  12879. }
  12880. }
  12881. }
  12882. }
  12883. return collection;
  12884. }
  12885. function remove( elem, selector, keepData ) {
  12886. var node,
  12887. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  12888. i = 0;
  12889. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  12890. if ( !keepData && node.nodeType === 1 ) {
  12891. jQuery.cleanData( getAll( node ) );
  12892. }
  12893. if ( node.parentNode ) {
  12894. if ( keepData && isAttached( node ) ) {
  12895. setGlobalEval( getAll( node, "script" ) );
  12896. }
  12897. node.parentNode.removeChild( node );
  12898. }
  12899. }
  12900. return elem;
  12901. }
  12902. jQuery.extend( {
  12903. htmlPrefilter: function( html ) {
  12904. return html.replace( rxhtmlTag, "<$1></$2>" );
  12905. },
  12906. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  12907. var i, l, srcElements, destElements,
  12908. clone = elem.cloneNode( true ),
  12909. inPage = isAttached( elem );
  12910. // Fix IE cloning issues
  12911. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  12912. !jQuery.isXMLDoc( elem ) ) {
  12913. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  12914. destElements = getAll( clone );
  12915. srcElements = getAll( elem );
  12916. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12917. fixInput( srcElements[ i ], destElements[ i ] );
  12918. }
  12919. }
  12920. // Copy the events from the original to the clone
  12921. if ( dataAndEvents ) {
  12922. if ( deepDataAndEvents ) {
  12923. srcElements = srcElements || getAll( elem );
  12924. destElements = destElements || getAll( clone );
  12925. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  12926. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  12927. }
  12928. } else {
  12929. cloneCopyEvent( elem, clone );
  12930. }
  12931. }
  12932. // Preserve script evaluation history
  12933. destElements = getAll( clone, "script" );
  12934. if ( destElements.length > 0 ) {
  12935. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  12936. }
  12937. // Return the cloned set
  12938. return clone;
  12939. },
  12940. cleanData: function( elems ) {
  12941. var data, elem, type,
  12942. special = jQuery.event.special,
  12943. i = 0;
  12944. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  12945. if ( acceptData( elem ) ) {
  12946. if ( ( data = elem[ dataPriv.expando ] ) ) {
  12947. if ( data.events ) {
  12948. for ( type in data.events ) {
  12949. if ( special[ type ] ) {
  12950. jQuery.event.remove( elem, type );
  12951. // This is a shortcut to avoid jQuery.event.remove's overhead
  12952. } else {
  12953. jQuery.removeEvent( elem, type, data.handle );
  12954. }
  12955. }
  12956. }
  12957. // Support: Chrome <=35 - 45+
  12958. // Assign undefined instead of using delete, see Data#remove
  12959. elem[ dataPriv.expando ] = undefined;
  12960. }
  12961. if ( elem[ dataUser.expando ] ) {
  12962. // Support: Chrome <=35 - 45+
  12963. // Assign undefined instead of using delete, see Data#remove
  12964. elem[ dataUser.expando ] = undefined;
  12965. }
  12966. }
  12967. }
  12968. }
  12969. } );
  12970. jQuery.fn.extend( {
  12971. detach: function( selector ) {
  12972. return remove( this, selector, true );
  12973. },
  12974. remove: function( selector ) {
  12975. return remove( this, selector );
  12976. },
  12977. text: function( value ) {
  12978. return access( this, function( value ) {
  12979. return value === undefined ?
  12980. jQuery.text( this ) :
  12981. this.empty().each( function() {
  12982. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12983. this.textContent = value;
  12984. }
  12985. } );
  12986. }, null, value, arguments.length );
  12987. },
  12988. append: function() {
  12989. return domManip( this, arguments, function( elem ) {
  12990. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12991. var target = manipulationTarget( this, elem );
  12992. target.appendChild( elem );
  12993. }
  12994. } );
  12995. },
  12996. prepend: function() {
  12997. return domManip( this, arguments, function( elem ) {
  12998. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  12999. var target = manipulationTarget( this, elem );
  13000. target.insertBefore( elem, target.firstChild );
  13001. }
  13002. } );
  13003. },
  13004. before: function() {
  13005. return domManip( this, arguments, function( elem ) {
  13006. if ( this.parentNode ) {
  13007. this.parentNode.insertBefore( elem, this );
  13008. }
  13009. } );
  13010. },
  13011. after: function() {
  13012. return domManip( this, arguments, function( elem ) {
  13013. if ( this.parentNode ) {
  13014. this.parentNode.insertBefore( elem, this.nextSibling );
  13015. }
  13016. } );
  13017. },
  13018. empty: function() {
  13019. var elem,
  13020. i = 0;
  13021. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  13022. if ( elem.nodeType === 1 ) {
  13023. // Prevent memory leaks
  13024. jQuery.cleanData( getAll( elem, false ) );
  13025. // Remove any remaining nodes
  13026. elem.textContent = "";
  13027. }
  13028. }
  13029. return this;
  13030. },
  13031. clone: function( dataAndEvents, deepDataAndEvents ) {
  13032. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  13033. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  13034. return this.map( function() {
  13035. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  13036. } );
  13037. },
  13038. html: function( value ) {
  13039. return access( this, function( value ) {
  13040. var elem = this[ 0 ] || {},
  13041. i = 0,
  13042. l = this.length;
  13043. if ( value === undefined && elem.nodeType === 1 ) {
  13044. return elem.innerHTML;
  13045. }
  13046. // See if we can take a shortcut and just use innerHTML
  13047. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  13048. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  13049. value = jQuery.htmlPrefilter( value );
  13050. try {
  13051. for ( ; i < l; i++ ) {
  13052. elem = this[ i ] || {};
  13053. // Remove element nodes and prevent memory leaks
  13054. if ( elem.nodeType === 1 ) {
  13055. jQuery.cleanData( getAll( elem, false ) );
  13056. elem.innerHTML = value;
  13057. }
  13058. }
  13059. elem = 0;
  13060. // If using innerHTML throws an exception, use the fallback method
  13061. } catch ( e ) {}
  13062. }
  13063. if ( elem ) {
  13064. this.empty().append( value );
  13065. }
  13066. }, null, value, arguments.length );
  13067. },
  13068. replaceWith: function() {
  13069. var ignored = [];
  13070. // Make the changes, replacing each non-ignored context element with the new content
  13071. return domManip( this, arguments, function( elem ) {
  13072. var parent = this.parentNode;
  13073. if ( jQuery.inArray( this, ignored ) < 0 ) {
  13074. jQuery.cleanData( getAll( this ) );
  13075. if ( parent ) {
  13076. parent.replaceChild( elem, this );
  13077. }
  13078. }
  13079. // Force callback invocation
  13080. }, ignored );
  13081. }
  13082. } );
  13083. jQuery.each( {
  13084. appendTo: "append",
  13085. prependTo: "prepend",
  13086. insertBefore: "before",
  13087. insertAfter: "after",
  13088. replaceAll: "replaceWith"
  13089. }, function( name, original ) {
  13090. jQuery.fn[ name ] = function( selector ) {
  13091. var elems,
  13092. ret = [],
  13093. insert = jQuery( selector ),
  13094. last = insert.length - 1,
  13095. i = 0;
  13096. for ( ; i <= last; i++ ) {
  13097. elems = i === last ? this : this.clone( true );
  13098. jQuery( insert[ i ] )[ original ]( elems );
  13099. // Support: Android <=4.0 only, PhantomJS 1 only
  13100. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  13101. push.apply( ret, elems.get() );
  13102. }
  13103. return this.pushStack( ret );
  13104. };
  13105. } );
  13106. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  13107. var getStyles = function( elem ) {
  13108. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  13109. // IE throws on elements created in popups
  13110. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  13111. var view = elem.ownerDocument.defaultView;
  13112. if ( !view || !view.opener ) {
  13113. view = window;
  13114. }
  13115. return view.getComputedStyle( elem );
  13116. };
  13117. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  13118. ( function() {
  13119. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  13120. // so they're executed at the same time to save the second computation.
  13121. function computeStyleTests() {
  13122. // This is a singleton, we need to execute it only once
  13123. if ( !div ) {
  13124. return;
  13125. }
  13126. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  13127. "margin-top:1px;padding:0;border:0";
  13128. div.style.cssText =
  13129. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  13130. "margin:auto;border:1px;padding:1px;" +
  13131. "width:60%;top:1%";
  13132. documentElement.appendChild( container ).appendChild( div );
  13133. var divStyle = window.getComputedStyle( div );
  13134. pixelPositionVal = divStyle.top !== "1%";
  13135. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  13136. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  13137. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  13138. // Some styles come back with percentage values, even though they shouldn't
  13139. div.style.right = "60%";
  13140. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  13141. // Support: IE 9 - 11 only
  13142. // Detect misreporting of content dimensions for box-sizing:border-box elements
  13143. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  13144. // Support: IE 9 only
  13145. // Detect overflow:scroll screwiness (gh-3699)
  13146. // Support: Chrome <=64
  13147. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  13148. div.style.position = "absolute";
  13149. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  13150. documentElement.removeChild( container );
  13151. // Nullify the div so it wouldn't be stored in the memory and
  13152. // it will also be a sign that checks already performed
  13153. div = null;
  13154. }
  13155. function roundPixelMeasures( measure ) {
  13156. return Math.round( parseFloat( measure ) );
  13157. }
  13158. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  13159. reliableMarginLeftVal,
  13160. container = document.createElement( "div" ),
  13161. div = document.createElement( "div" );
  13162. // Finish early in limited (non-browser) environments
  13163. if ( !div.style ) {
  13164. return;
  13165. }
  13166. // Support: IE <=9 - 11 only
  13167. // Style of cloned element affects source element cloned (#8908)
  13168. div.style.backgroundClip = "content-box";
  13169. div.cloneNode( true ).style.backgroundClip = "";
  13170. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  13171. jQuery.extend( support, {
  13172. boxSizingReliable: function() {
  13173. computeStyleTests();
  13174. return boxSizingReliableVal;
  13175. },
  13176. pixelBoxStyles: function() {
  13177. computeStyleTests();
  13178. return pixelBoxStylesVal;
  13179. },
  13180. pixelPosition: function() {
  13181. computeStyleTests();
  13182. return pixelPositionVal;
  13183. },
  13184. reliableMarginLeft: function() {
  13185. computeStyleTests();
  13186. return reliableMarginLeftVal;
  13187. },
  13188. scrollboxSize: function() {
  13189. computeStyleTests();
  13190. return scrollboxSizeVal;
  13191. }
  13192. } );
  13193. } )();
  13194. function curCSS( elem, name, computed ) {
  13195. var width, minWidth, maxWidth, ret,
  13196. // Support: Firefox 51+
  13197. // Retrieving style before computed somehow
  13198. // fixes an issue with getting wrong values
  13199. // on detached elements
  13200. style = elem.style;
  13201. computed = computed || getStyles( elem );
  13202. // getPropertyValue is needed for:
  13203. // .css('filter') (IE 9 only, #12537)
  13204. // .css('--customProperty) (#3144)
  13205. if ( computed ) {
  13206. ret = computed.getPropertyValue( name ) || computed[ name ];
  13207. if ( ret === "" && !isAttached( elem ) ) {
  13208. ret = jQuery.style( elem, name );
  13209. }
  13210. // A tribute to the "awesome hack by Dean Edwards"
  13211. // Android Browser returns percentage for some values,
  13212. // but width seems to be reliably pixels.
  13213. // This is against the CSSOM draft spec:
  13214. // https://drafts.csswg.org/cssom/#resolved-values
  13215. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  13216. // Remember the original values
  13217. width = style.width;
  13218. minWidth = style.minWidth;
  13219. maxWidth = style.maxWidth;
  13220. // Put in the new values to get a computed value out
  13221. style.minWidth = style.maxWidth = style.width = ret;
  13222. ret = computed.width;
  13223. // Revert the changed values
  13224. style.width = width;
  13225. style.minWidth = minWidth;
  13226. style.maxWidth = maxWidth;
  13227. }
  13228. }
  13229. return ret !== undefined ?
  13230. // Support: IE <=9 - 11 only
  13231. // IE returns zIndex value as an integer.
  13232. ret + "" :
  13233. ret;
  13234. }
  13235. function addGetHookIf( conditionFn, hookFn ) {
  13236. // Define the hook, we'll check on the first run if it's really needed.
  13237. return {
  13238. get: function() {
  13239. if ( conditionFn() ) {
  13240. // Hook not needed (or it's not possible to use it due
  13241. // to missing dependency), remove it.
  13242. delete this.get;
  13243. return;
  13244. }
  13245. // Hook needed; redefine it so that the support test is not executed again.
  13246. return ( this.get = hookFn ).apply( this, arguments );
  13247. }
  13248. };
  13249. }
  13250. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  13251. emptyStyle = document.createElement( "div" ).style,
  13252. vendorProps = {};
  13253. // Return a vendor-prefixed property or undefined
  13254. function vendorPropName( name ) {
  13255. // Check for vendor prefixed names
  13256. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  13257. i = cssPrefixes.length;
  13258. while ( i-- ) {
  13259. name = cssPrefixes[ i ] + capName;
  13260. if ( name in emptyStyle ) {
  13261. return name;
  13262. }
  13263. }
  13264. }
  13265. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  13266. function finalPropName( name ) {
  13267. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  13268. if ( final ) {
  13269. return final;
  13270. }
  13271. if ( name in emptyStyle ) {
  13272. return name;
  13273. }
  13274. return vendorProps[ name ] = vendorPropName( name ) || name;
  13275. }
  13276. var
  13277. // Swappable if display is none or starts with table
  13278. // except "table", "table-cell", or "table-caption"
  13279. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  13280. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  13281. rcustomProp = /^--/,
  13282. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  13283. cssNormalTransform = {
  13284. letterSpacing: "0",
  13285. fontWeight: "400"
  13286. };
  13287. function setPositiveNumber( elem, value, subtract ) {
  13288. // Any relative (+/-) values have already been
  13289. // normalized at this point
  13290. var matches = rcssNum.exec( value );
  13291. return matches ?
  13292. // Guard against undefined "subtract", e.g., when used as in cssHooks
  13293. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  13294. value;
  13295. }
  13296. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  13297. var i = dimension === "width" ? 1 : 0,
  13298. extra = 0,
  13299. delta = 0;
  13300. // Adjustment may not be necessary
  13301. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  13302. return 0;
  13303. }
  13304. for ( ; i < 4; i += 2 ) {
  13305. // Both box models exclude margin
  13306. if ( box === "margin" ) {
  13307. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  13308. }
  13309. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  13310. if ( !isBorderBox ) {
  13311. // Add padding
  13312. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  13313. // For "border" or "margin", add border
  13314. if ( box !== "padding" ) {
  13315. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13316. // But still keep track of it otherwise
  13317. } else {
  13318. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13319. }
  13320. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  13321. // "padding" or "margin"
  13322. } else {
  13323. // For "content", subtract padding
  13324. if ( box === "content" ) {
  13325. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  13326. }
  13327. // For "content" or "padding", subtract border
  13328. if ( box !== "margin" ) {
  13329. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  13330. }
  13331. }
  13332. }
  13333. // Account for positive content-box scroll gutter when requested by providing computedVal
  13334. if ( !isBorderBox && computedVal >= 0 ) {
  13335. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  13336. // Assuming integer scroll gutter, subtract the rest and round down
  13337. delta += Math.max( 0, Math.ceil(
  13338. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  13339. computedVal -
  13340. delta -
  13341. extra -
  13342. 0.5
  13343. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  13344. // Use an explicit zero to avoid NaN (gh-3964)
  13345. ) ) || 0;
  13346. }
  13347. return delta;
  13348. }
  13349. function getWidthOrHeight( elem, dimension, extra ) {
  13350. // Start with computed style
  13351. var styles = getStyles( elem ),
  13352. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  13353. // Fake content-box until we know it's needed to know the true value.
  13354. boxSizingNeeded = !support.boxSizingReliable() || extra,
  13355. isBorderBox = boxSizingNeeded &&
  13356. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  13357. valueIsBorderBox = isBorderBox,
  13358. val = curCSS( elem, dimension, styles ),
  13359. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  13360. // Support: Firefox <=54
  13361. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  13362. if ( rnumnonpx.test( val ) ) {
  13363. if ( !extra ) {
  13364. return val;
  13365. }
  13366. val = "auto";
  13367. }
  13368. // Fall back to offsetWidth/offsetHeight when value is "auto"
  13369. // This happens for inline elements with no explicit setting (gh-3571)
  13370. // Support: Android <=4.1 - 4.3 only
  13371. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  13372. // Support: IE 9-11 only
  13373. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  13374. // We use getClientRects() to check for hidden/disconnected.
  13375. // In those cases, the computed value can be trusted to be border-box
  13376. if ( ( !support.boxSizingReliable() && isBorderBox ||
  13377. val === "auto" ||
  13378. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  13379. elem.getClientRects().length ) {
  13380. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  13381. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  13382. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  13383. // retrieved value as a content box dimension.
  13384. valueIsBorderBox = offsetProp in elem;
  13385. if ( valueIsBorderBox ) {
  13386. val = elem[ offsetProp ];
  13387. }
  13388. }
  13389. // Normalize "" and auto
  13390. val = parseFloat( val ) || 0;
  13391. // Adjust for the element's box model
  13392. return ( val +
  13393. boxModelAdjustment(
  13394. elem,
  13395. dimension,
  13396. extra || ( isBorderBox ? "border" : "content" ),
  13397. valueIsBorderBox,
  13398. styles,
  13399. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  13400. val
  13401. )
  13402. ) + "px";
  13403. }
  13404. jQuery.extend( {
  13405. // Add in style property hooks for overriding the default
  13406. // behavior of getting and setting a style property
  13407. cssHooks: {
  13408. opacity: {
  13409. get: function( elem, computed ) {
  13410. if ( computed ) {
  13411. // We should always get a number back from opacity
  13412. var ret = curCSS( elem, "opacity" );
  13413. return ret === "" ? "1" : ret;
  13414. }
  13415. }
  13416. }
  13417. },
  13418. // Don't automatically add "px" to these possibly-unitless properties
  13419. cssNumber: {
  13420. "animationIterationCount": true,
  13421. "columnCount": true,
  13422. "fillOpacity": true,
  13423. "flexGrow": true,
  13424. "flexShrink": true,
  13425. "fontWeight": true,
  13426. "gridArea": true,
  13427. "gridColumn": true,
  13428. "gridColumnEnd": true,
  13429. "gridColumnStart": true,
  13430. "gridRow": true,
  13431. "gridRowEnd": true,
  13432. "gridRowStart": true,
  13433. "lineHeight": true,
  13434. "opacity": true,
  13435. "order": true,
  13436. "orphans": true,
  13437. "widows": true,
  13438. "zIndex": true,
  13439. "zoom": true
  13440. },
  13441. // Add in properties whose names you wish to fix before
  13442. // setting or getting the value
  13443. cssProps: {},
  13444. // Get and set the style property on a DOM Node
  13445. style: function( elem, name, value, extra ) {
  13446. // Don't set styles on text and comment nodes
  13447. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  13448. return;
  13449. }
  13450. // Make sure that we're working with the right name
  13451. var ret, type, hooks,
  13452. origName = camelCase( name ),
  13453. isCustomProp = rcustomProp.test( name ),
  13454. style = elem.style;
  13455. // Make sure that we're working with the right name. We don't
  13456. // want to query the value if it is a CSS custom property
  13457. // since they are user-defined.
  13458. if ( !isCustomProp ) {
  13459. name = finalPropName( origName );
  13460. }
  13461. // Gets hook for the prefixed version, then unprefixed version
  13462. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  13463. // Check if we're setting a value
  13464. if ( value !== undefined ) {
  13465. type = typeof value;
  13466. // Convert "+=" or "-=" to relative numbers (#7345)
  13467. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  13468. value = adjustCSS( elem, name, ret );
  13469. // Fixes bug #9237
  13470. type = "number";
  13471. }
  13472. // Make sure that null and NaN values aren't set (#7116)
  13473. if ( value == null || value !== value ) {
  13474. return;
  13475. }
  13476. // If a number was passed in, add the unit (except for certain CSS properties)
  13477. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  13478. // "px" to a few hardcoded values.
  13479. if ( type === "number" && !isCustomProp ) {
  13480. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  13481. }
  13482. // background-* props affect original clone's values
  13483. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  13484. style[ name ] = "inherit";
  13485. }
  13486. // If a hook was provided, use that value, otherwise just set the specified value
  13487. if ( !hooks || !( "set" in hooks ) ||
  13488. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  13489. if ( isCustomProp ) {
  13490. style.setProperty( name, value );
  13491. } else {
  13492. style[ name ] = value;
  13493. }
  13494. }
  13495. } else {
  13496. // If a hook was provided get the non-computed value from there
  13497. if ( hooks && "get" in hooks &&
  13498. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  13499. return ret;
  13500. }
  13501. // Otherwise just get the value from the style object
  13502. return style[ name ];
  13503. }
  13504. },
  13505. css: function( elem, name, extra, styles ) {
  13506. var val, num, hooks,
  13507. origName = camelCase( name ),
  13508. isCustomProp = rcustomProp.test( name );
  13509. // Make sure that we're working with the right name. We don't
  13510. // want to modify the value if it is a CSS custom property
  13511. // since they are user-defined.
  13512. if ( !isCustomProp ) {
  13513. name = finalPropName( origName );
  13514. }
  13515. // Try prefixed name followed by the unprefixed name
  13516. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  13517. // If a hook was provided get the computed value from there
  13518. if ( hooks && "get" in hooks ) {
  13519. val = hooks.get( elem, true, extra );
  13520. }
  13521. // Otherwise, if a way to get the computed value exists, use that
  13522. if ( val === undefined ) {
  13523. val = curCSS( elem, name, styles );
  13524. }
  13525. // Convert "normal" to computed value
  13526. if ( val === "normal" && name in cssNormalTransform ) {
  13527. val = cssNormalTransform[ name ];
  13528. }
  13529. // Make numeric if forced or a qualifier was provided and val looks numeric
  13530. if ( extra === "" || extra ) {
  13531. num = parseFloat( val );
  13532. return extra === true || isFinite( num ) ? num || 0 : val;
  13533. }
  13534. return val;
  13535. }
  13536. } );
  13537. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  13538. jQuery.cssHooks[ dimension ] = {
  13539. get: function( elem, computed, extra ) {
  13540. if ( computed ) {
  13541. // Certain elements can have dimension info if we invisibly show them
  13542. // but it must have a current display style that would benefit
  13543. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  13544. // Support: Safari 8+
  13545. // Table columns in Safari have non-zero offsetWidth & zero
  13546. // getBoundingClientRect().width unless display is changed.
  13547. // Support: IE <=11 only
  13548. // Running getBoundingClientRect on a disconnected node
  13549. // in IE throws an error.
  13550. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  13551. swap( elem, cssShow, function() {
  13552. return getWidthOrHeight( elem, dimension, extra );
  13553. } ) :
  13554. getWidthOrHeight( elem, dimension, extra );
  13555. }
  13556. },
  13557. set: function( elem, value, extra ) {
  13558. var matches,
  13559. styles = getStyles( elem ),
  13560. // Only read styles.position if the test has a chance to fail
  13561. // to avoid forcing a reflow.
  13562. scrollboxSizeBuggy = !support.scrollboxSize() &&
  13563. styles.position === "absolute",
  13564. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  13565. boxSizingNeeded = scrollboxSizeBuggy || extra,
  13566. isBorderBox = boxSizingNeeded &&
  13567. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  13568. subtract = extra ?
  13569. boxModelAdjustment(
  13570. elem,
  13571. dimension,
  13572. extra,
  13573. isBorderBox,
  13574. styles
  13575. ) :
  13576. 0;
  13577. // Account for unreliable border-box dimensions by comparing offset* to computed and
  13578. // faking a content-box to get border and padding (gh-3699)
  13579. if ( isBorderBox && scrollboxSizeBuggy ) {
  13580. subtract -= Math.ceil(
  13581. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  13582. parseFloat( styles[ dimension ] ) -
  13583. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  13584. 0.5
  13585. );
  13586. }
  13587. // Convert to pixels if value adjustment is needed
  13588. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  13589. ( matches[ 3 ] || "px" ) !== "px" ) {
  13590. elem.style[ dimension ] = value;
  13591. value = jQuery.css( elem, dimension );
  13592. }
  13593. return setPositiveNumber( elem, value, subtract );
  13594. }
  13595. };
  13596. } );
  13597. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  13598. function( elem, computed ) {
  13599. if ( computed ) {
  13600. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  13601. elem.getBoundingClientRect().left -
  13602. swap( elem, { marginLeft: 0 }, function() {
  13603. return elem.getBoundingClientRect().left;
  13604. } )
  13605. ) + "px";
  13606. }
  13607. }
  13608. );
  13609. // These hooks are used by animate to expand properties
  13610. jQuery.each( {
  13611. margin: "",
  13612. padding: "",
  13613. border: "Width"
  13614. }, function( prefix, suffix ) {
  13615. jQuery.cssHooks[ prefix + suffix ] = {
  13616. expand: function( value ) {
  13617. var i = 0,
  13618. expanded = {},
  13619. // Assumes a single number if not a string
  13620. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  13621. for ( ; i < 4; i++ ) {
  13622. expanded[ prefix + cssExpand[ i ] + suffix ] =
  13623. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  13624. }
  13625. return expanded;
  13626. }
  13627. };
  13628. if ( prefix !== "margin" ) {
  13629. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  13630. }
  13631. } );
  13632. jQuery.fn.extend( {
  13633. css: function( name, value ) {
  13634. return access( this, function( elem, name, value ) {
  13635. var styles, len,
  13636. map = {},
  13637. i = 0;
  13638. if ( Array.isArray( name ) ) {
  13639. styles = getStyles( elem );
  13640. len = name.length;
  13641. for ( ; i < len; i++ ) {
  13642. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  13643. }
  13644. return map;
  13645. }
  13646. return value !== undefined ?
  13647. jQuery.style( elem, name, value ) :
  13648. jQuery.css( elem, name );
  13649. }, name, value, arguments.length > 1 );
  13650. }
  13651. } );
  13652. function Tween( elem, options, prop, end, easing ) {
  13653. return new Tween.prototype.init( elem, options, prop, end, easing );
  13654. }
  13655. jQuery.Tween = Tween;
  13656. Tween.prototype = {
  13657. constructor: Tween,
  13658. init: function( elem, options, prop, end, easing, unit ) {
  13659. this.elem = elem;
  13660. this.prop = prop;
  13661. this.easing = easing || jQuery.easing._default;
  13662. this.options = options;
  13663. this.start = this.now = this.cur();
  13664. this.end = end;
  13665. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  13666. },
  13667. cur: function() {
  13668. var hooks = Tween.propHooks[ this.prop ];
  13669. return hooks && hooks.get ?
  13670. hooks.get( this ) :
  13671. Tween.propHooks._default.get( this );
  13672. },
  13673. run: function( percent ) {
  13674. var eased,
  13675. hooks = Tween.propHooks[ this.prop ];
  13676. if ( this.options.duration ) {
  13677. this.pos = eased = jQuery.easing[ this.easing ](
  13678. percent, this.options.duration * percent, 0, 1, this.options.duration
  13679. );
  13680. } else {
  13681. this.pos = eased = percent;
  13682. }
  13683. this.now = ( this.end - this.start ) * eased + this.start;
  13684. if ( this.options.step ) {
  13685. this.options.step.call( this.elem, this.now, this );
  13686. }
  13687. if ( hooks && hooks.set ) {
  13688. hooks.set( this );
  13689. } else {
  13690. Tween.propHooks._default.set( this );
  13691. }
  13692. return this;
  13693. }
  13694. };
  13695. Tween.prototype.init.prototype = Tween.prototype;
  13696. Tween.propHooks = {
  13697. _default: {
  13698. get: function( tween ) {
  13699. var result;
  13700. // Use a property on the element directly when it is not a DOM element,
  13701. // or when there is no matching style property that exists.
  13702. if ( tween.elem.nodeType !== 1 ||
  13703. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  13704. return tween.elem[ tween.prop ];
  13705. }
  13706. // Passing an empty string as a 3rd parameter to .css will automatically
  13707. // attempt a parseFloat and fallback to a string if the parse fails.
  13708. // Simple values such as "10px" are parsed to Float;
  13709. // complex values such as "rotate(1rad)" are returned as-is.
  13710. result = jQuery.css( tween.elem, tween.prop, "" );
  13711. // Empty strings, null, undefined and "auto" are converted to 0.
  13712. return !result || result === "auto" ? 0 : result;
  13713. },
  13714. set: function( tween ) {
  13715. // Use step hook for back compat.
  13716. // Use cssHook if its there.
  13717. // Use .style if available and use plain properties where available.
  13718. if ( jQuery.fx.step[ tween.prop ] ) {
  13719. jQuery.fx.step[ tween.prop ]( tween );
  13720. } else if ( tween.elem.nodeType === 1 && (
  13721. jQuery.cssHooks[ tween.prop ] ||
  13722. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  13723. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  13724. } else {
  13725. tween.elem[ tween.prop ] = tween.now;
  13726. }
  13727. }
  13728. }
  13729. };
  13730. // Support: IE <=9 only
  13731. // Panic based approach to setting things on disconnected nodes
  13732. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  13733. set: function( tween ) {
  13734. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  13735. tween.elem[ tween.prop ] = tween.now;
  13736. }
  13737. }
  13738. };
  13739. jQuery.easing = {
  13740. linear: function( p ) {
  13741. return p;
  13742. },
  13743. swing: function( p ) {
  13744. return 0.5 - Math.cos( p * Math.PI ) / 2;
  13745. },
  13746. _default: "swing"
  13747. };
  13748. jQuery.fx = Tween.prototype.init;
  13749. // Back compat <1.8 extension point
  13750. jQuery.fx.step = {};
  13751. var
  13752. fxNow, inProgress,
  13753. rfxtypes = /^(?:toggle|show|hide)$/,
  13754. rrun = /queueHooks$/;
  13755. function schedule() {
  13756. if ( inProgress ) {
  13757. if ( document.hidden === false && window.requestAnimationFrame ) {
  13758. window.requestAnimationFrame( schedule );
  13759. } else {
  13760. window.setTimeout( schedule, jQuery.fx.interval );
  13761. }
  13762. jQuery.fx.tick();
  13763. }
  13764. }
  13765. // Animations created synchronously will run synchronously
  13766. function createFxNow() {
  13767. window.setTimeout( function() {
  13768. fxNow = undefined;
  13769. } );
  13770. return ( fxNow = Date.now() );
  13771. }
  13772. // Generate parameters to create a standard animation
  13773. function genFx( type, includeWidth ) {
  13774. var which,
  13775. i = 0,
  13776. attrs = { height: type };
  13777. // If we include width, step value is 1 to do all cssExpand values,
  13778. // otherwise step value is 2 to skip over Left and Right
  13779. includeWidth = includeWidth ? 1 : 0;
  13780. for ( ; i < 4; i += 2 - includeWidth ) {
  13781. which = cssExpand[ i ];
  13782. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  13783. }
  13784. if ( includeWidth ) {
  13785. attrs.opacity = attrs.width = type;
  13786. }
  13787. return attrs;
  13788. }
  13789. function createTween( value, prop, animation ) {
  13790. var tween,
  13791. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  13792. index = 0,
  13793. length = collection.length;
  13794. for ( ; index < length; index++ ) {
  13795. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  13796. // We're done with this property
  13797. return tween;
  13798. }
  13799. }
  13800. }
  13801. function defaultPrefilter( elem, props, opts ) {
  13802. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  13803. isBox = "width" in props || "height" in props,
  13804. anim = this,
  13805. orig = {},
  13806. style = elem.style,
  13807. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  13808. dataShow = dataPriv.get( elem, "fxshow" );
  13809. // Queue-skipping animations hijack the fx hooks
  13810. if ( !opts.queue ) {
  13811. hooks = jQuery._queueHooks( elem, "fx" );
  13812. if ( hooks.unqueued == null ) {
  13813. hooks.unqueued = 0;
  13814. oldfire = hooks.empty.fire;
  13815. hooks.empty.fire = function() {
  13816. if ( !hooks.unqueued ) {
  13817. oldfire();
  13818. }
  13819. };
  13820. }
  13821. hooks.unqueued++;
  13822. anim.always( function() {
  13823. // Ensure the complete handler is called before this completes
  13824. anim.always( function() {
  13825. hooks.unqueued--;
  13826. if ( !jQuery.queue( elem, "fx" ).length ) {
  13827. hooks.empty.fire();
  13828. }
  13829. } );
  13830. } );
  13831. }
  13832. // Detect show/hide animations
  13833. for ( prop in props ) {
  13834. value = props[ prop ];
  13835. if ( rfxtypes.test( value ) ) {
  13836. delete props[ prop ];
  13837. toggle = toggle || value === "toggle";
  13838. if ( value === ( hidden ? "hide" : "show" ) ) {
  13839. // Pretend to be hidden if this is a "show" and
  13840. // there is still data from a stopped show/hide
  13841. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  13842. hidden = true;
  13843. // Ignore all other no-op show/hide data
  13844. } else {
  13845. continue;
  13846. }
  13847. }
  13848. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  13849. }
  13850. }
  13851. // Bail out if this is a no-op like .hide().hide()
  13852. propTween = !jQuery.isEmptyObject( props );
  13853. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  13854. return;
  13855. }
  13856. // Restrict "overflow" and "display" styles during box animations
  13857. if ( isBox && elem.nodeType === 1 ) {
  13858. // Support: IE <=9 - 11, Edge 12 - 15
  13859. // Record all 3 overflow attributes because IE does not infer the shorthand
  13860. // from identically-valued overflowX and overflowY and Edge just mirrors
  13861. // the overflowX value there.
  13862. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  13863. // Identify a display type, preferring old show/hide data over the CSS cascade
  13864. restoreDisplay = dataShow && dataShow.display;
  13865. if ( restoreDisplay == null ) {
  13866. restoreDisplay = dataPriv.get( elem, "display" );
  13867. }
  13868. display = jQuery.css( elem, "display" );
  13869. if ( display === "none" ) {
  13870. if ( restoreDisplay ) {
  13871. display = restoreDisplay;
  13872. } else {
  13873. // Get nonempty value(s) by temporarily forcing visibility
  13874. showHide( [ elem ], true );
  13875. restoreDisplay = elem.style.display || restoreDisplay;
  13876. display = jQuery.css( elem, "display" );
  13877. showHide( [ elem ] );
  13878. }
  13879. }
  13880. // Animate inline elements as inline-block
  13881. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  13882. if ( jQuery.css( elem, "float" ) === "none" ) {
  13883. // Restore the original display value at the end of pure show/hide animations
  13884. if ( !propTween ) {
  13885. anim.done( function() {
  13886. style.display = restoreDisplay;
  13887. } );
  13888. if ( restoreDisplay == null ) {
  13889. display = style.display;
  13890. restoreDisplay = display === "none" ? "" : display;
  13891. }
  13892. }
  13893. style.display = "inline-block";
  13894. }
  13895. }
  13896. }
  13897. if ( opts.overflow ) {
  13898. style.overflow = "hidden";
  13899. anim.always( function() {
  13900. style.overflow = opts.overflow[ 0 ];
  13901. style.overflowX = opts.overflow[ 1 ];
  13902. style.overflowY = opts.overflow[ 2 ];
  13903. } );
  13904. }
  13905. // Implement show/hide animations
  13906. propTween = false;
  13907. for ( prop in orig ) {
  13908. // General show/hide setup for this element animation
  13909. if ( !propTween ) {
  13910. if ( dataShow ) {
  13911. if ( "hidden" in dataShow ) {
  13912. hidden = dataShow.hidden;
  13913. }
  13914. } else {
  13915. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  13916. }
  13917. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  13918. if ( toggle ) {
  13919. dataShow.hidden = !hidden;
  13920. }
  13921. // Show elements before animating them
  13922. if ( hidden ) {
  13923. showHide( [ elem ], true );
  13924. }
  13925. /* eslint-disable no-loop-func */
  13926. anim.done( function() {
  13927. /* eslint-enable no-loop-func */
  13928. // The final step of a "hide" animation is actually hiding the element
  13929. if ( !hidden ) {
  13930. showHide( [ elem ] );
  13931. }
  13932. dataPriv.remove( elem, "fxshow" );
  13933. for ( prop in orig ) {
  13934. jQuery.style( elem, prop, orig[ prop ] );
  13935. }
  13936. } );
  13937. }
  13938. // Per-property setup
  13939. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  13940. if ( !( prop in dataShow ) ) {
  13941. dataShow[ prop ] = propTween.start;
  13942. if ( hidden ) {
  13943. propTween.end = propTween.start;
  13944. propTween.start = 0;
  13945. }
  13946. }
  13947. }
  13948. }
  13949. function propFilter( props, specialEasing ) {
  13950. var index, name, easing, value, hooks;
  13951. // camelCase, specialEasing and expand cssHook pass
  13952. for ( index in props ) {
  13953. name = camelCase( index );
  13954. easing = specialEasing[ name ];
  13955. value = props[ index ];
  13956. if ( Array.isArray( value ) ) {
  13957. easing = value[ 1 ];
  13958. value = props[ index ] = value[ 0 ];
  13959. }
  13960. if ( index !== name ) {
  13961. props[ name ] = value;
  13962. delete props[ index ];
  13963. }
  13964. hooks = jQuery.cssHooks[ name ];
  13965. if ( hooks && "expand" in hooks ) {
  13966. value = hooks.expand( value );
  13967. delete props[ name ];
  13968. // Not quite $.extend, this won't overwrite existing keys.
  13969. // Reusing 'index' because we have the correct "name"
  13970. for ( index in value ) {
  13971. if ( !( index in props ) ) {
  13972. props[ index ] = value[ index ];
  13973. specialEasing[ index ] = easing;
  13974. }
  13975. }
  13976. } else {
  13977. specialEasing[ name ] = easing;
  13978. }
  13979. }
  13980. }
  13981. function Animation( elem, properties, options ) {
  13982. var result,
  13983. stopped,
  13984. index = 0,
  13985. length = Animation.prefilters.length,
  13986. deferred = jQuery.Deferred().always( function() {
  13987. // Don't match elem in the :animated selector
  13988. delete tick.elem;
  13989. } ),
  13990. tick = function() {
  13991. if ( stopped ) {
  13992. return false;
  13993. }
  13994. var currentTime = fxNow || createFxNow(),
  13995. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  13996. // Support: Android 2.3 only
  13997. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  13998. temp = remaining / animation.duration || 0,
  13999. percent = 1 - temp,
  14000. index = 0,
  14001. length = animation.tweens.length;
  14002. for ( ; index < length; index++ ) {
  14003. animation.tweens[ index ].run( percent );
  14004. }
  14005. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  14006. // If there's more to do, yield
  14007. if ( percent < 1 && length ) {
  14008. return remaining;
  14009. }
  14010. // If this was an empty animation, synthesize a final progress notification
  14011. if ( !length ) {
  14012. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  14013. }
  14014. // Resolve the animation and report its conclusion
  14015. deferred.resolveWith( elem, [ animation ] );
  14016. return false;
  14017. },
  14018. animation = deferred.promise( {
  14019. elem: elem,
  14020. props: jQuery.extend( {}, properties ),
  14021. opts: jQuery.extend( true, {
  14022. specialEasing: {},
  14023. easing: jQuery.easing._default
  14024. }, options ),
  14025. originalProperties: properties,
  14026. originalOptions: options,
  14027. startTime: fxNow || createFxNow(),
  14028. duration: options.duration,
  14029. tweens: [],
  14030. createTween: function( prop, end ) {
  14031. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  14032. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  14033. animation.tweens.push( tween );
  14034. return tween;
  14035. },
  14036. stop: function( gotoEnd ) {
  14037. var index = 0,
  14038. // If we are going to the end, we want to run all the tweens
  14039. // otherwise we skip this part
  14040. length = gotoEnd ? animation.tweens.length : 0;
  14041. if ( stopped ) {
  14042. return this;
  14043. }
  14044. stopped = true;
  14045. for ( ; index < length; index++ ) {
  14046. animation.tweens[ index ].run( 1 );
  14047. }
  14048. // Resolve when we played the last frame; otherwise, reject
  14049. if ( gotoEnd ) {
  14050. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  14051. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  14052. } else {
  14053. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  14054. }
  14055. return this;
  14056. }
  14057. } ),
  14058. props = animation.props;
  14059. propFilter( props, animation.opts.specialEasing );
  14060. for ( ; index < length; index++ ) {
  14061. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  14062. if ( result ) {
  14063. if ( isFunction( result.stop ) ) {
  14064. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  14065. result.stop.bind( result );
  14066. }
  14067. return result;
  14068. }
  14069. }
  14070. jQuery.map( props, createTween, animation );
  14071. if ( isFunction( animation.opts.start ) ) {
  14072. animation.opts.start.call( elem, animation );
  14073. }
  14074. // Attach callbacks from options
  14075. animation
  14076. .progress( animation.opts.progress )
  14077. .done( animation.opts.done, animation.opts.complete )
  14078. .fail( animation.opts.fail )
  14079. .always( animation.opts.always );
  14080. jQuery.fx.timer(
  14081. jQuery.extend( tick, {
  14082. elem: elem,
  14083. anim: animation,
  14084. queue: animation.opts.queue
  14085. } )
  14086. );
  14087. return animation;
  14088. }
  14089. jQuery.Animation = jQuery.extend( Animation, {
  14090. tweeners: {
  14091. "*": [ function( prop, value ) {
  14092. var tween = this.createTween( prop, value );
  14093. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  14094. return tween;
  14095. } ]
  14096. },
  14097. tweener: function( props, callback ) {
  14098. if ( isFunction( props ) ) {
  14099. callback = props;
  14100. props = [ "*" ];
  14101. } else {
  14102. props = props.match( rnothtmlwhite );
  14103. }
  14104. var prop,
  14105. index = 0,
  14106. length = props.length;
  14107. for ( ; index < length; index++ ) {
  14108. prop = props[ index ];
  14109. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  14110. Animation.tweeners[ prop ].unshift( callback );
  14111. }
  14112. },
  14113. prefilters: [ defaultPrefilter ],
  14114. prefilter: function( callback, prepend ) {
  14115. if ( prepend ) {
  14116. Animation.prefilters.unshift( callback );
  14117. } else {
  14118. Animation.prefilters.push( callback );
  14119. }
  14120. }
  14121. } );
  14122. jQuery.speed = function( speed, easing, fn ) {
  14123. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  14124. complete: fn || !fn && easing ||
  14125. isFunction( speed ) && speed,
  14126. duration: speed,
  14127. easing: fn && easing || easing && !isFunction( easing ) && easing
  14128. };
  14129. // Go to the end state if fx are off
  14130. if ( jQuery.fx.off ) {
  14131. opt.duration = 0;
  14132. } else {
  14133. if ( typeof opt.duration !== "number" ) {
  14134. if ( opt.duration in jQuery.fx.speeds ) {
  14135. opt.duration = jQuery.fx.speeds[ opt.duration ];
  14136. } else {
  14137. opt.duration = jQuery.fx.speeds._default;
  14138. }
  14139. }
  14140. }
  14141. // Normalize opt.queue - true/undefined/null -> "fx"
  14142. if ( opt.queue == null || opt.queue === true ) {
  14143. opt.queue = "fx";
  14144. }
  14145. // Queueing
  14146. opt.old = opt.complete;
  14147. opt.complete = function() {
  14148. if ( isFunction( opt.old ) ) {
  14149. opt.old.call( this );
  14150. }
  14151. if ( opt.queue ) {
  14152. jQuery.dequeue( this, opt.queue );
  14153. }
  14154. };
  14155. return opt;
  14156. };
  14157. jQuery.fn.extend( {
  14158. fadeTo: function( speed, to, easing, callback ) {
  14159. // Show any hidden elements after setting opacity to 0
  14160. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  14161. // Animate to the value specified
  14162. .end().animate( { opacity: to }, speed, easing, callback );
  14163. },
  14164. animate: function( prop, speed, easing, callback ) {
  14165. var empty = jQuery.isEmptyObject( prop ),
  14166. optall = jQuery.speed( speed, easing, callback ),
  14167. doAnimation = function() {
  14168. // Operate on a copy of prop so per-property easing won't be lost
  14169. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  14170. // Empty animations, or finishing resolves immediately
  14171. if ( empty || dataPriv.get( this, "finish" ) ) {
  14172. anim.stop( true );
  14173. }
  14174. };
  14175. doAnimation.finish = doAnimation;
  14176. return empty || optall.queue === false ?
  14177. this.each( doAnimation ) :
  14178. this.queue( optall.queue, doAnimation );
  14179. },
  14180. stop: function( type, clearQueue, gotoEnd ) {
  14181. var stopQueue = function( hooks ) {
  14182. var stop = hooks.stop;
  14183. delete hooks.stop;
  14184. stop( gotoEnd );
  14185. };
  14186. if ( typeof type !== "string" ) {
  14187. gotoEnd = clearQueue;
  14188. clearQueue = type;
  14189. type = undefined;
  14190. }
  14191. if ( clearQueue && type !== false ) {
  14192. this.queue( type || "fx", [] );
  14193. }
  14194. return this.each( function() {
  14195. var dequeue = true,
  14196. index = type != null && type + "queueHooks",
  14197. timers = jQuery.timers,
  14198. data = dataPriv.get( this );
  14199. if ( index ) {
  14200. if ( data[ index ] && data[ index ].stop ) {
  14201. stopQueue( data[ index ] );
  14202. }
  14203. } else {
  14204. for ( index in data ) {
  14205. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  14206. stopQueue( data[ index ] );
  14207. }
  14208. }
  14209. }
  14210. for ( index = timers.length; index--; ) {
  14211. if ( timers[ index ].elem === this &&
  14212. ( type == null || timers[ index ].queue === type ) ) {
  14213. timers[ index ].anim.stop( gotoEnd );
  14214. dequeue = false;
  14215. timers.splice( index, 1 );
  14216. }
  14217. }
  14218. // Start the next in the queue if the last step wasn't forced.
  14219. // Timers currently will call their complete callbacks, which
  14220. // will dequeue but only if they were gotoEnd.
  14221. if ( dequeue || !gotoEnd ) {
  14222. jQuery.dequeue( this, type );
  14223. }
  14224. } );
  14225. },
  14226. finish: function( type ) {
  14227. if ( type !== false ) {
  14228. type = type || "fx";
  14229. }
  14230. return this.each( function() {
  14231. var index,
  14232. data = dataPriv.get( this ),
  14233. queue = data[ type + "queue" ],
  14234. hooks = data[ type + "queueHooks" ],
  14235. timers = jQuery.timers,
  14236. length = queue ? queue.length : 0;
  14237. // Enable finishing flag on private data
  14238. data.finish = true;
  14239. // Empty the queue first
  14240. jQuery.queue( this, type, [] );
  14241. if ( hooks && hooks.stop ) {
  14242. hooks.stop.call( this, true );
  14243. }
  14244. // Look for any active animations, and finish them
  14245. for ( index = timers.length; index--; ) {
  14246. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  14247. timers[ index ].anim.stop( true );
  14248. timers.splice( index, 1 );
  14249. }
  14250. }
  14251. // Look for any animations in the old queue and finish them
  14252. for ( index = 0; index < length; index++ ) {
  14253. if ( queue[ index ] && queue[ index ].finish ) {
  14254. queue[ index ].finish.call( this );
  14255. }
  14256. }
  14257. // Turn off finishing flag
  14258. delete data.finish;
  14259. } );
  14260. }
  14261. } );
  14262. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  14263. var cssFn = jQuery.fn[ name ];
  14264. jQuery.fn[ name ] = function( speed, easing, callback ) {
  14265. return speed == null || typeof speed === "boolean" ?
  14266. cssFn.apply( this, arguments ) :
  14267. this.animate( genFx( name, true ), speed, easing, callback );
  14268. };
  14269. } );
  14270. // Generate shortcuts for custom animations
  14271. jQuery.each( {
  14272. slideDown: genFx( "show" ),
  14273. slideUp: genFx( "hide" ),
  14274. slideToggle: genFx( "toggle" ),
  14275. fadeIn: { opacity: "show" },
  14276. fadeOut: { opacity: "hide" },
  14277. fadeToggle: { opacity: "toggle" }
  14278. }, function( name, props ) {
  14279. jQuery.fn[ name ] = function( speed, easing, callback ) {
  14280. return this.animate( props, speed, easing, callback );
  14281. };
  14282. } );
  14283. jQuery.timers = [];
  14284. jQuery.fx.tick = function() {
  14285. var timer,
  14286. i = 0,
  14287. timers = jQuery.timers;
  14288. fxNow = Date.now();
  14289. for ( ; i < timers.length; i++ ) {
  14290. timer = timers[ i ];
  14291. // Run the timer and safely remove it when done (allowing for external removal)
  14292. if ( !timer() && timers[ i ] === timer ) {
  14293. timers.splice( i--, 1 );
  14294. }
  14295. }
  14296. if ( !timers.length ) {
  14297. jQuery.fx.stop();
  14298. }
  14299. fxNow = undefined;
  14300. };
  14301. jQuery.fx.timer = function( timer ) {
  14302. jQuery.timers.push( timer );
  14303. jQuery.fx.start();
  14304. };
  14305. jQuery.fx.interval = 13;
  14306. jQuery.fx.start = function() {
  14307. if ( inProgress ) {
  14308. return;
  14309. }
  14310. inProgress = true;
  14311. schedule();
  14312. };
  14313. jQuery.fx.stop = function() {
  14314. inProgress = null;
  14315. };
  14316. jQuery.fx.speeds = {
  14317. slow: 600,
  14318. fast: 200,
  14319. // Default speed
  14320. _default: 400
  14321. };
  14322. // Based off of the plugin by Clint Helfers, with permission.
  14323. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  14324. jQuery.fn.delay = function( time, type ) {
  14325. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  14326. type = type || "fx";
  14327. return this.queue( type, function( next, hooks ) {
  14328. var timeout = window.setTimeout( next, time );
  14329. hooks.stop = function() {
  14330. window.clearTimeout( timeout );
  14331. };
  14332. } );
  14333. };
  14334. ( function() {
  14335. var input = document.createElement( "input" ),
  14336. select = document.createElement( "select" ),
  14337. opt = select.appendChild( document.createElement( "option" ) );
  14338. input.type = "checkbox";
  14339. // Support: Android <=4.3 only
  14340. // Default value for a checkbox should be "on"
  14341. support.checkOn = input.value !== "";
  14342. // Support: IE <=11 only
  14343. // Must access selectedIndex to make default options select
  14344. support.optSelected = opt.selected;
  14345. // Support: IE <=11 only
  14346. // An input loses its value after becoming a radio
  14347. input = document.createElement( "input" );
  14348. input.value = "t";
  14349. input.type = "radio";
  14350. support.radioValue = input.value === "t";
  14351. } )();
  14352. var boolHook,
  14353. attrHandle = jQuery.expr.attrHandle;
  14354. jQuery.fn.extend( {
  14355. attr: function( name, value ) {
  14356. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  14357. },
  14358. removeAttr: function( name ) {
  14359. return this.each( function() {
  14360. jQuery.removeAttr( this, name );
  14361. } );
  14362. }
  14363. } );
  14364. jQuery.extend( {
  14365. attr: function( elem, name, value ) {
  14366. var ret, hooks,
  14367. nType = elem.nodeType;
  14368. // Don't get/set attributes on text, comment and attribute nodes
  14369. if ( nType === 3 || nType === 8 || nType === 2 ) {
  14370. return;
  14371. }
  14372. // Fallback to prop when attributes are not supported
  14373. if ( typeof elem.getAttribute === "undefined" ) {
  14374. return jQuery.prop( elem, name, value );
  14375. }
  14376. // Attribute hooks are determined by the lowercase version
  14377. // Grab necessary hook if one is defined
  14378. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  14379. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  14380. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  14381. }
  14382. if ( value !== undefined ) {
  14383. if ( value === null ) {
  14384. jQuery.removeAttr( elem, name );
  14385. return;
  14386. }
  14387. if ( hooks && "set" in hooks &&
  14388. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  14389. return ret;
  14390. }
  14391. elem.setAttribute( name, value + "" );
  14392. return value;
  14393. }
  14394. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  14395. return ret;
  14396. }
  14397. ret = jQuery.find.attr( elem, name );
  14398. // Non-existent attributes return null, we normalize to undefined
  14399. return ret == null ? undefined : ret;
  14400. },
  14401. attrHooks: {
  14402. type: {
  14403. set: function( elem, value ) {
  14404. if ( !support.radioValue && value === "radio" &&
  14405. nodeName( elem, "input" ) ) {
  14406. var val = elem.value;
  14407. elem.setAttribute( "type", value );
  14408. if ( val ) {
  14409. elem.value = val;
  14410. }
  14411. return value;
  14412. }
  14413. }
  14414. }
  14415. },
  14416. removeAttr: function( elem, value ) {
  14417. var name,
  14418. i = 0,
  14419. // Attribute names can contain non-HTML whitespace characters
  14420. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  14421. attrNames = value && value.match( rnothtmlwhite );
  14422. if ( attrNames && elem.nodeType === 1 ) {
  14423. while ( ( name = attrNames[ i++ ] ) ) {
  14424. elem.removeAttribute( name );
  14425. }
  14426. }
  14427. }
  14428. } );
  14429. // Hooks for boolean attributes
  14430. boolHook = {
  14431. set: function( elem, value, name ) {
  14432. if ( value === false ) {
  14433. // Remove boolean attributes when set to false
  14434. jQuery.removeAttr( elem, name );
  14435. } else {
  14436. elem.setAttribute( name, name );
  14437. }
  14438. return name;
  14439. }
  14440. };
  14441. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  14442. var getter = attrHandle[ name ] || jQuery.find.attr;
  14443. attrHandle[ name ] = function( elem, name, isXML ) {
  14444. var ret, handle,
  14445. lowercaseName = name.toLowerCase();
  14446. if ( !isXML ) {
  14447. // Avoid an infinite loop by temporarily removing this function from the getter
  14448. handle = attrHandle[ lowercaseName ];
  14449. attrHandle[ lowercaseName ] = ret;
  14450. ret = getter( elem, name, isXML ) != null ?
  14451. lowercaseName :
  14452. null;
  14453. attrHandle[ lowercaseName ] = handle;
  14454. }
  14455. return ret;
  14456. };
  14457. } );
  14458. var rfocusable = /^(?:input|select|textarea|button)$/i,
  14459. rclickable = /^(?:a|area)$/i;
  14460. jQuery.fn.extend( {
  14461. prop: function( name, value ) {
  14462. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  14463. },
  14464. removeProp: function( name ) {
  14465. return this.each( function() {
  14466. delete this[ jQuery.propFix[ name ] || name ];
  14467. } );
  14468. }
  14469. } );
  14470. jQuery.extend( {
  14471. prop: function( elem, name, value ) {
  14472. var ret, hooks,
  14473. nType = elem.nodeType;
  14474. // Don't get/set properties on text, comment and attribute nodes
  14475. if ( nType === 3 || nType === 8 || nType === 2 ) {
  14476. return;
  14477. }
  14478. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  14479. // Fix name and attach hooks
  14480. name = jQuery.propFix[ name ] || name;
  14481. hooks = jQuery.propHooks[ name ];
  14482. }
  14483. if ( value !== undefined ) {
  14484. if ( hooks && "set" in hooks &&
  14485. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  14486. return ret;
  14487. }
  14488. return ( elem[ name ] = value );
  14489. }
  14490. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  14491. return ret;
  14492. }
  14493. return elem[ name ];
  14494. },
  14495. propHooks: {
  14496. tabIndex: {
  14497. get: function( elem ) {
  14498. // Support: IE <=9 - 11 only
  14499. // elem.tabIndex doesn't always return the
  14500. // correct value when it hasn't been explicitly set
  14501. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  14502. // Use proper attribute retrieval(#12072)
  14503. var tabindex = jQuery.find.attr( elem, "tabindex" );
  14504. if ( tabindex ) {
  14505. return parseInt( tabindex, 10 );
  14506. }
  14507. if (
  14508. rfocusable.test( elem.nodeName ) ||
  14509. rclickable.test( elem.nodeName ) &&
  14510. elem.href
  14511. ) {
  14512. return 0;
  14513. }
  14514. return -1;
  14515. }
  14516. }
  14517. },
  14518. propFix: {
  14519. "for": "htmlFor",
  14520. "class": "className"
  14521. }
  14522. } );
  14523. // Support: IE <=11 only
  14524. // Accessing the selectedIndex property
  14525. // forces the browser to respect setting selected
  14526. // on the option
  14527. // The getter ensures a default option is selected
  14528. // when in an optgroup
  14529. // eslint rule "no-unused-expressions" is disabled for this code
  14530. // since it considers such accessions noop
  14531. if ( !support.optSelected ) {
  14532. jQuery.propHooks.selected = {
  14533. get: function( elem ) {
  14534. /* eslint no-unused-expressions: "off" */
  14535. var parent = elem.parentNode;
  14536. if ( parent && parent.parentNode ) {
  14537. parent.parentNode.selectedIndex;
  14538. }
  14539. return null;
  14540. },
  14541. set: function( elem ) {
  14542. /* eslint no-unused-expressions: "off" */
  14543. var parent = elem.parentNode;
  14544. if ( parent ) {
  14545. parent.selectedIndex;
  14546. if ( parent.parentNode ) {
  14547. parent.parentNode.selectedIndex;
  14548. }
  14549. }
  14550. }
  14551. };
  14552. }
  14553. jQuery.each( [
  14554. "tabIndex",
  14555. "readOnly",
  14556. "maxLength",
  14557. "cellSpacing",
  14558. "cellPadding",
  14559. "rowSpan",
  14560. "colSpan",
  14561. "useMap",
  14562. "frameBorder",
  14563. "contentEditable"
  14564. ], function() {
  14565. jQuery.propFix[ this.toLowerCase() ] = this;
  14566. } );
  14567. // Strip and collapse whitespace according to HTML spec
  14568. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  14569. function stripAndCollapse( value ) {
  14570. var tokens = value.match( rnothtmlwhite ) || [];
  14571. return tokens.join( " " );
  14572. }
  14573. function getClass( elem ) {
  14574. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  14575. }
  14576. function classesToArray( value ) {
  14577. if ( Array.isArray( value ) ) {
  14578. return value;
  14579. }
  14580. if ( typeof value === "string" ) {
  14581. return value.match( rnothtmlwhite ) || [];
  14582. }
  14583. return [];
  14584. }
  14585. jQuery.fn.extend( {
  14586. addClass: function( value ) {
  14587. var classes, elem, cur, curValue, clazz, j, finalValue,
  14588. i = 0;
  14589. if ( isFunction( value ) ) {
  14590. return this.each( function( j ) {
  14591. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  14592. } );
  14593. }
  14594. classes = classesToArray( value );
  14595. if ( classes.length ) {
  14596. while ( ( elem = this[ i++ ] ) ) {
  14597. curValue = getClass( elem );
  14598. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  14599. if ( cur ) {
  14600. j = 0;
  14601. while ( ( clazz = classes[ j++ ] ) ) {
  14602. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  14603. cur += clazz + " ";
  14604. }
  14605. }
  14606. // Only assign if different to avoid unneeded rendering.
  14607. finalValue = stripAndCollapse( cur );
  14608. if ( curValue !== finalValue ) {
  14609. elem.setAttribute( "class", finalValue );
  14610. }
  14611. }
  14612. }
  14613. }
  14614. return this;
  14615. },
  14616. removeClass: function( value ) {
  14617. var classes, elem, cur, curValue, clazz, j, finalValue,
  14618. i = 0;
  14619. if ( isFunction( value ) ) {
  14620. return this.each( function( j ) {
  14621. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  14622. } );
  14623. }
  14624. if ( !arguments.length ) {
  14625. return this.attr( "class", "" );
  14626. }
  14627. classes = classesToArray( value );
  14628. if ( classes.length ) {
  14629. while ( ( elem = this[ i++ ] ) ) {
  14630. curValue = getClass( elem );
  14631. // This expression is here for better compressibility (see addClass)
  14632. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  14633. if ( cur ) {
  14634. j = 0;
  14635. while ( ( clazz = classes[ j++ ] ) ) {
  14636. // Remove *all* instances
  14637. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  14638. cur = cur.replace( " " + clazz + " ", " " );
  14639. }
  14640. }
  14641. // Only assign if different to avoid unneeded rendering.
  14642. finalValue = stripAndCollapse( cur );
  14643. if ( curValue !== finalValue ) {
  14644. elem.setAttribute( "class", finalValue );
  14645. }
  14646. }
  14647. }
  14648. }
  14649. return this;
  14650. },
  14651. toggleClass: function( value, stateVal ) {
  14652. var type = typeof value,
  14653. isValidValue = type === "string" || Array.isArray( value );
  14654. if ( typeof stateVal === "boolean" && isValidValue ) {
  14655. return stateVal ? this.addClass( value ) : this.removeClass( value );
  14656. }
  14657. if ( isFunction( value ) ) {
  14658. return this.each( function( i ) {
  14659. jQuery( this ).toggleClass(
  14660. value.call( this, i, getClass( this ), stateVal ),
  14661. stateVal
  14662. );
  14663. } );
  14664. }
  14665. return this.each( function() {
  14666. var className, i, self, classNames;
  14667. if ( isValidValue ) {
  14668. // Toggle individual class names
  14669. i = 0;
  14670. self = jQuery( this );
  14671. classNames = classesToArray( value );
  14672. while ( ( className = classNames[ i++ ] ) ) {
  14673. // Check each className given, space separated list
  14674. if ( self.hasClass( className ) ) {
  14675. self.removeClass( className );
  14676. } else {
  14677. self.addClass( className );
  14678. }
  14679. }
  14680. // Toggle whole class name
  14681. } else if ( value === undefined || type === "boolean" ) {
  14682. className = getClass( this );
  14683. if ( className ) {
  14684. // Store className if set
  14685. dataPriv.set( this, "__className__", className );
  14686. }
  14687. // If the element has a class name or if we're passed `false`,
  14688. // then remove the whole classname (if there was one, the above saved it).
  14689. // Otherwise bring back whatever was previously saved (if anything),
  14690. // falling back to the empty string if nothing was stored.
  14691. if ( this.setAttribute ) {
  14692. this.setAttribute( "class",
  14693. className || value === false ?
  14694. "" :
  14695. dataPriv.get( this, "__className__" ) || ""
  14696. );
  14697. }
  14698. }
  14699. } );
  14700. },
  14701. hasClass: function( selector ) {
  14702. var className, elem,
  14703. i = 0;
  14704. className = " " + selector + " ";
  14705. while ( ( elem = this[ i++ ] ) ) {
  14706. if ( elem.nodeType === 1 &&
  14707. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  14708. return true;
  14709. }
  14710. }
  14711. return false;
  14712. }
  14713. } );
  14714. var rreturn = /\r/g;
  14715. jQuery.fn.extend( {
  14716. val: function( value ) {
  14717. var hooks, ret, valueIsFunction,
  14718. elem = this[ 0 ];
  14719. if ( !arguments.length ) {
  14720. if ( elem ) {
  14721. hooks = jQuery.valHooks[ elem.type ] ||
  14722. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  14723. if ( hooks &&
  14724. "get" in hooks &&
  14725. ( ret = hooks.get( elem, "value" ) ) !== undefined
  14726. ) {
  14727. return ret;
  14728. }
  14729. ret = elem.value;
  14730. // Handle most common string cases
  14731. if ( typeof ret === "string" ) {
  14732. return ret.replace( rreturn, "" );
  14733. }
  14734. // Handle cases where value is null/undef or number
  14735. return ret == null ? "" : ret;
  14736. }
  14737. return;
  14738. }
  14739. valueIsFunction = isFunction( value );
  14740. return this.each( function( i ) {
  14741. var val;
  14742. if ( this.nodeType !== 1 ) {
  14743. return;
  14744. }
  14745. if ( valueIsFunction ) {
  14746. val = value.call( this, i, jQuery( this ).val() );
  14747. } else {
  14748. val = value;
  14749. }
  14750. // Treat null/undefined as ""; convert numbers to string
  14751. if ( val == null ) {
  14752. val = "";
  14753. } else if ( typeof val === "number" ) {
  14754. val += "";
  14755. } else if ( Array.isArray( val ) ) {
  14756. val = jQuery.map( val, function( value ) {
  14757. return value == null ? "" : value + "";
  14758. } );
  14759. }
  14760. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  14761. // If set returns undefined, fall back to normal setting
  14762. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  14763. this.value = val;
  14764. }
  14765. } );
  14766. }
  14767. } );
  14768. jQuery.extend( {
  14769. valHooks: {
  14770. option: {
  14771. get: function( elem ) {
  14772. var val = jQuery.find.attr( elem, "value" );
  14773. return val != null ?
  14774. val :
  14775. // Support: IE <=10 - 11 only
  14776. // option.text throws exceptions (#14686, #14858)
  14777. // Strip and collapse whitespace
  14778. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  14779. stripAndCollapse( jQuery.text( elem ) );
  14780. }
  14781. },
  14782. select: {
  14783. get: function( elem ) {
  14784. var value, option, i,
  14785. options = elem.options,
  14786. index = elem.selectedIndex,
  14787. one = elem.type === "select-one",
  14788. values = one ? null : [],
  14789. max = one ? index + 1 : options.length;
  14790. if ( index < 0 ) {
  14791. i = max;
  14792. } else {
  14793. i = one ? index : 0;
  14794. }
  14795. // Loop through all the selected options
  14796. for ( ; i < max; i++ ) {
  14797. option = options[ i ];
  14798. // Support: IE <=9 only
  14799. // IE8-9 doesn't update selected after form reset (#2551)
  14800. if ( ( option.selected || i === index ) &&
  14801. // Don't return options that are disabled or in a disabled optgroup
  14802. !option.disabled &&
  14803. ( !option.parentNode.disabled ||
  14804. !nodeName( option.parentNode, "optgroup" ) ) ) {
  14805. // Get the specific value for the option
  14806. value = jQuery( option ).val();
  14807. // We don't need an array for one selects
  14808. if ( one ) {
  14809. return value;
  14810. }
  14811. // Multi-Selects return an array
  14812. values.push( value );
  14813. }
  14814. }
  14815. return values;
  14816. },
  14817. set: function( elem, value ) {
  14818. var optionSet, option,
  14819. options = elem.options,
  14820. values = jQuery.makeArray( value ),
  14821. i = options.length;
  14822. while ( i-- ) {
  14823. option = options[ i ];
  14824. /* eslint-disable no-cond-assign */
  14825. if ( option.selected =
  14826. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  14827. ) {
  14828. optionSet = true;
  14829. }
  14830. /* eslint-enable no-cond-assign */
  14831. }
  14832. // Force browsers to behave consistently when non-matching value is set
  14833. if ( !optionSet ) {
  14834. elem.selectedIndex = -1;
  14835. }
  14836. return values;
  14837. }
  14838. }
  14839. }
  14840. } );
  14841. // Radios and checkboxes getter/setter
  14842. jQuery.each( [ "radio", "checkbox" ], function() {
  14843. jQuery.valHooks[ this ] = {
  14844. set: function( elem, value ) {
  14845. if ( Array.isArray( value ) ) {
  14846. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  14847. }
  14848. }
  14849. };
  14850. if ( !support.checkOn ) {
  14851. jQuery.valHooks[ this ].get = function( elem ) {
  14852. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  14853. };
  14854. }
  14855. } );
  14856. // Return jQuery for attributes-only inclusion
  14857. support.focusin = "onfocusin" in window;
  14858. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  14859. stopPropagationCallback = function( e ) {
  14860. e.stopPropagation();
  14861. };
  14862. jQuery.extend( jQuery.event, {
  14863. trigger: function( event, data, elem, onlyHandlers ) {
  14864. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  14865. eventPath = [ elem || document ],
  14866. type = hasOwn.call( event, "type" ) ? event.type : event,
  14867. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  14868. cur = lastElement = tmp = elem = elem || document;
  14869. // Don't do events on text and comment nodes
  14870. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  14871. return;
  14872. }
  14873. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  14874. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  14875. return;
  14876. }
  14877. if ( type.indexOf( "." ) > -1 ) {
  14878. // Namespaced trigger; create a regexp to match event type in handle()
  14879. namespaces = type.split( "." );
  14880. type = namespaces.shift();
  14881. namespaces.sort();
  14882. }
  14883. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  14884. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  14885. event = event[ jQuery.expando ] ?
  14886. event :
  14887. new jQuery.Event( type, typeof event === "object" && event );
  14888. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  14889. event.isTrigger = onlyHandlers ? 2 : 3;
  14890. event.namespace = namespaces.join( "." );
  14891. event.rnamespace = event.namespace ?
  14892. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  14893. null;
  14894. // Clean up the event in case it is being reused
  14895. event.result = undefined;
  14896. if ( !event.target ) {
  14897. event.target = elem;
  14898. }
  14899. // Clone any incoming data and prepend the event, creating the handler arg list
  14900. data = data == null ?
  14901. [ event ] :
  14902. jQuery.makeArray( data, [ event ] );
  14903. // Allow special events to draw outside the lines
  14904. special = jQuery.event.special[ type ] || {};
  14905. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  14906. return;
  14907. }
  14908. // Determine event propagation path in advance, per W3C events spec (#9951)
  14909. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  14910. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  14911. bubbleType = special.delegateType || type;
  14912. if ( !rfocusMorph.test( bubbleType + type ) ) {
  14913. cur = cur.parentNode;
  14914. }
  14915. for ( ; cur; cur = cur.parentNode ) {
  14916. eventPath.push( cur );
  14917. tmp = cur;
  14918. }
  14919. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  14920. if ( tmp === ( elem.ownerDocument || document ) ) {
  14921. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  14922. }
  14923. }
  14924. // Fire handlers on the event path
  14925. i = 0;
  14926. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  14927. lastElement = cur;
  14928. event.type = i > 1 ?
  14929. bubbleType :
  14930. special.bindType || type;
  14931. // jQuery handler
  14932. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  14933. dataPriv.get( cur, "handle" );
  14934. if ( handle ) {
  14935. handle.apply( cur, data );
  14936. }
  14937. // Native handler
  14938. handle = ontype && cur[ ontype ];
  14939. if ( handle && handle.apply && acceptData( cur ) ) {
  14940. event.result = handle.apply( cur, data );
  14941. if ( event.result === false ) {
  14942. event.preventDefault();
  14943. }
  14944. }
  14945. }
  14946. event.type = type;
  14947. // If nobody prevented the default action, do it now
  14948. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  14949. if ( ( !special._default ||
  14950. special._default.apply( eventPath.pop(), data ) === false ) &&
  14951. acceptData( elem ) ) {
  14952. // Call a native DOM method on the target with the same name as the event.
  14953. // Don't do default actions on window, that's where global variables be (#6170)
  14954. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  14955. // Don't re-trigger an onFOO event when we call its FOO() method
  14956. tmp = elem[ ontype ];
  14957. if ( tmp ) {
  14958. elem[ ontype ] = null;
  14959. }
  14960. // Prevent re-triggering of the same event, since we already bubbled it above
  14961. jQuery.event.triggered = type;
  14962. if ( event.isPropagationStopped() ) {
  14963. lastElement.addEventListener( type, stopPropagationCallback );
  14964. }
  14965. elem[ type ]();
  14966. if ( event.isPropagationStopped() ) {
  14967. lastElement.removeEventListener( type, stopPropagationCallback );
  14968. }
  14969. jQuery.event.triggered = undefined;
  14970. if ( tmp ) {
  14971. elem[ ontype ] = tmp;
  14972. }
  14973. }
  14974. }
  14975. }
  14976. return event.result;
  14977. },
  14978. // Piggyback on a donor event to simulate a different one
  14979. // Used only for `focus(in | out)` events
  14980. simulate: function( type, elem, event ) {
  14981. var e = jQuery.extend(
  14982. new jQuery.Event(),
  14983. event,
  14984. {
  14985. type: type,
  14986. isSimulated: true
  14987. }
  14988. );
  14989. jQuery.event.trigger( e, null, elem );
  14990. }
  14991. } );
  14992. jQuery.fn.extend( {
  14993. trigger: function( type, data ) {
  14994. return this.each( function() {
  14995. jQuery.event.trigger( type, data, this );
  14996. } );
  14997. },
  14998. triggerHandler: function( type, data ) {
  14999. var elem = this[ 0 ];
  15000. if ( elem ) {
  15001. return jQuery.event.trigger( type, data, elem, true );
  15002. }
  15003. }
  15004. } );
  15005. // Support: Firefox <=44
  15006. // Firefox doesn't have focus(in | out) events
  15007. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  15008. //
  15009. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  15010. // focus(in | out) events fire after focus & blur events,
  15011. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  15012. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  15013. if ( !support.focusin ) {
  15014. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  15015. // Attach a single capturing handler on the document while someone wants focusin/focusout
  15016. var handler = function( event ) {
  15017. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  15018. };
  15019. jQuery.event.special[ fix ] = {
  15020. setup: function() {
  15021. var doc = this.ownerDocument || this,
  15022. attaches = dataPriv.access( doc, fix );
  15023. if ( !attaches ) {
  15024. doc.addEventListener( orig, handler, true );
  15025. }
  15026. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  15027. },
  15028. teardown: function() {
  15029. var doc = this.ownerDocument || this,
  15030. attaches = dataPriv.access( doc, fix ) - 1;
  15031. if ( !attaches ) {
  15032. doc.removeEventListener( orig, handler, true );
  15033. dataPriv.remove( doc, fix );
  15034. } else {
  15035. dataPriv.access( doc, fix, attaches );
  15036. }
  15037. }
  15038. };
  15039. } );
  15040. }
  15041. var location = window.location;
  15042. var nonce = Date.now();
  15043. var rquery = ( /\?/ );
  15044. // Cross-browser xml parsing
  15045. jQuery.parseXML = function( data ) {
  15046. var xml;
  15047. if ( !data || typeof data !== "string" ) {
  15048. return null;
  15049. }
  15050. // Support: IE 9 - 11 only
  15051. // IE throws on parseFromString with invalid input.
  15052. try {
  15053. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  15054. } catch ( e ) {
  15055. xml = undefined;
  15056. }
  15057. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  15058. jQuery.error( "Invalid XML: " + data );
  15059. }
  15060. return xml;
  15061. };
  15062. var
  15063. rbracket = /\[\]$/,
  15064. rCRLF = /\r?\n/g,
  15065. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  15066. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  15067. function buildParams( prefix, obj, traditional, add ) {
  15068. var name;
  15069. if ( Array.isArray( obj ) ) {
  15070. // Serialize array item.
  15071. jQuery.each( obj, function( i, v ) {
  15072. if ( traditional || rbracket.test( prefix ) ) {
  15073. // Treat each array item as a scalar.
  15074. add( prefix, v );
  15075. } else {
  15076. // Item is non-scalar (array or object), encode its numeric index.
  15077. buildParams(
  15078. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  15079. v,
  15080. traditional,
  15081. add
  15082. );
  15083. }
  15084. } );
  15085. } else if ( !traditional && toType( obj ) === "object" ) {
  15086. // Serialize object item.
  15087. for ( name in obj ) {
  15088. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  15089. }
  15090. } else {
  15091. // Serialize scalar item.
  15092. add( prefix, obj );
  15093. }
  15094. }
  15095. // Serialize an array of form elements or a set of
  15096. // key/values into a query string
  15097. jQuery.param = function( a, traditional ) {
  15098. var prefix,
  15099. s = [],
  15100. add = function( key, valueOrFunction ) {
  15101. // If value is a function, invoke it and use its return value
  15102. var value = isFunction( valueOrFunction ) ?
  15103. valueOrFunction() :
  15104. valueOrFunction;
  15105. s[ s.length ] = encodeURIComponent( key ) + "=" +
  15106. encodeURIComponent( value == null ? "" : value );
  15107. };
  15108. if ( a == null ) {
  15109. return "";
  15110. }
  15111. // If an array was passed in, assume that it is an array of form elements.
  15112. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  15113. // Serialize the form elements
  15114. jQuery.each( a, function() {
  15115. add( this.name, this.value );
  15116. } );
  15117. } else {
  15118. // If traditional, encode the "old" way (the way 1.3.2 or older
  15119. // did it), otherwise encode params recursively.
  15120. for ( prefix in a ) {
  15121. buildParams( prefix, a[ prefix ], traditional, add );
  15122. }
  15123. }
  15124. // Return the resulting serialization
  15125. return s.join( "&" );
  15126. };
  15127. jQuery.fn.extend( {
  15128. serialize: function() {
  15129. return jQuery.param( this.serializeArray() );
  15130. },
  15131. serializeArray: function() {
  15132. return this.map( function() {
  15133. // Can add propHook for "elements" to filter or add form elements
  15134. var elements = jQuery.prop( this, "elements" );
  15135. return elements ? jQuery.makeArray( elements ) : this;
  15136. } )
  15137. .filter( function() {
  15138. var type = this.type;
  15139. // Use .is( ":disabled" ) so that fieldset[disabled] works
  15140. return this.name && !jQuery( this ).is( ":disabled" ) &&
  15141. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  15142. ( this.checked || !rcheckableType.test( type ) );
  15143. } )
  15144. .map( function( i, elem ) {
  15145. var val = jQuery( this ).val();
  15146. if ( val == null ) {
  15147. return null;
  15148. }
  15149. if ( Array.isArray( val ) ) {
  15150. return jQuery.map( val, function( val ) {
  15151. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  15152. } );
  15153. }
  15154. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  15155. } ).get();
  15156. }
  15157. } );
  15158. var
  15159. r20 = /%20/g,
  15160. rhash = /#.*$/,
  15161. rantiCache = /([?&])_=[^&]*/,
  15162. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  15163. // #7653, #8125, #8152: local protocol detection
  15164. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  15165. rnoContent = /^(?:GET|HEAD)$/,
  15166. rprotocol = /^\/\//,
  15167. /* Prefilters
  15168. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  15169. * 2) These are called:
  15170. * - BEFORE asking for a transport
  15171. * - AFTER param serialization (s.data is a string if s.processData is true)
  15172. * 3) key is the dataType
  15173. * 4) the catchall symbol "*" can be used
  15174. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  15175. */
  15176. prefilters = {},
  15177. /* Transports bindings
  15178. * 1) key is the dataType
  15179. * 2) the catchall symbol "*" can be used
  15180. * 3) selection will start with transport dataType and THEN go to "*" if needed
  15181. */
  15182. transports = {},
  15183. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  15184. allTypes = "*/".concat( "*" ),
  15185. // Anchor tag for parsing the document origin
  15186. originAnchor = document.createElement( "a" );
  15187. originAnchor.href = location.href;
  15188. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  15189. function addToPrefiltersOrTransports( structure ) {
  15190. // dataTypeExpression is optional and defaults to "*"
  15191. return function( dataTypeExpression, func ) {
  15192. if ( typeof dataTypeExpression !== "string" ) {
  15193. func = dataTypeExpression;
  15194. dataTypeExpression = "*";
  15195. }
  15196. var dataType,
  15197. i = 0,
  15198. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  15199. if ( isFunction( func ) ) {
  15200. // For each dataType in the dataTypeExpression
  15201. while ( ( dataType = dataTypes[ i++ ] ) ) {
  15202. // Prepend if requested
  15203. if ( dataType[ 0 ] === "+" ) {
  15204. dataType = dataType.slice( 1 ) || "*";
  15205. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  15206. // Otherwise append
  15207. } else {
  15208. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  15209. }
  15210. }
  15211. }
  15212. };
  15213. }
  15214. // Base inspection function for prefilters and transports
  15215. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  15216. var inspected = {},
  15217. seekingTransport = ( structure === transports );
  15218. function inspect( dataType ) {
  15219. var selected;
  15220. inspected[ dataType ] = true;
  15221. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  15222. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  15223. if ( typeof dataTypeOrTransport === "string" &&
  15224. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  15225. options.dataTypes.unshift( dataTypeOrTransport );
  15226. inspect( dataTypeOrTransport );
  15227. return false;
  15228. } else if ( seekingTransport ) {
  15229. return !( selected = dataTypeOrTransport );
  15230. }
  15231. } );
  15232. return selected;
  15233. }
  15234. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  15235. }
  15236. // A special extend for ajax options
  15237. // that takes "flat" options (not to be deep extended)
  15238. // Fixes #9887
  15239. function ajaxExtend( target, src ) {
  15240. var key, deep,
  15241. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  15242. for ( key in src ) {
  15243. if ( src[ key ] !== undefined ) {
  15244. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  15245. }
  15246. }
  15247. if ( deep ) {
  15248. jQuery.extend( true, target, deep );
  15249. }
  15250. return target;
  15251. }
  15252. /* Handles responses to an ajax request:
  15253. * - finds the right dataType (mediates between content-type and expected dataType)
  15254. * - returns the corresponding response
  15255. */
  15256. function ajaxHandleResponses( s, jqXHR, responses ) {
  15257. var ct, type, finalDataType, firstDataType,
  15258. contents = s.contents,
  15259. dataTypes = s.dataTypes;
  15260. // Remove auto dataType and get content-type in the process
  15261. while ( dataTypes[ 0 ] === "*" ) {
  15262. dataTypes.shift();
  15263. if ( ct === undefined ) {
  15264. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  15265. }
  15266. }
  15267. // Check if we're dealing with a known content-type
  15268. if ( ct ) {
  15269. for ( type in contents ) {
  15270. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  15271. dataTypes.unshift( type );
  15272. break;
  15273. }
  15274. }
  15275. }
  15276. // Check to see if we have a response for the expected dataType
  15277. if ( dataTypes[ 0 ] in responses ) {
  15278. finalDataType = dataTypes[ 0 ];
  15279. } else {
  15280. // Try convertible dataTypes
  15281. for ( type in responses ) {
  15282. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  15283. finalDataType = type;
  15284. break;
  15285. }
  15286. if ( !firstDataType ) {
  15287. firstDataType = type;
  15288. }
  15289. }
  15290. // Or just use first one
  15291. finalDataType = finalDataType || firstDataType;
  15292. }
  15293. // If we found a dataType
  15294. // We add the dataType to the list if needed
  15295. // and return the corresponding response
  15296. if ( finalDataType ) {
  15297. if ( finalDataType !== dataTypes[ 0 ] ) {
  15298. dataTypes.unshift( finalDataType );
  15299. }
  15300. return responses[ finalDataType ];
  15301. }
  15302. }
  15303. /* Chain conversions given the request and the original response
  15304. * Also sets the responseXXX fields on the jqXHR instance
  15305. */
  15306. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  15307. var conv2, current, conv, tmp, prev,
  15308. converters = {},
  15309. // Work with a copy of dataTypes in case we need to modify it for conversion
  15310. dataTypes = s.dataTypes.slice();
  15311. // Create converters map with lowercased keys
  15312. if ( dataTypes[ 1 ] ) {
  15313. for ( conv in s.converters ) {
  15314. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  15315. }
  15316. }
  15317. current = dataTypes.shift();
  15318. // Convert to each sequential dataType
  15319. while ( current ) {
  15320. if ( s.responseFields[ current ] ) {
  15321. jqXHR[ s.responseFields[ current ] ] = response;
  15322. }
  15323. // Apply the dataFilter if provided
  15324. if ( !prev && isSuccess && s.dataFilter ) {
  15325. response = s.dataFilter( response, s.dataType );
  15326. }
  15327. prev = current;
  15328. current = dataTypes.shift();
  15329. if ( current ) {
  15330. // There's only work to do if current dataType is non-auto
  15331. if ( current === "*" ) {
  15332. current = prev;
  15333. // Convert response if prev dataType is non-auto and differs from current
  15334. } else if ( prev !== "*" && prev !== current ) {
  15335. // Seek a direct converter
  15336. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  15337. // If none found, seek a pair
  15338. if ( !conv ) {
  15339. for ( conv2 in converters ) {
  15340. // If conv2 outputs current
  15341. tmp = conv2.split( " " );
  15342. if ( tmp[ 1 ] === current ) {
  15343. // If prev can be converted to accepted input
  15344. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  15345. converters[ "* " + tmp[ 0 ] ];
  15346. if ( conv ) {
  15347. // Condense equivalence converters
  15348. if ( conv === true ) {
  15349. conv = converters[ conv2 ];
  15350. // Otherwise, insert the intermediate dataType
  15351. } else if ( converters[ conv2 ] !== true ) {
  15352. current = tmp[ 0 ];
  15353. dataTypes.unshift( tmp[ 1 ] );
  15354. }
  15355. break;
  15356. }
  15357. }
  15358. }
  15359. }
  15360. // Apply converter (if not an equivalence)
  15361. if ( conv !== true ) {
  15362. // Unless errors are allowed to bubble, catch and return them
  15363. if ( conv && s.throws ) {
  15364. response = conv( response );
  15365. } else {
  15366. try {
  15367. response = conv( response );
  15368. } catch ( e ) {
  15369. return {
  15370. state: "parsererror",
  15371. error: conv ? e : "No conversion from " + prev + " to " + current
  15372. };
  15373. }
  15374. }
  15375. }
  15376. }
  15377. }
  15378. }
  15379. return { state: "success", data: response };
  15380. }
  15381. jQuery.extend( {
  15382. // Counter for holding the number of active queries
  15383. active: 0,
  15384. // Last-Modified header cache for next request
  15385. lastModified: {},
  15386. etag: {},
  15387. ajaxSettings: {
  15388. url: location.href,
  15389. type: "GET",
  15390. isLocal: rlocalProtocol.test( location.protocol ),
  15391. global: true,
  15392. processData: true,
  15393. async: true,
  15394. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  15395. /*
  15396. timeout: 0,
  15397. data: null,
  15398. dataType: null,
  15399. username: null,
  15400. password: null,
  15401. cache: null,
  15402. throws: false,
  15403. traditional: false,
  15404. headers: {},
  15405. */
  15406. accepts: {
  15407. "*": allTypes,
  15408. text: "text/plain",
  15409. html: "text/html",
  15410. xml: "application/xml, text/xml",
  15411. json: "application/json, text/javascript"
  15412. },
  15413. contents: {
  15414. xml: /\bxml\b/,
  15415. html: /\bhtml/,
  15416. json: /\bjson\b/
  15417. },
  15418. responseFields: {
  15419. xml: "responseXML",
  15420. text: "responseText",
  15421. json: "responseJSON"
  15422. },
  15423. // Data converters
  15424. // Keys separate source (or catchall "*") and destination types with a single space
  15425. converters: {
  15426. // Convert anything to text
  15427. "* text": String,
  15428. // Text to html (true = no transformation)
  15429. "text html": true,
  15430. // Evaluate text as a json expression
  15431. "text json": JSON.parse,
  15432. // Parse text as xml
  15433. "text xml": jQuery.parseXML
  15434. },
  15435. // For options that shouldn't be deep extended:
  15436. // you can add your own custom options here if
  15437. // and when you create one that shouldn't be
  15438. // deep extended (see ajaxExtend)
  15439. flatOptions: {
  15440. url: true,
  15441. context: true
  15442. }
  15443. },
  15444. // Creates a full fledged settings object into target
  15445. // with both ajaxSettings and settings fields.
  15446. // If target is omitted, writes into ajaxSettings.
  15447. ajaxSetup: function( target, settings ) {
  15448. return settings ?
  15449. // Building a settings object
  15450. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  15451. // Extending ajaxSettings
  15452. ajaxExtend( jQuery.ajaxSettings, target );
  15453. },
  15454. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  15455. ajaxTransport: addToPrefiltersOrTransports( transports ),
  15456. // Main method
  15457. ajax: function( url, options ) {
  15458. // If url is an object, simulate pre-1.5 signature
  15459. if ( typeof url === "object" ) {
  15460. options = url;
  15461. url = undefined;
  15462. }
  15463. // Force options to be an object
  15464. options = options || {};
  15465. var transport,
  15466. // URL without anti-cache param
  15467. cacheURL,
  15468. // Response headers
  15469. responseHeadersString,
  15470. responseHeaders,
  15471. // timeout handle
  15472. timeoutTimer,
  15473. // Url cleanup var
  15474. urlAnchor,
  15475. // Request state (becomes false upon send and true upon completion)
  15476. completed,
  15477. // To know if global events are to be dispatched
  15478. fireGlobals,
  15479. // Loop variable
  15480. i,
  15481. // uncached part of the url
  15482. uncached,
  15483. // Create the final options object
  15484. s = jQuery.ajaxSetup( {}, options ),
  15485. // Callbacks context
  15486. callbackContext = s.context || s,
  15487. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  15488. globalEventContext = s.context &&
  15489. ( callbackContext.nodeType || callbackContext.jquery ) ?
  15490. jQuery( callbackContext ) :
  15491. jQuery.event,
  15492. // Deferreds
  15493. deferred = jQuery.Deferred(),
  15494. completeDeferred = jQuery.Callbacks( "once memory" ),
  15495. // Status-dependent callbacks
  15496. statusCode = s.statusCode || {},
  15497. // Headers (they are sent all at once)
  15498. requestHeaders = {},
  15499. requestHeadersNames = {},
  15500. // Default abort message
  15501. strAbort = "canceled",
  15502. // Fake xhr
  15503. jqXHR = {
  15504. readyState: 0,
  15505. // Builds headers hashtable if needed
  15506. getResponseHeader: function( key ) {
  15507. var match;
  15508. if ( completed ) {
  15509. if ( !responseHeaders ) {
  15510. responseHeaders = {};
  15511. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  15512. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  15513. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  15514. .concat( match[ 2 ] );
  15515. }
  15516. }
  15517. match = responseHeaders[ key.toLowerCase() + " " ];
  15518. }
  15519. return match == null ? null : match.join( ", " );
  15520. },
  15521. // Raw string
  15522. getAllResponseHeaders: function() {
  15523. return completed ? responseHeadersString : null;
  15524. },
  15525. // Caches the header
  15526. setRequestHeader: function( name, value ) {
  15527. if ( completed == null ) {
  15528. name = requestHeadersNames[ name.toLowerCase() ] =
  15529. requestHeadersNames[ name.toLowerCase() ] || name;
  15530. requestHeaders[ name ] = value;
  15531. }
  15532. return this;
  15533. },
  15534. // Overrides response content-type header
  15535. overrideMimeType: function( type ) {
  15536. if ( completed == null ) {
  15537. s.mimeType = type;
  15538. }
  15539. return this;
  15540. },
  15541. // Status-dependent callbacks
  15542. statusCode: function( map ) {
  15543. var code;
  15544. if ( map ) {
  15545. if ( completed ) {
  15546. // Execute the appropriate callbacks
  15547. jqXHR.always( map[ jqXHR.status ] );
  15548. } else {
  15549. // Lazy-add the new callbacks in a way that preserves old ones
  15550. for ( code in map ) {
  15551. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  15552. }
  15553. }
  15554. }
  15555. return this;
  15556. },
  15557. // Cancel the request
  15558. abort: function( statusText ) {
  15559. var finalText = statusText || strAbort;
  15560. if ( transport ) {
  15561. transport.abort( finalText );
  15562. }
  15563. done( 0, finalText );
  15564. return this;
  15565. }
  15566. };
  15567. // Attach deferreds
  15568. deferred.promise( jqXHR );
  15569. // Add protocol if not provided (prefilters might expect it)
  15570. // Handle falsy url in the settings object (#10093: consistency with old signature)
  15571. // We also use the url parameter if available
  15572. s.url = ( ( url || s.url || location.href ) + "" )
  15573. .replace( rprotocol, location.protocol + "//" );
  15574. // Alias method option to type as per ticket #12004
  15575. s.type = options.method || options.type || s.method || s.type;
  15576. // Extract dataTypes list
  15577. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  15578. // A cross-domain request is in order when the origin doesn't match the current origin.
  15579. if ( s.crossDomain == null ) {
  15580. urlAnchor = document.createElement( "a" );
  15581. // Support: IE <=8 - 11, Edge 12 - 15
  15582. // IE throws exception on accessing the href property if url is malformed,
  15583. // e.g. http://example.com:80x/
  15584. try {
  15585. urlAnchor.href = s.url;
  15586. // Support: IE <=8 - 11 only
  15587. // Anchor's host property isn't correctly set when s.url is relative
  15588. urlAnchor.href = urlAnchor.href;
  15589. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  15590. urlAnchor.protocol + "//" + urlAnchor.host;
  15591. } catch ( e ) {
  15592. // If there is an error parsing the URL, assume it is crossDomain,
  15593. // it can be rejected by the transport if it is invalid
  15594. s.crossDomain = true;
  15595. }
  15596. }
  15597. // Convert data if not already a string
  15598. if ( s.data && s.processData && typeof s.data !== "string" ) {
  15599. s.data = jQuery.param( s.data, s.traditional );
  15600. }
  15601. // Apply prefilters
  15602. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  15603. // If request was aborted inside a prefilter, stop there
  15604. if ( completed ) {
  15605. return jqXHR;
  15606. }
  15607. // We can fire global events as of now if asked to
  15608. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  15609. fireGlobals = jQuery.event && s.global;
  15610. // Watch for a new set of requests
  15611. if ( fireGlobals && jQuery.active++ === 0 ) {
  15612. jQuery.event.trigger( "ajaxStart" );
  15613. }
  15614. // Uppercase the type
  15615. s.type = s.type.toUpperCase();
  15616. // Determine if request has content
  15617. s.hasContent = !rnoContent.test( s.type );
  15618. // Save the URL in case we're toying with the If-Modified-Since
  15619. // and/or If-None-Match header later on
  15620. // Remove hash to simplify url manipulation
  15621. cacheURL = s.url.replace( rhash, "" );
  15622. // More options handling for requests with no content
  15623. if ( !s.hasContent ) {
  15624. // Remember the hash so we can put it back
  15625. uncached = s.url.slice( cacheURL.length );
  15626. // If data is available and should be processed, append data to url
  15627. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  15628. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  15629. // #9682: remove data so that it's not used in an eventual retry
  15630. delete s.data;
  15631. }
  15632. // Add or update anti-cache param if needed
  15633. if ( s.cache === false ) {
  15634. cacheURL = cacheURL.replace( rantiCache, "$1" );
  15635. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  15636. }
  15637. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  15638. s.url = cacheURL + uncached;
  15639. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  15640. } else if ( s.data && s.processData &&
  15641. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  15642. s.data = s.data.replace( r20, "+" );
  15643. }
  15644. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  15645. if ( s.ifModified ) {
  15646. if ( jQuery.lastModified[ cacheURL ] ) {
  15647. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  15648. }
  15649. if ( jQuery.etag[ cacheURL ] ) {
  15650. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  15651. }
  15652. }
  15653. // Set the correct header, if data is being sent
  15654. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  15655. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  15656. }
  15657. // Set the Accepts header for the server, depending on the dataType
  15658. jqXHR.setRequestHeader(
  15659. "Accept",
  15660. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  15661. s.accepts[ s.dataTypes[ 0 ] ] +
  15662. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  15663. s.accepts[ "*" ]
  15664. );
  15665. // Check for headers option
  15666. for ( i in s.headers ) {
  15667. jqXHR.setRequestHeader( i, s.headers[ i ] );
  15668. }
  15669. // Allow custom headers/mimetypes and early abort
  15670. if ( s.beforeSend &&
  15671. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  15672. // Abort if not done already and return
  15673. return jqXHR.abort();
  15674. }
  15675. // Aborting is no longer a cancellation
  15676. strAbort = "abort";
  15677. // Install callbacks on deferreds
  15678. completeDeferred.add( s.complete );
  15679. jqXHR.done( s.success );
  15680. jqXHR.fail( s.error );
  15681. // Get transport
  15682. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  15683. // If no transport, we auto-abort
  15684. if ( !transport ) {
  15685. done( -1, "No Transport" );
  15686. } else {
  15687. jqXHR.readyState = 1;
  15688. // Send global event
  15689. if ( fireGlobals ) {
  15690. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  15691. }
  15692. // If request was aborted inside ajaxSend, stop there
  15693. if ( completed ) {
  15694. return jqXHR;
  15695. }
  15696. // Timeout
  15697. if ( s.async && s.timeout > 0 ) {
  15698. timeoutTimer = window.setTimeout( function() {
  15699. jqXHR.abort( "timeout" );
  15700. }, s.timeout );
  15701. }
  15702. try {
  15703. completed = false;
  15704. transport.send( requestHeaders, done );
  15705. } catch ( e ) {
  15706. // Rethrow post-completion exceptions
  15707. if ( completed ) {
  15708. throw e;
  15709. }
  15710. // Propagate others as results
  15711. done( -1, e );
  15712. }
  15713. }
  15714. // Callback for when everything is done
  15715. function done( status, nativeStatusText, responses, headers ) {
  15716. var isSuccess, success, error, response, modified,
  15717. statusText = nativeStatusText;
  15718. // Ignore repeat invocations
  15719. if ( completed ) {
  15720. return;
  15721. }
  15722. completed = true;
  15723. // Clear timeout if it exists
  15724. if ( timeoutTimer ) {
  15725. window.clearTimeout( timeoutTimer );
  15726. }
  15727. // Dereference transport for early garbage collection
  15728. // (no matter how long the jqXHR object will be used)
  15729. transport = undefined;
  15730. // Cache response headers
  15731. responseHeadersString = headers || "";
  15732. // Set readyState
  15733. jqXHR.readyState = status > 0 ? 4 : 0;
  15734. // Determine if successful
  15735. isSuccess = status >= 200 && status < 300 || status === 304;
  15736. // Get response data
  15737. if ( responses ) {
  15738. response = ajaxHandleResponses( s, jqXHR, responses );
  15739. }
  15740. // Convert no matter what (that way responseXXX fields are always set)
  15741. response = ajaxConvert( s, response, jqXHR, isSuccess );
  15742. // If successful, handle type chaining
  15743. if ( isSuccess ) {
  15744. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  15745. if ( s.ifModified ) {
  15746. modified = jqXHR.getResponseHeader( "Last-Modified" );
  15747. if ( modified ) {
  15748. jQuery.lastModified[ cacheURL ] = modified;
  15749. }
  15750. modified = jqXHR.getResponseHeader( "etag" );
  15751. if ( modified ) {
  15752. jQuery.etag[ cacheURL ] = modified;
  15753. }
  15754. }
  15755. // if no content
  15756. if ( status === 204 || s.type === "HEAD" ) {
  15757. statusText = "nocontent";
  15758. // if not modified
  15759. } else if ( status === 304 ) {
  15760. statusText = "notmodified";
  15761. // If we have data, let's convert it
  15762. } else {
  15763. statusText = response.state;
  15764. success = response.data;
  15765. error = response.error;
  15766. isSuccess = !error;
  15767. }
  15768. } else {
  15769. // Extract error from statusText and normalize for non-aborts
  15770. error = statusText;
  15771. if ( status || !statusText ) {
  15772. statusText = "error";
  15773. if ( status < 0 ) {
  15774. status = 0;
  15775. }
  15776. }
  15777. }
  15778. // Set data for the fake xhr object
  15779. jqXHR.status = status;
  15780. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  15781. // Success/Error
  15782. if ( isSuccess ) {
  15783. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  15784. } else {
  15785. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  15786. }
  15787. // Status-dependent callbacks
  15788. jqXHR.statusCode( statusCode );
  15789. statusCode = undefined;
  15790. if ( fireGlobals ) {
  15791. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  15792. [ jqXHR, s, isSuccess ? success : error ] );
  15793. }
  15794. // Complete
  15795. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  15796. if ( fireGlobals ) {
  15797. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  15798. // Handle the global AJAX counter
  15799. if ( !( --jQuery.active ) ) {
  15800. jQuery.event.trigger( "ajaxStop" );
  15801. }
  15802. }
  15803. }
  15804. return jqXHR;
  15805. },
  15806. getJSON: function( url, data, callback ) {
  15807. return jQuery.get( url, data, callback, "json" );
  15808. },
  15809. getScript: function( url, callback ) {
  15810. return jQuery.get( url, undefined, callback, "script" );
  15811. }
  15812. } );
  15813. jQuery.each( [ "get", "post" ], function( i, method ) {
  15814. jQuery[ method ] = function( url, data, callback, type ) {
  15815. // Shift arguments if data argument was omitted
  15816. if ( isFunction( data ) ) {
  15817. type = type || callback;
  15818. callback = data;
  15819. data = undefined;
  15820. }
  15821. // The url can be an options object (which then must have .url)
  15822. return jQuery.ajax( jQuery.extend( {
  15823. url: url,
  15824. type: method,
  15825. dataType: type,
  15826. data: data,
  15827. success: callback
  15828. }, jQuery.isPlainObject( url ) && url ) );
  15829. };
  15830. } );
  15831. jQuery._evalUrl = function( url, options ) {
  15832. return jQuery.ajax( {
  15833. url: url,
  15834. // Make this explicit, since user can override this through ajaxSetup (#11264)
  15835. type: "GET",
  15836. dataType: "script",
  15837. cache: true,
  15838. async: false,
  15839. global: false,
  15840. // Only evaluate the response if it is successful (gh-4126)
  15841. // dataFilter is not invoked for failure responses, so using it instead
  15842. // of the default converter is kludgy but it works.
  15843. converters: {
  15844. "text script": function() {}
  15845. },
  15846. dataFilter: function( response ) {
  15847. jQuery.globalEval( response, options );
  15848. }
  15849. } );
  15850. };
  15851. jQuery.fn.extend( {
  15852. wrapAll: function( html ) {
  15853. var wrap;
  15854. if ( this[ 0 ] ) {
  15855. if ( isFunction( html ) ) {
  15856. html = html.call( this[ 0 ] );
  15857. }
  15858. // The elements to wrap the target around
  15859. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  15860. if ( this[ 0 ].parentNode ) {
  15861. wrap.insertBefore( this[ 0 ] );
  15862. }
  15863. wrap.map( function() {
  15864. var elem = this;
  15865. while ( elem.firstElementChild ) {
  15866. elem = elem.firstElementChild;
  15867. }
  15868. return elem;
  15869. } ).append( this );
  15870. }
  15871. return this;
  15872. },
  15873. wrapInner: function( html ) {
  15874. if ( isFunction( html ) ) {
  15875. return this.each( function( i ) {
  15876. jQuery( this ).wrapInner( html.call( this, i ) );
  15877. } );
  15878. }
  15879. return this.each( function() {
  15880. var self = jQuery( this ),
  15881. contents = self.contents();
  15882. if ( contents.length ) {
  15883. contents.wrapAll( html );
  15884. } else {
  15885. self.append( html );
  15886. }
  15887. } );
  15888. },
  15889. wrap: function( html ) {
  15890. var htmlIsFunction = isFunction( html );
  15891. return this.each( function( i ) {
  15892. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  15893. } );
  15894. },
  15895. unwrap: function( selector ) {
  15896. this.parent( selector ).not( "body" ).each( function() {
  15897. jQuery( this ).replaceWith( this.childNodes );
  15898. } );
  15899. return this;
  15900. }
  15901. } );
  15902. jQuery.expr.pseudos.hidden = function( elem ) {
  15903. return !jQuery.expr.pseudos.visible( elem );
  15904. };
  15905. jQuery.expr.pseudos.visible = function( elem ) {
  15906. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  15907. };
  15908. jQuery.ajaxSettings.xhr = function() {
  15909. try {
  15910. return new window.XMLHttpRequest();
  15911. } catch ( e ) {}
  15912. };
  15913. var xhrSuccessStatus = {
  15914. // File protocol always yields status code 0, assume 200
  15915. 0: 200,
  15916. // Support: IE <=9 only
  15917. // #1450: sometimes IE returns 1223 when it should be 204
  15918. 1223: 204
  15919. },
  15920. xhrSupported = jQuery.ajaxSettings.xhr();
  15921. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  15922. support.ajax = xhrSupported = !!xhrSupported;
  15923. jQuery.ajaxTransport( function( options ) {
  15924. var callback, errorCallback;
  15925. // Cross domain only allowed if supported through XMLHttpRequest
  15926. if ( support.cors || xhrSupported && !options.crossDomain ) {
  15927. return {
  15928. send: function( headers, complete ) {
  15929. var i,
  15930. xhr = options.xhr();
  15931. xhr.open(
  15932. options.type,
  15933. options.url,
  15934. options.async,
  15935. options.username,
  15936. options.password
  15937. );
  15938. // Apply custom fields if provided
  15939. if ( options.xhrFields ) {
  15940. for ( i in options.xhrFields ) {
  15941. xhr[ i ] = options.xhrFields[ i ];
  15942. }
  15943. }
  15944. // Override mime type if needed
  15945. if ( options.mimeType && xhr.overrideMimeType ) {
  15946. xhr.overrideMimeType( options.mimeType );
  15947. }
  15948. // X-Requested-With header
  15949. // For cross-domain requests, seeing as conditions for a preflight are
  15950. // akin to a jigsaw puzzle, we simply never set it to be sure.
  15951. // (it can always be set on a per-request basis or even using ajaxSetup)
  15952. // For same-domain requests, won't change header if already provided.
  15953. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  15954. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  15955. }
  15956. // Set headers
  15957. for ( i in headers ) {
  15958. xhr.setRequestHeader( i, headers[ i ] );
  15959. }
  15960. // Callback
  15961. callback = function( type ) {
  15962. return function() {
  15963. if ( callback ) {
  15964. callback = errorCallback = xhr.onload =
  15965. xhr.onerror = xhr.onabort = xhr.ontimeout =
  15966. xhr.onreadystatechange = null;
  15967. if ( type === "abort" ) {
  15968. xhr.abort();
  15969. } else if ( type === "error" ) {
  15970. // Support: IE <=9 only
  15971. // On a manual native abort, IE9 throws
  15972. // errors on any property access that is not readyState
  15973. if ( typeof xhr.status !== "number" ) {
  15974. complete( 0, "error" );
  15975. } else {
  15976. complete(
  15977. // File: protocol always yields status 0; see #8605, #14207
  15978. xhr.status,
  15979. xhr.statusText
  15980. );
  15981. }
  15982. } else {
  15983. complete(
  15984. xhrSuccessStatus[ xhr.status ] || xhr.status,
  15985. xhr.statusText,
  15986. // Support: IE <=9 only
  15987. // IE9 has no XHR2 but throws on binary (trac-11426)
  15988. // For XHR2 non-text, let the caller handle it (gh-2498)
  15989. ( xhr.responseType || "text" ) !== "text" ||
  15990. typeof xhr.responseText !== "string" ?
  15991. { binary: xhr.response } :
  15992. { text: xhr.responseText },
  15993. xhr.getAllResponseHeaders()
  15994. );
  15995. }
  15996. }
  15997. };
  15998. };
  15999. // Listen to events
  16000. xhr.onload = callback();
  16001. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  16002. // Support: IE 9 only
  16003. // Use onreadystatechange to replace onabort
  16004. // to handle uncaught aborts
  16005. if ( xhr.onabort !== undefined ) {
  16006. xhr.onabort = errorCallback;
  16007. } else {
  16008. xhr.onreadystatechange = function() {
  16009. // Check readyState before timeout as it changes
  16010. if ( xhr.readyState === 4 ) {
  16011. // Allow onerror to be called first,
  16012. // but that will not handle a native abort
  16013. // Also, save errorCallback to a variable
  16014. // as xhr.onerror cannot be accessed
  16015. window.setTimeout( function() {
  16016. if ( callback ) {
  16017. errorCallback();
  16018. }
  16019. } );
  16020. }
  16021. };
  16022. }
  16023. // Create the abort callback
  16024. callback = callback( "abort" );
  16025. try {
  16026. // Do send the request (this may raise an exception)
  16027. xhr.send( options.hasContent && options.data || null );
  16028. } catch ( e ) {
  16029. // #14683: Only rethrow if this hasn't been notified as an error yet
  16030. if ( callback ) {
  16031. throw e;
  16032. }
  16033. }
  16034. },
  16035. abort: function() {
  16036. if ( callback ) {
  16037. callback();
  16038. }
  16039. }
  16040. };
  16041. }
  16042. } );
  16043. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  16044. jQuery.ajaxPrefilter( function( s ) {
  16045. if ( s.crossDomain ) {
  16046. s.contents.script = false;
  16047. }
  16048. } );
  16049. // Install script dataType
  16050. jQuery.ajaxSetup( {
  16051. accepts: {
  16052. script: "text/javascript, application/javascript, " +
  16053. "application/ecmascript, application/x-ecmascript"
  16054. },
  16055. contents: {
  16056. script: /\b(?:java|ecma)script\b/
  16057. },
  16058. converters: {
  16059. "text script": function( text ) {
  16060. jQuery.globalEval( text );
  16061. return text;
  16062. }
  16063. }
  16064. } );
  16065. // Handle cache's special case and crossDomain
  16066. jQuery.ajaxPrefilter( "script", function( s ) {
  16067. if ( s.cache === undefined ) {
  16068. s.cache = false;
  16069. }
  16070. if ( s.crossDomain ) {
  16071. s.type = "GET";
  16072. }
  16073. } );
  16074. // Bind script tag hack transport
  16075. jQuery.ajaxTransport( "script", function( s ) {
  16076. // This transport only deals with cross domain or forced-by-attrs requests
  16077. if ( s.crossDomain || s.scriptAttrs ) {
  16078. var script, callback;
  16079. return {
  16080. send: function( _, complete ) {
  16081. script = jQuery( "<script>" )
  16082. .attr( s.scriptAttrs || {} )
  16083. .prop( { charset: s.scriptCharset, src: s.url } )
  16084. .on( "load error", callback = function( evt ) {
  16085. script.remove();
  16086. callback = null;
  16087. if ( evt ) {
  16088. complete( evt.type === "error" ? 404 : 200, evt.type );
  16089. }
  16090. } );
  16091. // Use native DOM manipulation to avoid our domManip AJAX trickery
  16092. document.head.appendChild( script[ 0 ] );
  16093. },
  16094. abort: function() {
  16095. if ( callback ) {
  16096. callback();
  16097. }
  16098. }
  16099. };
  16100. }
  16101. } );
  16102. var oldCallbacks = [],
  16103. rjsonp = /(=)\?(?=&|$)|\?\?/;
  16104. // Default jsonp settings
  16105. jQuery.ajaxSetup( {
  16106. jsonp: "callback",
  16107. jsonpCallback: function() {
  16108. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  16109. this[ callback ] = true;
  16110. return callback;
  16111. }
  16112. } );
  16113. // Detect, normalize options and install callbacks for jsonp requests
  16114. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  16115. var callbackName, overwritten, responseContainer,
  16116. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  16117. "url" :
  16118. typeof s.data === "string" &&
  16119. ( s.contentType || "" )
  16120. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  16121. rjsonp.test( s.data ) && "data"
  16122. );
  16123. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  16124. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  16125. // Get callback name, remembering preexisting value associated with it
  16126. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  16127. s.jsonpCallback() :
  16128. s.jsonpCallback;
  16129. // Insert callback into url or form data
  16130. if ( jsonProp ) {
  16131. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  16132. } else if ( s.jsonp !== false ) {
  16133. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  16134. }
  16135. // Use data converter to retrieve json after script execution
  16136. s.converters[ "script json" ] = function() {
  16137. if ( !responseContainer ) {
  16138. jQuery.error( callbackName + " was not called" );
  16139. }
  16140. return responseContainer[ 0 ];
  16141. };
  16142. // Force json dataType
  16143. s.dataTypes[ 0 ] = "json";
  16144. // Install callback
  16145. overwritten = window[ callbackName ];
  16146. window[ callbackName ] = function() {
  16147. responseContainer = arguments;
  16148. };
  16149. // Clean-up function (fires after converters)
  16150. jqXHR.always( function() {
  16151. // If previous value didn't exist - remove it
  16152. if ( overwritten === undefined ) {
  16153. jQuery( window ).removeProp( callbackName );
  16154. // Otherwise restore preexisting value
  16155. } else {
  16156. window[ callbackName ] = overwritten;
  16157. }
  16158. // Save back as free
  16159. if ( s[ callbackName ] ) {
  16160. // Make sure that re-using the options doesn't screw things around
  16161. s.jsonpCallback = originalSettings.jsonpCallback;
  16162. // Save the callback name for future use
  16163. oldCallbacks.push( callbackName );
  16164. }
  16165. // Call if it was a function and we have a response
  16166. if ( responseContainer && isFunction( overwritten ) ) {
  16167. overwritten( responseContainer[ 0 ] );
  16168. }
  16169. responseContainer = overwritten = undefined;
  16170. } );
  16171. // Delegate to script
  16172. return "script";
  16173. }
  16174. } );
  16175. // Support: Safari 8 only
  16176. // In Safari 8 documents created via document.implementation.createHTMLDocument
  16177. // collapse sibling forms: the second one becomes a child of the first one.
  16178. // Because of that, this security measure has to be disabled in Safari 8.
  16179. // https://bugs.webkit.org/show_bug.cgi?id=137337
  16180. support.createHTMLDocument = ( function() {
  16181. var body = document.implementation.createHTMLDocument( "" ).body;
  16182. body.innerHTML = "<form></form><form></form>";
  16183. return body.childNodes.length === 2;
  16184. } )();
  16185. // Argument "data" should be string of html
  16186. // context (optional): If specified, the fragment will be created in this context,
  16187. // defaults to document
  16188. // keepScripts (optional): If true, will include scripts passed in the html string
  16189. jQuery.parseHTML = function( data, context, keepScripts ) {
  16190. if ( typeof data !== "string" ) {
  16191. return [];
  16192. }
  16193. if ( typeof context === "boolean" ) {
  16194. keepScripts = context;
  16195. context = false;
  16196. }
  16197. var base, parsed, scripts;
  16198. if ( !context ) {
  16199. // Stop scripts or inline event handlers from being executed immediately
  16200. // by using document.implementation
  16201. if ( support.createHTMLDocument ) {
  16202. context = document.implementation.createHTMLDocument( "" );
  16203. // Set the base href for the created document
  16204. // so any parsed elements with URLs
  16205. // are based on the document's URL (gh-2965)
  16206. base = context.createElement( "base" );
  16207. base.href = document.location.href;
  16208. context.head.appendChild( base );
  16209. } else {
  16210. context = document;
  16211. }
  16212. }
  16213. parsed = rsingleTag.exec( data );
  16214. scripts = !keepScripts && [];
  16215. // Single tag
  16216. if ( parsed ) {
  16217. return [ context.createElement( parsed[ 1 ] ) ];
  16218. }
  16219. parsed = buildFragment( [ data ], context, scripts );
  16220. if ( scripts && scripts.length ) {
  16221. jQuery( scripts ).remove();
  16222. }
  16223. return jQuery.merge( [], parsed.childNodes );
  16224. };
  16225. /**
  16226. * Load a url into a page
  16227. */
  16228. jQuery.fn.load = function( url, params, callback ) {
  16229. var selector, type, response,
  16230. self = this,
  16231. off = url.indexOf( " " );
  16232. if ( off > -1 ) {
  16233. selector = stripAndCollapse( url.slice( off ) );
  16234. url = url.slice( 0, off );
  16235. }
  16236. // If it's a function
  16237. if ( isFunction( params ) ) {
  16238. // We assume that it's the callback
  16239. callback = params;
  16240. params = undefined;
  16241. // Otherwise, build a param string
  16242. } else if ( params && typeof params === "object" ) {
  16243. type = "POST";
  16244. }
  16245. // If we have elements to modify, make the request
  16246. if ( self.length > 0 ) {
  16247. jQuery.ajax( {
  16248. url: url,
  16249. // If "type" variable is undefined, then "GET" method will be used.
  16250. // Make value of this field explicit since
  16251. // user can override it through ajaxSetup method
  16252. type: type || "GET",
  16253. dataType: "html",
  16254. data: params
  16255. } ).done( function( responseText ) {
  16256. // Save response for use in complete callback
  16257. response = arguments;
  16258. self.html( selector ?
  16259. // If a selector was specified, locate the right elements in a dummy div
  16260. // Exclude scripts to avoid IE 'Permission Denied' errors
  16261. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  16262. // Otherwise use the full result
  16263. responseText );
  16264. // If the request succeeds, this function gets "data", "status", "jqXHR"
  16265. // but they are ignored because response was set above.
  16266. // If it fails, this function gets "jqXHR", "status", "error"
  16267. } ).always( callback && function( jqXHR, status ) {
  16268. self.each( function() {
  16269. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  16270. } );
  16271. } );
  16272. }
  16273. return this;
  16274. };
  16275. // Attach a bunch of functions for handling common AJAX events
  16276. jQuery.each( [
  16277. "ajaxStart",
  16278. "ajaxStop",
  16279. "ajaxComplete",
  16280. "ajaxError",
  16281. "ajaxSuccess",
  16282. "ajaxSend"
  16283. ], function( i, type ) {
  16284. jQuery.fn[ type ] = function( fn ) {
  16285. return this.on( type, fn );
  16286. };
  16287. } );
  16288. jQuery.expr.pseudos.animated = function( elem ) {
  16289. return jQuery.grep( jQuery.timers, function( fn ) {
  16290. return elem === fn.elem;
  16291. } ).length;
  16292. };
  16293. jQuery.offset = {
  16294. setOffset: function( elem, options, i ) {
  16295. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  16296. position = jQuery.css( elem, "position" ),
  16297. curElem = jQuery( elem ),
  16298. props = {};
  16299. // Set position first, in-case top/left are set even on static elem
  16300. if ( position === "static" ) {
  16301. elem.style.position = "relative";
  16302. }
  16303. curOffset = curElem.offset();
  16304. curCSSTop = jQuery.css( elem, "top" );
  16305. curCSSLeft = jQuery.css( elem, "left" );
  16306. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  16307. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  16308. // Need to be able to calculate position if either
  16309. // top or left is auto and position is either absolute or fixed
  16310. if ( calculatePosition ) {
  16311. curPosition = curElem.position();
  16312. curTop = curPosition.top;
  16313. curLeft = curPosition.left;
  16314. } else {
  16315. curTop = parseFloat( curCSSTop ) || 0;
  16316. curLeft = parseFloat( curCSSLeft ) || 0;
  16317. }
  16318. if ( isFunction( options ) ) {
  16319. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  16320. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  16321. }
  16322. if ( options.top != null ) {
  16323. props.top = ( options.top - curOffset.top ) + curTop;
  16324. }
  16325. if ( options.left != null ) {
  16326. props.left = ( options.left - curOffset.left ) + curLeft;
  16327. }
  16328. if ( "using" in options ) {
  16329. options.using.call( elem, props );
  16330. } else {
  16331. curElem.css( props );
  16332. }
  16333. }
  16334. };
  16335. jQuery.fn.extend( {
  16336. // offset() relates an element's border box to the document origin
  16337. offset: function( options ) {
  16338. // Preserve chaining for setter
  16339. if ( arguments.length ) {
  16340. return options === undefined ?
  16341. this :
  16342. this.each( function( i ) {
  16343. jQuery.offset.setOffset( this, options, i );
  16344. } );
  16345. }
  16346. var rect, win,
  16347. elem = this[ 0 ];
  16348. if ( !elem ) {
  16349. return;
  16350. }
  16351. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  16352. // Support: IE <=11 only
  16353. // Running getBoundingClientRect on a
  16354. // disconnected node in IE throws an error
  16355. if ( !elem.getClientRects().length ) {
  16356. return { top: 0, left: 0 };
  16357. }
  16358. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  16359. rect = elem.getBoundingClientRect();
  16360. win = elem.ownerDocument.defaultView;
  16361. return {
  16362. top: rect.top + win.pageYOffset,
  16363. left: rect.left + win.pageXOffset
  16364. };
  16365. },
  16366. // position() relates an element's margin box to its offset parent's padding box
  16367. // This corresponds to the behavior of CSS absolute positioning
  16368. position: function() {
  16369. if ( !this[ 0 ] ) {
  16370. return;
  16371. }
  16372. var offsetParent, offset, doc,
  16373. elem = this[ 0 ],
  16374. parentOffset = { top: 0, left: 0 };
  16375. // position:fixed elements are offset from the viewport, which itself always has zero offset
  16376. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  16377. // Assume position:fixed implies availability of getBoundingClientRect
  16378. offset = elem.getBoundingClientRect();
  16379. } else {
  16380. offset = this.offset();
  16381. // Account for the *real* offset parent, which can be the document or its root element
  16382. // when a statically positioned element is identified
  16383. doc = elem.ownerDocument;
  16384. offsetParent = elem.offsetParent || doc.documentElement;
  16385. while ( offsetParent &&
  16386. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  16387. jQuery.css( offsetParent, "position" ) === "static" ) {
  16388. offsetParent = offsetParent.parentNode;
  16389. }
  16390. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  16391. // Incorporate borders into its offset, since they are outside its content origin
  16392. parentOffset = jQuery( offsetParent ).offset();
  16393. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  16394. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  16395. }
  16396. }
  16397. // Subtract parent offsets and element margins
  16398. return {
  16399. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  16400. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  16401. };
  16402. },
  16403. // This method will return documentElement in the following cases:
  16404. // 1) For the element inside the iframe without offsetParent, this method will return
  16405. // documentElement of the parent window
  16406. // 2) For the hidden or detached element
  16407. // 3) For body or html element, i.e. in case of the html node - it will return itself
  16408. //
  16409. // but those exceptions were never presented as a real life use-cases
  16410. // and might be considered as more preferable results.
  16411. //
  16412. // This logic, however, is not guaranteed and can change at any point in the future
  16413. offsetParent: function() {
  16414. return this.map( function() {
  16415. var offsetParent = this.offsetParent;
  16416. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  16417. offsetParent = offsetParent.offsetParent;
  16418. }
  16419. return offsetParent || documentElement;
  16420. } );
  16421. }
  16422. } );
  16423. // Create scrollLeft and scrollTop methods
  16424. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  16425. var top = "pageYOffset" === prop;
  16426. jQuery.fn[ method ] = function( val ) {
  16427. return access( this, function( elem, method, val ) {
  16428. // Coalesce documents and windows
  16429. var win;
  16430. if ( isWindow( elem ) ) {
  16431. win = elem;
  16432. } else if ( elem.nodeType === 9 ) {
  16433. win = elem.defaultView;
  16434. }
  16435. if ( val === undefined ) {
  16436. return win ? win[ prop ] : elem[ method ];
  16437. }
  16438. if ( win ) {
  16439. win.scrollTo(
  16440. !top ? val : win.pageXOffset,
  16441. top ? val : win.pageYOffset
  16442. );
  16443. } else {
  16444. elem[ method ] = val;
  16445. }
  16446. }, method, val, arguments.length );
  16447. };
  16448. } );
  16449. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  16450. // Add the top/left cssHooks using jQuery.fn.position
  16451. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  16452. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  16453. // getComputedStyle returns percent when specified for top/left/bottom/right;
  16454. // rather than make the css module depend on the offset module, just check for it here
  16455. jQuery.each( [ "top", "left" ], function( i, prop ) {
  16456. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  16457. function( elem, computed ) {
  16458. if ( computed ) {
  16459. computed = curCSS( elem, prop );
  16460. // If curCSS returns percentage, fallback to offset
  16461. return rnumnonpx.test( computed ) ?
  16462. jQuery( elem ).position()[ prop ] + "px" :
  16463. computed;
  16464. }
  16465. }
  16466. );
  16467. } );
  16468. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  16469. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  16470. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  16471. function( defaultExtra, funcName ) {
  16472. // Margin is only for outerHeight, outerWidth
  16473. jQuery.fn[ funcName ] = function( margin, value ) {
  16474. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  16475. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  16476. return access( this, function( elem, type, value ) {
  16477. var doc;
  16478. if ( isWindow( elem ) ) {
  16479. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  16480. return funcName.indexOf( "outer" ) === 0 ?
  16481. elem[ "inner" + name ] :
  16482. elem.document.documentElement[ "client" + name ];
  16483. }
  16484. // Get document width or height
  16485. if ( elem.nodeType === 9 ) {
  16486. doc = elem.documentElement;
  16487. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  16488. // whichever is greatest
  16489. return Math.max(
  16490. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  16491. elem.body[ "offset" + name ], doc[ "offset" + name ],
  16492. doc[ "client" + name ]
  16493. );
  16494. }
  16495. return value === undefined ?
  16496. // Get width or height on the element, requesting but not forcing parseFloat
  16497. jQuery.css( elem, type, extra ) :
  16498. // Set width or height on the element
  16499. jQuery.style( elem, type, value, extra );
  16500. }, type, chainable ? margin : undefined, chainable );
  16501. };
  16502. } );
  16503. } );
  16504. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  16505. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  16506. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  16507. function( i, name ) {
  16508. // Handle event binding
  16509. jQuery.fn[ name ] = function( data, fn ) {
  16510. return arguments.length > 0 ?
  16511. this.on( name, null, data, fn ) :
  16512. this.trigger( name );
  16513. };
  16514. } );
  16515. jQuery.fn.extend( {
  16516. hover: function( fnOver, fnOut ) {
  16517. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  16518. }
  16519. } );
  16520. jQuery.fn.extend( {
  16521. bind: function( types, data, fn ) {
  16522. return this.on( types, null, data, fn );
  16523. },
  16524. unbind: function( types, fn ) {
  16525. return this.off( types, null, fn );
  16526. },
  16527. delegate: function( selector, types, data, fn ) {
  16528. return this.on( types, selector, data, fn );
  16529. },
  16530. undelegate: function( selector, types, fn ) {
  16531. // ( namespace ) or ( selector, types [, fn] )
  16532. return arguments.length === 1 ?
  16533. this.off( selector, "**" ) :
  16534. this.off( types, selector || "**", fn );
  16535. }
  16536. } );
  16537. // Bind a function to a context, optionally partially applying any
  16538. // arguments.
  16539. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  16540. // However, it is not slated for removal any time soon
  16541. jQuery.proxy = function( fn, context ) {
  16542. var tmp, args, proxy;
  16543. if ( typeof context === "string" ) {
  16544. tmp = fn[ context ];
  16545. context = fn;
  16546. fn = tmp;
  16547. }
  16548. // Quick check to determine if target is callable, in the spec
  16549. // this throws a TypeError, but we will just return undefined.
  16550. if ( !isFunction( fn ) ) {
  16551. return undefined;
  16552. }
  16553. // Simulated bind
  16554. args = slice.call( arguments, 2 );
  16555. proxy = function() {
  16556. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  16557. };
  16558. // Set the guid of unique handler to the same of original handler, so it can be removed
  16559. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  16560. return proxy;
  16561. };
  16562. jQuery.holdReady = function( hold ) {
  16563. if ( hold ) {
  16564. jQuery.readyWait++;
  16565. } else {
  16566. jQuery.ready( true );
  16567. }
  16568. };
  16569. jQuery.isArray = Array.isArray;
  16570. jQuery.parseJSON = JSON.parse;
  16571. jQuery.nodeName = nodeName;
  16572. jQuery.isFunction = isFunction;
  16573. jQuery.isWindow = isWindow;
  16574. jQuery.camelCase = camelCase;
  16575. jQuery.type = toType;
  16576. jQuery.now = Date.now;
  16577. jQuery.isNumeric = function( obj ) {
  16578. // As of jQuery 3.0, isNumeric is limited to
  16579. // strings and numbers (primitives or objects)
  16580. // that can be coerced to finite numbers (gh-2662)
  16581. var type = jQuery.type( obj );
  16582. return ( type === "number" || type === "string" ) &&
  16583. // parseFloat NaNs numeric-cast false positives ("")
  16584. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  16585. // subtraction forces infinities to NaN
  16586. !isNaN( obj - parseFloat( obj ) );
  16587. };
  16588. // Register as a named AMD module, since jQuery can be concatenated with other
  16589. // files that may use define, but not via a proper concatenation script that
  16590. // understands anonymous AMD modules. A named AMD is safest and most robust
  16591. // way to register. Lowercase jquery is used because AMD module names are
  16592. // derived from file names, and jQuery is normally delivered in a lowercase
  16593. // file name. Do this after creating the global so that if an AMD module wants
  16594. // to call noConflict to hide this version of jQuery, it will work.
  16595. // Note that for maximum portability, libraries that are not jQuery should
  16596. // declare themselves as anonymous modules, and avoid setting a global if an
  16597. // AMD loader is present. jQuery is a special case. For more information, see
  16598. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  16599. if ( true ) {
  16600. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  16601. return jQuery;
  16602. }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  16603. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  16604. }
  16605. var
  16606. // Map over jQuery in case of overwrite
  16607. _jQuery = window.jQuery,
  16608. // Map over the $ in case of overwrite
  16609. _$ = window.$;
  16610. jQuery.noConflict = function( deep ) {
  16611. if ( window.$ === jQuery ) {
  16612. window.$ = _$;
  16613. }
  16614. if ( deep && window.jQuery === jQuery ) {
  16615. window.jQuery = _jQuery;
  16616. }
  16617. return jQuery;
  16618. };
  16619. // Expose jQuery and $ identifiers, even in AMD
  16620. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  16621. // and CommonJS for browser emulators (#13566)
  16622. if ( !noGlobal ) {
  16623. window.jQuery = window.$ = jQuery;
  16624. }
  16625. return jQuery;
  16626. } );
  16627. /***/ }),
  16628. /***/ "./node_modules/laravel-echo/dist/echo.js":
  16629. /*!************************************************!*\
  16630. !*** ./node_modules/laravel-echo/dist/echo.js ***!
  16631. \************************************************/
  16632. /*! exports provided: default */
  16633. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16634. "use strict";
  16635. __webpack_require__.r(__webpack_exports__);
  16636. var classCallCheck = function (instance, Constructor) {
  16637. if (!(instance instanceof Constructor)) {
  16638. throw new TypeError("Cannot call a class as a function");
  16639. }
  16640. };
  16641. var createClass = function () {
  16642. function defineProperties(target, props) {
  16643. for (var i = 0; i < props.length; i++) {
  16644. var descriptor = props[i];
  16645. descriptor.enumerable = descriptor.enumerable || false;
  16646. descriptor.configurable = true;
  16647. if ("value" in descriptor) descriptor.writable = true;
  16648. Object.defineProperty(target, descriptor.key, descriptor);
  16649. }
  16650. }
  16651. return function (Constructor, protoProps, staticProps) {
  16652. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  16653. if (staticProps) defineProperties(Constructor, staticProps);
  16654. return Constructor;
  16655. };
  16656. }();
  16657. var _extends = Object.assign || function (target) {
  16658. for (var i = 1; i < arguments.length; i++) {
  16659. var source = arguments[i];
  16660. for (var key in source) {
  16661. if (Object.prototype.hasOwnProperty.call(source, key)) {
  16662. target[key] = source[key];
  16663. }
  16664. }
  16665. }
  16666. return target;
  16667. };
  16668. var inherits = function (subClass, superClass) {
  16669. if (typeof superClass !== "function" && superClass !== null) {
  16670. throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  16671. }
  16672. subClass.prototype = Object.create(superClass && superClass.prototype, {
  16673. constructor: {
  16674. value: subClass,
  16675. enumerable: false,
  16676. writable: true,
  16677. configurable: true
  16678. }
  16679. });
  16680. if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
  16681. };
  16682. var possibleConstructorReturn = function (self, call) {
  16683. if (!self) {
  16684. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  16685. }
  16686. return call && (typeof call === "object" || typeof call === "function") ? call : self;
  16687. };
  16688. var Connector = function () {
  16689. /**
  16690. * Create a new class instance.
  16691. */
  16692. function Connector(options) {
  16693. classCallCheck(this, Connector);
  16694. /**
  16695. * Default connector options.
  16696. */
  16697. this._defaultOptions = {
  16698. auth: {
  16699. headers: {}
  16700. },
  16701. authEndpoint: '/broadcasting/auth',
  16702. broadcaster: 'pusher',
  16703. csrfToken: null,
  16704. host: null,
  16705. key: null,
  16706. namespace: 'App.Events'
  16707. };
  16708. this.setOptions(options);
  16709. this.connect();
  16710. }
  16711. /**
  16712. * Merge the custom options with the defaults.
  16713. */
  16714. createClass(Connector, [{
  16715. key: 'setOptions',
  16716. value: function setOptions(options) {
  16717. this.options = _extends(this._defaultOptions, options);
  16718. if (this.csrfToken()) {
  16719. this.options.auth.headers['X-CSRF-TOKEN'] = this.csrfToken();
  16720. }
  16721. return options;
  16722. }
  16723. /**
  16724. * Extract the CSRF token from the page.
  16725. */
  16726. }, {
  16727. key: 'csrfToken',
  16728. value: function csrfToken() {
  16729. var selector = void 0;
  16730. if (typeof window !== 'undefined' && window['Laravel'] && window['Laravel'].csrfToken) {
  16731. return window['Laravel'].csrfToken;
  16732. } else if (this.options.csrfToken) {
  16733. return this.options.csrfToken;
  16734. } else if (typeof document !== 'undefined' && typeof document.querySelector === 'function' && (selector = document.querySelector('meta[name="csrf-token"]'))) {
  16735. return selector.getAttribute('content');
  16736. }
  16737. return null;
  16738. }
  16739. }]);
  16740. return Connector;
  16741. }();
  16742. /**
  16743. * This class represents a basic channel.
  16744. */
  16745. var Channel = function () {
  16746. function Channel() {
  16747. classCallCheck(this, Channel);
  16748. }
  16749. createClass(Channel, [{
  16750. key: 'listenForWhisper',
  16751. /**
  16752. * Listen for a whisper event on the channel instance.
  16753. */
  16754. value: function listenForWhisper(event, callback) {
  16755. return this.listen('.client-' + event, callback);
  16756. }
  16757. /**
  16758. * Listen for an event on the channel instance.
  16759. */
  16760. }, {
  16761. key: 'notification',
  16762. value: function notification(callback) {
  16763. return this.listen('.Illuminate\\Notifications\\Events\\BroadcastNotificationCreated', callback);
  16764. }
  16765. /**
  16766. * Stop listening for a whispser event on the channel instance.
  16767. */
  16768. }, {
  16769. key: 'stopListeningForWhisper',
  16770. value: function stopListeningForWhisper(event) {
  16771. return this.stopListening('.client-' + event);
  16772. }
  16773. }]);
  16774. return Channel;
  16775. }();
  16776. /**
  16777. * Event name formatter
  16778. */
  16779. var EventFormatter = function () {
  16780. /**
  16781. * Create a new class instance.
  16782. */
  16783. function EventFormatter(namespace) {
  16784. classCallCheck(this, EventFormatter);
  16785. this.setNamespace(namespace);
  16786. }
  16787. /**
  16788. * Format the given event name.
  16789. */
  16790. createClass(EventFormatter, [{
  16791. key: 'format',
  16792. value: function format(event) {
  16793. if (event.charAt(0) === '.' || event.charAt(0) === '\\') {
  16794. return event.substr(1);
  16795. } else if (this.namespace) {
  16796. event = this.namespace + '.' + event;
  16797. }
  16798. return event.replace(/\./g, '\\');
  16799. }
  16800. /**
  16801. * Set the event namespace.
  16802. */
  16803. }, {
  16804. key: 'setNamespace',
  16805. value: function setNamespace(value) {
  16806. this.namespace = value;
  16807. }
  16808. }]);
  16809. return EventFormatter;
  16810. }();
  16811. /**
  16812. * This class represents a Pusher channel.
  16813. */
  16814. var PusherChannel = function (_Channel) {
  16815. inherits(PusherChannel, _Channel);
  16816. /**
  16817. * Create a new class instance.
  16818. */
  16819. function PusherChannel(pusher, name, options) {
  16820. classCallCheck(this, PusherChannel);
  16821. var _this = possibleConstructorReturn(this, (PusherChannel.__proto__ || Object.getPrototypeOf(PusherChannel)).call(this));
  16822. _this.name = name;
  16823. _this.pusher = pusher;
  16824. _this.options = options;
  16825. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16826. _this.subscribe();
  16827. return _this;
  16828. }
  16829. /**
  16830. * Subscribe to a Pusher channel.
  16831. */
  16832. createClass(PusherChannel, [{
  16833. key: 'subscribe',
  16834. value: function subscribe() {
  16835. this.subscription = this.pusher.subscribe(this.name);
  16836. }
  16837. /**
  16838. * Unsubscribe from a Pusher channel.
  16839. */
  16840. }, {
  16841. key: 'unsubscribe',
  16842. value: function unsubscribe() {
  16843. this.pusher.unsubscribe(this.name);
  16844. }
  16845. /**
  16846. * Listen for an event on the channel instance.
  16847. */
  16848. }, {
  16849. key: 'listen',
  16850. value: function listen(event, callback) {
  16851. this.on(this.eventFormatter.format(event), callback);
  16852. return this;
  16853. }
  16854. /**
  16855. * Stop listening for an event on the channel instance.
  16856. */
  16857. }, {
  16858. key: 'stopListening',
  16859. value: function stopListening(event) {
  16860. this.subscription.unbind(this.eventFormatter.format(event));
  16861. return this;
  16862. }
  16863. /**
  16864. * Bind a channel to an event.
  16865. */
  16866. }, {
  16867. key: 'on',
  16868. value: function on(event, callback) {
  16869. this.subscription.bind(event, callback);
  16870. return this;
  16871. }
  16872. }]);
  16873. return PusherChannel;
  16874. }(Channel);
  16875. /**
  16876. * This class represents a Pusher private channel.
  16877. */
  16878. var PusherPrivateChannel = function (_PusherChannel) {
  16879. inherits(PusherPrivateChannel, _PusherChannel);
  16880. function PusherPrivateChannel() {
  16881. classCallCheck(this, PusherPrivateChannel);
  16882. return possibleConstructorReturn(this, (PusherPrivateChannel.__proto__ || Object.getPrototypeOf(PusherPrivateChannel)).apply(this, arguments));
  16883. }
  16884. createClass(PusherPrivateChannel, [{
  16885. key: 'whisper',
  16886. /**
  16887. * Trigger client event on the channel.
  16888. */
  16889. value: function whisper(eventName, data) {
  16890. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16891. return this;
  16892. }
  16893. }]);
  16894. return PusherPrivateChannel;
  16895. }(PusherChannel);
  16896. /**
  16897. * This class represents a Pusher presence channel.
  16898. */
  16899. var PusherPresenceChannel = function (_PusherChannel) {
  16900. inherits(PusherPresenceChannel, _PusherChannel);
  16901. function PusherPresenceChannel() {
  16902. classCallCheck(this, PusherPresenceChannel);
  16903. return possibleConstructorReturn(this, (PusherPresenceChannel.__proto__ || Object.getPrototypeOf(PusherPresenceChannel)).apply(this, arguments));
  16904. }
  16905. createClass(PusherPresenceChannel, [{
  16906. key: 'here',
  16907. /**
  16908. * Register a callback to be called anytime the member list changes.
  16909. */
  16910. value: function here(callback) {
  16911. this.on('pusher:subscription_succeeded', function (data) {
  16912. callback(Object.keys(data.members).map(function (k) {
  16913. return data.members[k];
  16914. }));
  16915. });
  16916. return this;
  16917. }
  16918. /**
  16919. * Listen for someone joining the channel.
  16920. */
  16921. }, {
  16922. key: 'joining',
  16923. value: function joining(callback) {
  16924. this.on('pusher:member_added', function (member) {
  16925. callback(member.info);
  16926. });
  16927. return this;
  16928. }
  16929. /**
  16930. * Listen for someone leaving the channel.
  16931. */
  16932. }, {
  16933. key: 'leaving',
  16934. value: function leaving(callback) {
  16935. this.on('pusher:member_removed', function (member) {
  16936. callback(member.info);
  16937. });
  16938. return this;
  16939. }
  16940. /**
  16941. * Trigger client event on the channel.
  16942. */
  16943. }, {
  16944. key: 'whisper',
  16945. value: function whisper(eventName, data) {
  16946. this.pusher.channels.channels[this.name].trigger('client-' + eventName, data);
  16947. return this;
  16948. }
  16949. }]);
  16950. return PusherPresenceChannel;
  16951. }(PusherChannel);
  16952. /**
  16953. * This class represents a Socket.io channel.
  16954. */
  16955. var SocketIoChannel = function (_Channel) {
  16956. inherits(SocketIoChannel, _Channel);
  16957. /**
  16958. * Create a new class instance.
  16959. */
  16960. function SocketIoChannel(socket, name, options) {
  16961. classCallCheck(this, SocketIoChannel);
  16962. /**
  16963. * The event callbacks applied to the channel.
  16964. */
  16965. var _this = possibleConstructorReturn(this, (SocketIoChannel.__proto__ || Object.getPrototypeOf(SocketIoChannel)).call(this));
  16966. _this.events = {};
  16967. _this.name = name;
  16968. _this.socket = socket;
  16969. _this.options = options;
  16970. _this.eventFormatter = new EventFormatter(_this.options.namespace);
  16971. _this.subscribe();
  16972. _this.configureReconnector();
  16973. return _this;
  16974. }
  16975. /**
  16976. * Subscribe to a Socket.io channel.
  16977. */
  16978. createClass(SocketIoChannel, [{
  16979. key: 'subscribe',
  16980. value: function subscribe() {
  16981. this.socket.emit('subscribe', {
  16982. channel: this.name,
  16983. auth: this.options.auth || {}
  16984. });
  16985. }
  16986. /**
  16987. * Unsubscribe from channel and ubind event callbacks.
  16988. */
  16989. }, {
  16990. key: 'unsubscribe',
  16991. value: function unsubscribe() {
  16992. this.unbind();
  16993. this.socket.emit('unsubscribe', {
  16994. channel: this.name,
  16995. auth: this.options.auth || {}
  16996. });
  16997. }
  16998. /**
  16999. * Listen for an event on the channel instance.
  17000. */
  17001. }, {
  17002. key: 'listen',
  17003. value: function listen(event, callback) {
  17004. this.on(this.eventFormatter.format(event), callback);
  17005. return this;
  17006. }
  17007. /**
  17008. * Stop listening for an event on the channel instance.
  17009. */
  17010. }, {
  17011. key: 'stopListening',
  17012. value: function stopListening(event) {
  17013. var name = this.eventFormatter.format(event);
  17014. this.socket.removeListener(name);
  17015. delete this.events[name];
  17016. return this;
  17017. }
  17018. /**
  17019. * Bind the channel's socket to an event and store the callback.
  17020. */
  17021. }, {
  17022. key: 'on',
  17023. value: function on(event, callback) {
  17024. var _this2 = this;
  17025. var listener = function listener(channel, data) {
  17026. if (_this2.name == channel) {
  17027. callback(data);
  17028. }
  17029. };
  17030. this.socket.on(event, listener);
  17031. this.bind(event, listener);
  17032. }
  17033. /**
  17034. * Attach a 'reconnect' listener and bind the event.
  17035. */
  17036. }, {
  17037. key: 'configureReconnector',
  17038. value: function configureReconnector() {
  17039. var _this3 = this;
  17040. var listener = function listener() {
  17041. _this3.subscribe();
  17042. };
  17043. this.socket.on('reconnect', listener);
  17044. this.bind('reconnect', listener);
  17045. }
  17046. /**
  17047. * Bind the channel's socket to an event and store the callback.
  17048. */
  17049. }, {
  17050. key: 'bind',
  17051. value: function bind(event, callback) {
  17052. this.events[event] = this.events[event] || [];
  17053. this.events[event].push(callback);
  17054. }
  17055. /**
  17056. * Unbind the channel's socket from all stored event callbacks.
  17057. */
  17058. }, {
  17059. key: 'unbind',
  17060. value: function unbind() {
  17061. var _this4 = this;
  17062. Object.keys(this.events).forEach(function (event) {
  17063. _this4.events[event].forEach(function (callback) {
  17064. _this4.socket.removeListener(event, callback);
  17065. });
  17066. delete _this4.events[event];
  17067. });
  17068. }
  17069. }]);
  17070. return SocketIoChannel;
  17071. }(Channel);
  17072. /**
  17073. * This class represents a Socket.io presence channel.
  17074. */
  17075. var SocketIoPrivateChannel = function (_SocketIoChannel) {
  17076. inherits(SocketIoPrivateChannel, _SocketIoChannel);
  17077. function SocketIoPrivateChannel() {
  17078. classCallCheck(this, SocketIoPrivateChannel);
  17079. return possibleConstructorReturn(this, (SocketIoPrivateChannel.__proto__ || Object.getPrototypeOf(SocketIoPrivateChannel)).apply(this, arguments));
  17080. }
  17081. createClass(SocketIoPrivateChannel, [{
  17082. key: 'whisper',
  17083. /**
  17084. * Trigger client event on the channel.
  17085. */
  17086. value: function whisper(eventName, data) {
  17087. this.socket.emit('client event', {
  17088. channel: this.name,
  17089. event: 'client-' + eventName,
  17090. data: data
  17091. });
  17092. return this;
  17093. }
  17094. }]);
  17095. return SocketIoPrivateChannel;
  17096. }(SocketIoChannel);
  17097. /**
  17098. * This class represents a Socket.io presence channel.
  17099. */
  17100. var SocketIoPresenceChannel = function (_SocketIoPrivateChann) {
  17101. inherits(SocketIoPresenceChannel, _SocketIoPrivateChann);
  17102. function SocketIoPresenceChannel() {
  17103. classCallCheck(this, SocketIoPresenceChannel);
  17104. return possibleConstructorReturn(this, (SocketIoPresenceChannel.__proto__ || Object.getPrototypeOf(SocketIoPresenceChannel)).apply(this, arguments));
  17105. }
  17106. createClass(SocketIoPresenceChannel, [{
  17107. key: 'here',
  17108. /**
  17109. * Register a callback to be called anytime the member list changes.
  17110. */
  17111. value: function here(callback) {
  17112. this.on('presence:subscribed', function (members) {
  17113. callback(members.map(function (m) {
  17114. return m.user_info;
  17115. }));
  17116. });
  17117. return this;
  17118. }
  17119. /**
  17120. * Listen for someone joining the channel.
  17121. */
  17122. }, {
  17123. key: 'joining',
  17124. value: function joining(callback) {
  17125. this.on('presence:joining', function (member) {
  17126. return callback(member.user_info);
  17127. });
  17128. return this;
  17129. }
  17130. /**
  17131. * Listen for someone leaving the channel.
  17132. */
  17133. }, {
  17134. key: 'leaving',
  17135. value: function leaving(callback) {
  17136. this.on('presence:leaving', function (member) {
  17137. return callback(member.user_info);
  17138. });
  17139. return this;
  17140. }
  17141. }]);
  17142. return SocketIoPresenceChannel;
  17143. }(SocketIoPrivateChannel);
  17144. /**
  17145. * This class represents a null channel.
  17146. */
  17147. var NullChannel = function (_Channel) {
  17148. inherits(NullChannel, _Channel);
  17149. function NullChannel() {
  17150. classCallCheck(this, NullChannel);
  17151. return possibleConstructorReturn(this, (NullChannel.__proto__ || Object.getPrototypeOf(NullChannel)).apply(this, arguments));
  17152. }
  17153. createClass(NullChannel, [{
  17154. key: 'subscribe',
  17155. /**
  17156. * Subscribe to a channel.
  17157. */
  17158. value: function subscribe() {}
  17159. //
  17160. /**
  17161. * Unsubscribe from a channel.
  17162. */
  17163. }, {
  17164. key: 'unsubscribe',
  17165. value: function unsubscribe() {}
  17166. //
  17167. /**
  17168. * Listen for an event on the channel instance.
  17169. */
  17170. }, {
  17171. key: 'listen',
  17172. value: function listen(event, callback) {
  17173. return this;
  17174. }
  17175. /**
  17176. * Stop listening for an event on the channel instance.
  17177. */
  17178. }, {
  17179. key: 'stopListening',
  17180. value: function stopListening(event) {
  17181. return this;
  17182. }
  17183. /**
  17184. * Bind a channel to an event.
  17185. */
  17186. }, {
  17187. key: 'on',
  17188. value: function on(event, callback) {
  17189. return this;
  17190. }
  17191. }]);
  17192. return NullChannel;
  17193. }(Channel);
  17194. /**
  17195. * This class represents a null private channel.
  17196. */
  17197. var NullPrivateChannel = function (_NullChannel) {
  17198. inherits(NullPrivateChannel, _NullChannel);
  17199. function NullPrivateChannel() {
  17200. classCallCheck(this, NullPrivateChannel);
  17201. return possibleConstructorReturn(this, (NullPrivateChannel.__proto__ || Object.getPrototypeOf(NullPrivateChannel)).apply(this, arguments));
  17202. }
  17203. createClass(NullPrivateChannel, [{
  17204. key: 'whisper',
  17205. /**
  17206. * Trigger client event on the channel.
  17207. */
  17208. value: function whisper(eventName, data) {
  17209. return this;
  17210. }
  17211. }]);
  17212. return NullPrivateChannel;
  17213. }(NullChannel);
  17214. /**
  17215. * This class represents a null presence channel.
  17216. */
  17217. var NullPresenceChannel = function (_NullChannel) {
  17218. inherits(NullPresenceChannel, _NullChannel);
  17219. function NullPresenceChannel() {
  17220. classCallCheck(this, NullPresenceChannel);
  17221. return possibleConstructorReturn(this, (NullPresenceChannel.__proto__ || Object.getPrototypeOf(NullPresenceChannel)).apply(this, arguments));
  17222. }
  17223. createClass(NullPresenceChannel, [{
  17224. key: 'here',
  17225. /**
  17226. * Register a callback to be called anytime the member list changes.
  17227. */
  17228. value: function here(callback) {
  17229. return this;
  17230. }
  17231. /**
  17232. * Listen for someone joining the channel.
  17233. */
  17234. }, {
  17235. key: 'joining',
  17236. value: function joining(callback) {
  17237. return this;
  17238. }
  17239. /**
  17240. * Listen for someone leaving the channel.
  17241. */
  17242. }, {
  17243. key: 'leaving',
  17244. value: function leaving(callback) {
  17245. return this;
  17246. }
  17247. /**
  17248. * Trigger client event on the channel.
  17249. */
  17250. }, {
  17251. key: 'whisper',
  17252. value: function whisper(eventName, data) {
  17253. return this;
  17254. }
  17255. }]);
  17256. return NullPresenceChannel;
  17257. }(NullChannel);
  17258. /**
  17259. * This class creates a connector to Pusher.
  17260. */
  17261. var PusherConnector = function (_Connector) {
  17262. inherits(PusherConnector, _Connector);
  17263. function PusherConnector() {
  17264. classCallCheck(this, PusherConnector);
  17265. /**
  17266. * All of the subscribed channel names.
  17267. */
  17268. var _this = possibleConstructorReturn(this, (PusherConnector.__proto__ || Object.getPrototypeOf(PusherConnector)).apply(this, arguments));
  17269. _this.channels = {};
  17270. return _this;
  17271. }
  17272. /**
  17273. * Create a fresh Pusher connection.
  17274. */
  17275. createClass(PusherConnector, [{
  17276. key: 'connect',
  17277. value: function connect() {
  17278. if (typeof this.options.client !== 'undefined') {
  17279. this.pusher = this.options.client;
  17280. } else {
  17281. this.pusher = new Pusher(this.options.key, this.options);
  17282. }
  17283. }
  17284. /**
  17285. * Listen for an event on a channel instance.
  17286. */
  17287. }, {
  17288. key: 'listen',
  17289. value: function listen(name, event, callback) {
  17290. return this.channel(name).listen(event, callback);
  17291. }
  17292. /**
  17293. * Get a channel instance by name.
  17294. */
  17295. }, {
  17296. key: 'channel',
  17297. value: function channel(name) {
  17298. if (!this.channels[name]) {
  17299. this.channels[name] = new PusherChannel(this.pusher, name, this.options);
  17300. }
  17301. return this.channels[name];
  17302. }
  17303. /**
  17304. * Get a private channel instance by name.
  17305. */
  17306. }, {
  17307. key: 'privateChannel',
  17308. value: function privateChannel(name) {
  17309. if (!this.channels['private-' + name]) {
  17310. this.channels['private-' + name] = new PusherPrivateChannel(this.pusher, 'private-' + name, this.options);
  17311. }
  17312. return this.channels['private-' + name];
  17313. }
  17314. /**
  17315. * Get a presence channel instance by name.
  17316. */
  17317. }, {
  17318. key: 'presenceChannel',
  17319. value: function presenceChannel(name) {
  17320. if (!this.channels['presence-' + name]) {
  17321. this.channels['presence-' + name] = new PusherPresenceChannel(this.pusher, 'presence-' + name, this.options);
  17322. }
  17323. return this.channels['presence-' + name];
  17324. }
  17325. /**
  17326. * Leave the given channel, as well as its private and presence variants.
  17327. */
  17328. }, {
  17329. key: 'leave',
  17330. value: function leave(name) {
  17331. var _this2 = this;
  17332. var channels = [name, 'private-' + name, 'presence-' + name];
  17333. channels.forEach(function (name, index) {
  17334. _this2.leaveChannel(name);
  17335. });
  17336. }
  17337. /**
  17338. * Leave the given channel.
  17339. */
  17340. }, {
  17341. key: 'leaveChannel',
  17342. value: function leaveChannel(name) {
  17343. if (this.channels[name]) {
  17344. this.channels[name].unsubscribe();
  17345. delete this.channels[name];
  17346. }
  17347. }
  17348. /**
  17349. * Get the socket ID for the connection.
  17350. */
  17351. }, {
  17352. key: 'socketId',
  17353. value: function socketId() {
  17354. return this.pusher.connection.socket_id;
  17355. }
  17356. /**
  17357. * Disconnect Pusher connection.
  17358. */
  17359. }, {
  17360. key: 'disconnect',
  17361. value: function disconnect() {
  17362. this.pusher.disconnect();
  17363. }
  17364. }]);
  17365. return PusherConnector;
  17366. }(Connector);
  17367. /**
  17368. * This class creates a connnector to a Socket.io server.
  17369. */
  17370. var SocketIoConnector = function (_Connector) {
  17371. inherits(SocketIoConnector, _Connector);
  17372. function SocketIoConnector() {
  17373. classCallCheck(this, SocketIoConnector);
  17374. /**
  17375. * All of the subscribed channel names.
  17376. */
  17377. var _this = possibleConstructorReturn(this, (SocketIoConnector.__proto__ || Object.getPrototypeOf(SocketIoConnector)).apply(this, arguments));
  17378. _this.channels = {};
  17379. return _this;
  17380. }
  17381. /**
  17382. * Create a fresh Socket.io connection.
  17383. */
  17384. createClass(SocketIoConnector, [{
  17385. key: 'connect',
  17386. value: function connect() {
  17387. var io = this.getSocketIO();
  17388. this.socket = io(this.options.host, this.options);
  17389. return this.socket;
  17390. }
  17391. /**
  17392. * Get socket.io module from global scope or options.
  17393. */
  17394. }, {
  17395. key: 'getSocketIO',
  17396. value: function getSocketIO() {
  17397. if (typeof this.options.client !== 'undefined') {
  17398. return this.options.client;
  17399. }
  17400. if (typeof io !== 'undefined') {
  17401. return io;
  17402. }
  17403. throw new Error('Socket.io client not found. Should be globally available or passed via options.client');
  17404. }
  17405. /**
  17406. * Listen for an event on a channel instance.
  17407. */
  17408. }, {
  17409. key: 'listen',
  17410. value: function listen(name, event, callback) {
  17411. return this.channel(name).listen(event, callback);
  17412. }
  17413. /**
  17414. * Get a channel instance by name.
  17415. */
  17416. }, {
  17417. key: 'channel',
  17418. value: function channel(name) {
  17419. if (!this.channels[name]) {
  17420. this.channels[name] = new SocketIoChannel(this.socket, name, this.options);
  17421. }
  17422. return this.channels[name];
  17423. }
  17424. /**
  17425. * Get a private channel instance by name.
  17426. */
  17427. }, {
  17428. key: 'privateChannel',
  17429. value: function privateChannel(name) {
  17430. if (!this.channels['private-' + name]) {
  17431. this.channels['private-' + name] = new SocketIoPrivateChannel(this.socket, 'private-' + name, this.options);
  17432. }
  17433. return this.channels['private-' + name];
  17434. }
  17435. /**
  17436. * Get a presence channel instance by name.
  17437. */
  17438. }, {
  17439. key: 'presenceChannel',
  17440. value: function presenceChannel(name) {
  17441. if (!this.channels['presence-' + name]) {
  17442. this.channels['presence-' + name] = new SocketIoPresenceChannel(this.socket, 'presence-' + name, this.options);
  17443. }
  17444. return this.channels['presence-' + name];
  17445. }
  17446. /**
  17447. * Leave the given channel, as well as its private and presence variants.
  17448. */
  17449. }, {
  17450. key: 'leave',
  17451. value: function leave(name) {
  17452. var _this2 = this;
  17453. var channels = [name, 'private-' + name, 'presence-' + name];
  17454. channels.forEach(function (name) {
  17455. _this2.leaveChannel(name);
  17456. });
  17457. }
  17458. /**
  17459. * Leave the given channel.
  17460. */
  17461. }, {
  17462. key: 'leaveChannel',
  17463. value: function leaveChannel(name) {
  17464. if (this.channels[name]) {
  17465. this.channels[name].unsubscribe();
  17466. delete this.channels[name];
  17467. }
  17468. }
  17469. /**
  17470. * Get the socket ID for the connection.
  17471. */
  17472. }, {
  17473. key: 'socketId',
  17474. value: function socketId() {
  17475. return this.socket.id;
  17476. }
  17477. /**
  17478. * Disconnect Socketio connection.
  17479. */
  17480. }, {
  17481. key: 'disconnect',
  17482. value: function disconnect() {
  17483. this.socket.disconnect();
  17484. }
  17485. }]);
  17486. return SocketIoConnector;
  17487. }(Connector);
  17488. /**
  17489. * This class creates a null connector.
  17490. */
  17491. var NullConnector = function (_Connector) {
  17492. inherits(NullConnector, _Connector);
  17493. function NullConnector() {
  17494. classCallCheck(this, NullConnector);
  17495. /**
  17496. * All of the subscribed channel names.
  17497. */
  17498. var _this = possibleConstructorReturn(this, (NullConnector.__proto__ || Object.getPrototypeOf(NullConnector)).apply(this, arguments));
  17499. _this.channels = {};
  17500. return _this;
  17501. }
  17502. /**
  17503. * Create a fresh connection.
  17504. */
  17505. createClass(NullConnector, [{
  17506. key: 'connect',
  17507. value: function connect() {}
  17508. //
  17509. /**
  17510. * Listen for an event on a channel instance.
  17511. */
  17512. }, {
  17513. key: 'listen',
  17514. value: function listen(name, event, callback) {
  17515. return new NullChannel();
  17516. }
  17517. /**
  17518. * Get a channel instance by name.
  17519. */
  17520. }, {
  17521. key: 'channel',
  17522. value: function channel(name) {
  17523. return new NullChannel();
  17524. }
  17525. /**
  17526. * Get a private channel instance by name.
  17527. */
  17528. }, {
  17529. key: 'privateChannel',
  17530. value: function privateChannel(name) {
  17531. return new NullPrivateChannel();
  17532. }
  17533. /**
  17534. * Get a presence channel instance by name.
  17535. */
  17536. }, {
  17537. key: 'presenceChannel',
  17538. value: function presenceChannel(name) {
  17539. return new NullPresenceChannel();
  17540. }
  17541. /**
  17542. * Leave the given channel, as well as its private and presence variants.
  17543. */
  17544. }, {
  17545. key: 'leave',
  17546. value: function leave(name) {}
  17547. //
  17548. /**
  17549. * Leave the given channel.
  17550. */
  17551. }, {
  17552. key: 'leaveChannel',
  17553. value: function leaveChannel(name) {}
  17554. //
  17555. /**
  17556. * Get the socket ID for the connection.
  17557. */
  17558. }, {
  17559. key: 'socketId',
  17560. value: function socketId() {
  17561. return 'fake-socket-id';
  17562. }
  17563. /**
  17564. * Disconnect the connection.
  17565. */
  17566. }, {
  17567. key: 'disconnect',
  17568. value: function disconnect() {
  17569. //
  17570. }
  17571. }]);
  17572. return NullConnector;
  17573. }(Connector);
  17574. /**
  17575. * This class is the primary API for interacting with broadcasting.
  17576. */
  17577. var Echo = function () {
  17578. /**
  17579. * Create a new class instance.
  17580. */
  17581. function Echo(options) {
  17582. classCallCheck(this, Echo);
  17583. this.options = options;
  17584. this.connect();
  17585. if (!this.options.withoutInterceptors) {
  17586. this.registerInterceptors();
  17587. }
  17588. }
  17589. /**
  17590. * Get a channel instance by name.
  17591. */
  17592. createClass(Echo, [{
  17593. key: 'channel',
  17594. value: function channel(_channel) {
  17595. return this.connector.channel(_channel);
  17596. }
  17597. /**
  17598. * Create a new connection.
  17599. */
  17600. }, {
  17601. key: 'connect',
  17602. value: function connect() {
  17603. if (this.options.broadcaster == 'pusher') {
  17604. this.connector = new PusherConnector(this.options);
  17605. } else if (this.options.broadcaster == 'socket.io') {
  17606. this.connector = new SocketIoConnector(this.options);
  17607. } else if (this.options.broadcaster == 'null') {
  17608. this.connector = new NullConnector(this.options);
  17609. } else if (typeof this.options.broadcaster == 'function') {
  17610. this.connector = new this.options.broadcaster(this.options);
  17611. }
  17612. }
  17613. /**
  17614. * Disconnect from the Echo server.
  17615. */
  17616. }, {
  17617. key: 'disconnect',
  17618. value: function disconnect() {
  17619. this.connector.disconnect();
  17620. }
  17621. /**
  17622. * Get a presence channel instance by name.
  17623. */
  17624. }, {
  17625. key: 'join',
  17626. value: function join(channel) {
  17627. return this.connector.presenceChannel(channel);
  17628. }
  17629. /**
  17630. * Leave the given channel, as well as its private and presence variants.
  17631. */
  17632. }, {
  17633. key: 'leave',
  17634. value: function leave(channel) {
  17635. this.connector.leave(channel);
  17636. }
  17637. /**
  17638. * Leave the given channel.
  17639. */
  17640. }, {
  17641. key: 'leaveChannel',
  17642. value: function leaveChannel(channel) {
  17643. this.connector.leaveChannel(channel);
  17644. }
  17645. /**
  17646. * Listen for an event on a channel instance.
  17647. */
  17648. }, {
  17649. key: 'listen',
  17650. value: function listen(channel, event, callback) {
  17651. return this.connector.listen(channel, event, callback);
  17652. }
  17653. /**
  17654. * Get a private channel instance by name.
  17655. */
  17656. }, {
  17657. key: 'private',
  17658. value: function _private(channel) {
  17659. return this.connector.privateChannel(channel);
  17660. }
  17661. /**
  17662. * Get the Socket ID for the connection.
  17663. */
  17664. }, {
  17665. key: 'socketId',
  17666. value: function socketId() {
  17667. return this.connector.socketId();
  17668. }
  17669. /**
  17670. * Register 3rd party request interceptiors. These are used to automatically
  17671. * send a connections socket id to a Laravel app with a X-Socket-Id header.
  17672. */
  17673. }, {
  17674. key: 'registerInterceptors',
  17675. value: function registerInterceptors() {
  17676. if (typeof Vue === 'function' && Vue.http) {
  17677. this.registerVueRequestInterceptor();
  17678. }
  17679. if (typeof axios === 'function') {
  17680. this.registerAxiosRequestInterceptor();
  17681. }
  17682. if (typeof jQuery === 'function') {
  17683. this.registerjQueryAjaxSetup();
  17684. }
  17685. }
  17686. /**
  17687. * Register a Vue HTTP interceptor to add the X-Socket-ID header.
  17688. */
  17689. }, {
  17690. key: 'registerVueRequestInterceptor',
  17691. value: function registerVueRequestInterceptor() {
  17692. var _this = this;
  17693. Vue.http.interceptors.push(function (request, next) {
  17694. if (_this.socketId()) {
  17695. request.headers.set('X-Socket-ID', _this.socketId());
  17696. }
  17697. next();
  17698. });
  17699. }
  17700. /**
  17701. * Register an Axios HTTP interceptor to add the X-Socket-ID header.
  17702. */
  17703. }, {
  17704. key: 'registerAxiosRequestInterceptor',
  17705. value: function registerAxiosRequestInterceptor() {
  17706. var _this2 = this;
  17707. axios.interceptors.request.use(function (config) {
  17708. if (_this2.socketId()) {
  17709. config.headers['X-Socket-Id'] = _this2.socketId();
  17710. }
  17711. return config;
  17712. });
  17713. }
  17714. /**
  17715. * Register jQuery AjaxPrefilter to add the X-Socket-ID header.
  17716. */
  17717. }, {
  17718. key: 'registerjQueryAjaxSetup',
  17719. value: function registerjQueryAjaxSetup() {
  17720. var _this3 = this;
  17721. if (typeof jQuery.ajax != 'undefined') {
  17722. jQuery.ajaxPrefilter(function (options, originalOptions, xhr) {
  17723. if (_this3.socketId()) {
  17724. xhr.setRequestHeader('X-Socket-Id', _this3.socketId());
  17725. }
  17726. });
  17727. }
  17728. }
  17729. }]);
  17730. return Echo;
  17731. }();
  17732. /* harmony default export */ __webpack_exports__["default"] = (Echo);
  17733. /***/ }),
  17734. /***/ "./node_modules/lodash/lodash.js":
  17735. /*!***************************************!*\
  17736. !*** ./node_modules/lodash/lodash.js ***!
  17737. \***************************************/
  17738. /*! no static exports found */
  17739. /***/ (function(module, exports, __webpack_require__) {
  17740. /* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_RESULT__;/**
  17741. * @license
  17742. * Lodash <https://lodash.com/>
  17743. * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
  17744. * Released under MIT license <https://lodash.com/license>
  17745. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  17746. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  17747. */
  17748. ;(function() {
  17749. /** Used as a safe reference for `undefined` in pre-ES5 environments. */
  17750. var undefined;
  17751. /** Used as the semantic version number. */
  17752. var VERSION = '4.17.15';
  17753. /** Used as the size to enable large array optimizations. */
  17754. var LARGE_ARRAY_SIZE = 200;
  17755. /** Error message constants. */
  17756. var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
  17757. FUNC_ERROR_TEXT = 'Expected a function';
  17758. /** Used to stand-in for `undefined` hash values. */
  17759. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  17760. /** Used as the maximum memoize cache size. */
  17761. var MAX_MEMOIZE_SIZE = 500;
  17762. /** Used as the internal argument placeholder. */
  17763. var PLACEHOLDER = '__lodash_placeholder__';
  17764. /** Used to compose bitmasks for cloning. */
  17765. var CLONE_DEEP_FLAG = 1,
  17766. CLONE_FLAT_FLAG = 2,
  17767. CLONE_SYMBOLS_FLAG = 4;
  17768. /** Used to compose bitmasks for value comparisons. */
  17769. var COMPARE_PARTIAL_FLAG = 1,
  17770. COMPARE_UNORDERED_FLAG = 2;
  17771. /** Used to compose bitmasks for function metadata. */
  17772. var WRAP_BIND_FLAG = 1,
  17773. WRAP_BIND_KEY_FLAG = 2,
  17774. WRAP_CURRY_BOUND_FLAG = 4,
  17775. WRAP_CURRY_FLAG = 8,
  17776. WRAP_CURRY_RIGHT_FLAG = 16,
  17777. WRAP_PARTIAL_FLAG = 32,
  17778. WRAP_PARTIAL_RIGHT_FLAG = 64,
  17779. WRAP_ARY_FLAG = 128,
  17780. WRAP_REARG_FLAG = 256,
  17781. WRAP_FLIP_FLAG = 512;
  17782. /** Used as default options for `_.truncate`. */
  17783. var DEFAULT_TRUNC_LENGTH = 30,
  17784. DEFAULT_TRUNC_OMISSION = '...';
  17785. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  17786. var HOT_COUNT = 800,
  17787. HOT_SPAN = 16;
  17788. /** Used to indicate the type of lazy iteratees. */
  17789. var LAZY_FILTER_FLAG = 1,
  17790. LAZY_MAP_FLAG = 2,
  17791. LAZY_WHILE_FLAG = 3;
  17792. /** Used as references for various `Number` constants. */
  17793. var INFINITY = 1 / 0,
  17794. MAX_SAFE_INTEGER = 9007199254740991,
  17795. MAX_INTEGER = 1.7976931348623157e+308,
  17796. NAN = 0 / 0;
  17797. /** Used as references for the maximum length and index of an array. */
  17798. var MAX_ARRAY_LENGTH = 4294967295,
  17799. MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
  17800. HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
  17801. /** Used to associate wrap methods with their bit flags. */
  17802. var wrapFlags = [
  17803. ['ary', WRAP_ARY_FLAG],
  17804. ['bind', WRAP_BIND_FLAG],
  17805. ['bindKey', WRAP_BIND_KEY_FLAG],
  17806. ['curry', WRAP_CURRY_FLAG],
  17807. ['curryRight', WRAP_CURRY_RIGHT_FLAG],
  17808. ['flip', WRAP_FLIP_FLAG],
  17809. ['partial', WRAP_PARTIAL_FLAG],
  17810. ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
  17811. ['rearg', WRAP_REARG_FLAG]
  17812. ];
  17813. /** `Object#toString` result references. */
  17814. var argsTag = '[object Arguments]',
  17815. arrayTag = '[object Array]',
  17816. asyncTag = '[object AsyncFunction]',
  17817. boolTag = '[object Boolean]',
  17818. dateTag = '[object Date]',
  17819. domExcTag = '[object DOMException]',
  17820. errorTag = '[object Error]',
  17821. funcTag = '[object Function]',
  17822. genTag = '[object GeneratorFunction]',
  17823. mapTag = '[object Map]',
  17824. numberTag = '[object Number]',
  17825. nullTag = '[object Null]',
  17826. objectTag = '[object Object]',
  17827. promiseTag = '[object Promise]',
  17828. proxyTag = '[object Proxy]',
  17829. regexpTag = '[object RegExp]',
  17830. setTag = '[object Set]',
  17831. stringTag = '[object String]',
  17832. symbolTag = '[object Symbol]',
  17833. undefinedTag = '[object Undefined]',
  17834. weakMapTag = '[object WeakMap]',
  17835. weakSetTag = '[object WeakSet]';
  17836. var arrayBufferTag = '[object ArrayBuffer]',
  17837. dataViewTag = '[object DataView]',
  17838. float32Tag = '[object Float32Array]',
  17839. float64Tag = '[object Float64Array]',
  17840. int8Tag = '[object Int8Array]',
  17841. int16Tag = '[object Int16Array]',
  17842. int32Tag = '[object Int32Array]',
  17843. uint8Tag = '[object Uint8Array]',
  17844. uint8ClampedTag = '[object Uint8ClampedArray]',
  17845. uint16Tag = '[object Uint16Array]',
  17846. uint32Tag = '[object Uint32Array]';
  17847. /** Used to match empty string literals in compiled template source. */
  17848. var reEmptyStringLeading = /\b__p \+= '';/g,
  17849. reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
  17850. reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
  17851. /** Used to match HTML entities and HTML characters. */
  17852. var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
  17853. reUnescapedHtml = /[&<>"']/g,
  17854. reHasEscapedHtml = RegExp(reEscapedHtml.source),
  17855. reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
  17856. /** Used to match template delimiters. */
  17857. var reEscape = /<%-([\s\S]+?)%>/g,
  17858. reEvaluate = /<%([\s\S]+?)%>/g,
  17859. reInterpolate = /<%=([\s\S]+?)%>/g;
  17860. /** Used to match property names within property paths. */
  17861. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  17862. reIsPlainProp = /^\w*$/,
  17863. rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  17864. /**
  17865. * Used to match `RegExp`
  17866. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  17867. */
  17868. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
  17869. reHasRegExpChar = RegExp(reRegExpChar.source);
  17870. /** Used to match leading and trailing whitespace. */
  17871. var reTrim = /^\s+|\s+$/g,
  17872. reTrimStart = /^\s+/,
  17873. reTrimEnd = /\s+$/;
  17874. /** Used to match wrap detail comments. */
  17875. var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
  17876. reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
  17877. reSplitDetails = /,? & /;
  17878. /** Used to match words composed of alphanumeric characters. */
  17879. var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
  17880. /** Used to match backslashes in property paths. */
  17881. var reEscapeChar = /\\(\\)?/g;
  17882. /**
  17883. * Used to match
  17884. * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
  17885. */
  17886. var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
  17887. /** Used to match `RegExp` flags from their coerced string values. */
  17888. var reFlags = /\w*$/;
  17889. /** Used to detect bad signed hexadecimal string values. */
  17890. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  17891. /** Used to detect binary string values. */
  17892. var reIsBinary = /^0b[01]+$/i;
  17893. /** Used to detect host constructors (Safari). */
  17894. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  17895. /** Used to detect octal string values. */
  17896. var reIsOctal = /^0o[0-7]+$/i;
  17897. /** Used to detect unsigned integer values. */
  17898. var reIsUint = /^(?:0|[1-9]\d*)$/;
  17899. /** Used to match Latin Unicode letters (excluding mathematical operators). */
  17900. var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
  17901. /** Used to ensure capturing order of template delimiters. */
  17902. var reNoMatch = /($^)/;
  17903. /** Used to match unescaped characters in compiled string literals. */
  17904. var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
  17905. /** Used to compose unicode character classes. */
  17906. var rsAstralRange = '\\ud800-\\udfff',
  17907. rsComboMarksRange = '\\u0300-\\u036f',
  17908. reComboHalfMarksRange = '\\ufe20-\\ufe2f',
  17909. rsComboSymbolsRange = '\\u20d0-\\u20ff',
  17910. rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
  17911. rsDingbatRange = '\\u2700-\\u27bf',
  17912. rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
  17913. rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
  17914. rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
  17915. rsPunctuationRange = '\\u2000-\\u206f',
  17916. 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',
  17917. rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde',
  17918. rsVarRange = '\\ufe0e\\ufe0f',
  17919. rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
  17920. /** Used to compose unicode capture groups. */
  17921. var rsApos = "['\u2019]",
  17922. rsAstral = '[' + rsAstralRange + ']',
  17923. rsBreak = '[' + rsBreakRange + ']',
  17924. rsCombo = '[' + rsComboRange + ']',
  17925. rsDigits = '\\d+',
  17926. rsDingbat = '[' + rsDingbatRange + ']',
  17927. rsLower = '[' + rsLowerRange + ']',
  17928. rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']',
  17929. rsFitz = '\\ud83c[\\udffb-\\udfff]',
  17930. rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
  17931. rsNonAstral = '[^' + rsAstralRange + ']',
  17932. rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
  17933. rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
  17934. rsUpper = '[' + rsUpperRange + ']',
  17935. rsZWJ = '\\u200d';
  17936. /** Used to compose unicode regexes. */
  17937. var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
  17938. rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
  17939. rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
  17940. rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
  17941. reOptMod = rsModifier + '?',
  17942. rsOptVar = '[' + rsVarRange + ']?',
  17943. rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
  17944. rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])',
  17945. rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])',
  17946. rsSeq = rsOptVar + reOptMod + rsOptJoin,
  17947. rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
  17948. rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
  17949. /** Used to match apostrophes. */
  17950. var reApos = RegExp(rsApos, 'g');
  17951. /**
  17952. * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and
  17953. * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols).
  17954. */
  17955. var reComboMark = RegExp(rsCombo, 'g');
  17956. /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
  17957. var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
  17958. /** Used to match complex or compound words. */
  17959. var reUnicodeWord = RegExp([
  17960. rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
  17961. rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
  17962. rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
  17963. rsUpper + '+' + rsOptContrUpper,
  17964. rsOrdUpper,
  17965. rsOrdLower,
  17966. rsDigits,
  17967. rsEmoji
  17968. ].join('|'), 'g');
  17969. /** 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/). */
  17970. var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
  17971. /** Used to detect strings that need a more robust regexp to match words. */
  17972. 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 ]/;
  17973. /** Used to assign default `context` object properties. */
  17974. var contextProps = [
  17975. 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
  17976. 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
  17977. 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
  17978. 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
  17979. '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
  17980. ];
  17981. /** Used to make template sourceURLs easier to identify. */
  17982. var templateCounter = -1;
  17983. /** Used to identify `toStringTag` values of typed arrays. */
  17984. var typedArrayTags = {};
  17985. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  17986. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  17987. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  17988. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  17989. typedArrayTags[uint32Tag] = true;
  17990. typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
  17991. typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
  17992. typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
  17993. typedArrayTags[errorTag] = typedArrayTags[funcTag] =
  17994. typedArrayTags[mapTag] = typedArrayTags[numberTag] =
  17995. typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
  17996. typedArrayTags[setTag] = typedArrayTags[stringTag] =
  17997. typedArrayTags[weakMapTag] = false;
  17998. /** Used to identify `toStringTag` values supported by `_.clone`. */
  17999. var cloneableTags = {};
  18000. cloneableTags[argsTag] = cloneableTags[arrayTag] =
  18001. cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
  18002. cloneableTags[boolTag] = cloneableTags[dateTag] =
  18003. cloneableTags[float32Tag] = cloneableTags[float64Tag] =
  18004. cloneableTags[int8Tag] = cloneableTags[int16Tag] =
  18005. cloneableTags[int32Tag] = cloneableTags[mapTag] =
  18006. cloneableTags[numberTag] = cloneableTags[objectTag] =
  18007. cloneableTags[regexpTag] = cloneableTags[setTag] =
  18008. cloneableTags[stringTag] = cloneableTags[symbolTag] =
  18009. cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
  18010. cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
  18011. cloneableTags[errorTag] = cloneableTags[funcTag] =
  18012. cloneableTags[weakMapTag] = false;
  18013. /** Used to map Latin Unicode letters to basic Latin letters. */
  18014. var deburredLetters = {
  18015. // Latin-1 Supplement block.
  18016. '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
  18017. '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
  18018. '\xc7': 'C', '\xe7': 'c',
  18019. '\xd0': 'D', '\xf0': 'd',
  18020. '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
  18021. '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
  18022. '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
  18023. '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
  18024. '\xd1': 'N', '\xf1': 'n',
  18025. '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
  18026. '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
  18027. '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U',
  18028. '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
  18029. '\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
  18030. '\xc6': 'Ae', '\xe6': 'ae',
  18031. '\xde': 'Th', '\xfe': 'th',
  18032. '\xdf': 'ss',
  18033. // Latin Extended-A block.
  18034. '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
  18035. '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
  18036. '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
  18037. '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
  18038. '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
  18039. '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
  18040. '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
  18041. '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
  18042. '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
  18043. '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
  18044. '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
  18045. '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
  18046. '\u0134': 'J', '\u0135': 'j',
  18047. '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
  18048. '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
  18049. '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
  18050. '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
  18051. '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
  18052. '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
  18053. '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
  18054. '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
  18055. '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
  18056. '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
  18057. '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
  18058. '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
  18059. '\u0163': 't', '\u0165': 't', '\u0167': 't',
  18060. '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
  18061. '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
  18062. '\u0174': 'W', '\u0175': 'w',
  18063. '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
  18064. '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
  18065. '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
  18066. '\u0132': 'IJ', '\u0133': 'ij',
  18067. '\u0152': 'Oe', '\u0153': 'oe',
  18068. '\u0149': "'n", '\u017f': 's'
  18069. };
  18070. /** Used to map characters to HTML entities. */
  18071. var htmlEscapes = {
  18072. '&': '&amp;',
  18073. '<': '&lt;',
  18074. '>': '&gt;',
  18075. '"': '&quot;',
  18076. "'": '&#39;'
  18077. };
  18078. /** Used to map HTML entities to characters. */
  18079. var htmlUnescapes = {
  18080. '&amp;': '&',
  18081. '&lt;': '<',
  18082. '&gt;': '>',
  18083. '&quot;': '"',
  18084. '&#39;': "'"
  18085. };
  18086. /** Used to escape characters for inclusion in compiled string literals. */
  18087. var stringEscapes = {
  18088. '\\': '\\',
  18089. "'": "'",
  18090. '\n': 'n',
  18091. '\r': 'r',
  18092. '\u2028': 'u2028',
  18093. '\u2029': 'u2029'
  18094. };
  18095. /** Built-in method references without a dependency on `root`. */
  18096. var freeParseFloat = parseFloat,
  18097. freeParseInt = parseInt;
  18098. /** Detect free variable `global` from Node.js. */
  18099. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  18100. /** Detect free variable `self`. */
  18101. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  18102. /** Used as a reference to the global object. */
  18103. var root = freeGlobal || freeSelf || Function('return this')();
  18104. /** Detect free variable `exports`. */
  18105. var freeExports = true && exports && !exports.nodeType && exports;
  18106. /** Detect free variable `module`. */
  18107. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  18108. /** Detect the popular CommonJS extension `module.exports`. */
  18109. var moduleExports = freeModule && freeModule.exports === freeExports;
  18110. /** Detect free variable `process` from Node.js. */
  18111. var freeProcess = moduleExports && freeGlobal.process;
  18112. /** Used to access faster Node.js helpers. */
  18113. var nodeUtil = (function() {
  18114. try {
  18115. // Use `util.types` for Node.js 10+.
  18116. var types = freeModule && freeModule.require && freeModule.require('util').types;
  18117. if (types) {
  18118. return types;
  18119. }
  18120. // Legacy `process.binding('util')` for Node.js < 10.
  18121. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  18122. } catch (e) {}
  18123. }());
  18124. /* Node.js helper references. */
  18125. var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
  18126. nodeIsDate = nodeUtil && nodeUtil.isDate,
  18127. nodeIsMap = nodeUtil && nodeUtil.isMap,
  18128. nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
  18129. nodeIsSet = nodeUtil && nodeUtil.isSet,
  18130. nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  18131. /*--------------------------------------------------------------------------*/
  18132. /**
  18133. * A faster alternative to `Function#apply`, this function invokes `func`
  18134. * with the `this` binding of `thisArg` and the arguments of `args`.
  18135. *
  18136. * @private
  18137. * @param {Function} func The function to invoke.
  18138. * @param {*} thisArg The `this` binding of `func`.
  18139. * @param {Array} args The arguments to invoke `func` with.
  18140. * @returns {*} Returns the result of `func`.
  18141. */
  18142. function apply(func, thisArg, args) {
  18143. switch (args.length) {
  18144. case 0: return func.call(thisArg);
  18145. case 1: return func.call(thisArg, args[0]);
  18146. case 2: return func.call(thisArg, args[0], args[1]);
  18147. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  18148. }
  18149. return func.apply(thisArg, args);
  18150. }
  18151. /**
  18152. * A specialized version of `baseAggregator` for arrays.
  18153. *
  18154. * @private
  18155. * @param {Array} [array] The array to iterate over.
  18156. * @param {Function} setter The function to set `accumulator` values.
  18157. * @param {Function} iteratee The iteratee to transform keys.
  18158. * @param {Object} accumulator The initial aggregated object.
  18159. * @returns {Function} Returns `accumulator`.
  18160. */
  18161. function arrayAggregator(array, setter, iteratee, accumulator) {
  18162. var index = -1,
  18163. length = array == null ? 0 : array.length;
  18164. while (++index < length) {
  18165. var value = array[index];
  18166. setter(accumulator, value, iteratee(value), array);
  18167. }
  18168. return accumulator;
  18169. }
  18170. /**
  18171. * A specialized version of `_.forEach` for arrays without support for
  18172. * iteratee shorthands.
  18173. *
  18174. * @private
  18175. * @param {Array} [array] The array to iterate over.
  18176. * @param {Function} iteratee The function invoked per iteration.
  18177. * @returns {Array} Returns `array`.
  18178. */
  18179. function arrayEach(array, iteratee) {
  18180. var index = -1,
  18181. length = array == null ? 0 : array.length;
  18182. while (++index < length) {
  18183. if (iteratee(array[index], index, array) === false) {
  18184. break;
  18185. }
  18186. }
  18187. return array;
  18188. }
  18189. /**
  18190. * A specialized version of `_.forEachRight` for arrays without support for
  18191. * iteratee shorthands.
  18192. *
  18193. * @private
  18194. * @param {Array} [array] The array to iterate over.
  18195. * @param {Function} iteratee The function invoked per iteration.
  18196. * @returns {Array} Returns `array`.
  18197. */
  18198. function arrayEachRight(array, iteratee) {
  18199. var length = array == null ? 0 : array.length;
  18200. while (length--) {
  18201. if (iteratee(array[length], length, array) === false) {
  18202. break;
  18203. }
  18204. }
  18205. return array;
  18206. }
  18207. /**
  18208. * A specialized version of `_.every` for arrays without support for
  18209. * iteratee shorthands.
  18210. *
  18211. * @private
  18212. * @param {Array} [array] The array to iterate over.
  18213. * @param {Function} predicate The function invoked per iteration.
  18214. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  18215. * else `false`.
  18216. */
  18217. function arrayEvery(array, predicate) {
  18218. var index = -1,
  18219. length = array == null ? 0 : array.length;
  18220. while (++index < length) {
  18221. if (!predicate(array[index], index, array)) {
  18222. return false;
  18223. }
  18224. }
  18225. return true;
  18226. }
  18227. /**
  18228. * A specialized version of `_.filter` for arrays without support for
  18229. * iteratee shorthands.
  18230. *
  18231. * @private
  18232. * @param {Array} [array] The array to iterate over.
  18233. * @param {Function} predicate The function invoked per iteration.
  18234. * @returns {Array} Returns the new filtered array.
  18235. */
  18236. function arrayFilter(array, predicate) {
  18237. var index = -1,
  18238. length = array == null ? 0 : array.length,
  18239. resIndex = 0,
  18240. result = [];
  18241. while (++index < length) {
  18242. var value = array[index];
  18243. if (predicate(value, index, array)) {
  18244. result[resIndex++] = value;
  18245. }
  18246. }
  18247. return result;
  18248. }
  18249. /**
  18250. * A specialized version of `_.includes` for arrays without support for
  18251. * specifying an index to search from.
  18252. *
  18253. * @private
  18254. * @param {Array} [array] The array to inspect.
  18255. * @param {*} target The value to search for.
  18256. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  18257. */
  18258. function arrayIncludes(array, value) {
  18259. var length = array == null ? 0 : array.length;
  18260. return !!length && baseIndexOf(array, value, 0) > -1;
  18261. }
  18262. /**
  18263. * This function is like `arrayIncludes` except that it accepts a comparator.
  18264. *
  18265. * @private
  18266. * @param {Array} [array] The array to inspect.
  18267. * @param {*} target The value to search for.
  18268. * @param {Function} comparator The comparator invoked per element.
  18269. * @returns {boolean} Returns `true` if `target` is found, else `false`.
  18270. */
  18271. function arrayIncludesWith(array, value, comparator) {
  18272. var index = -1,
  18273. length = array == null ? 0 : array.length;
  18274. while (++index < length) {
  18275. if (comparator(value, array[index])) {
  18276. return true;
  18277. }
  18278. }
  18279. return false;
  18280. }
  18281. /**
  18282. * A specialized version of `_.map` for arrays without support for iteratee
  18283. * shorthands.
  18284. *
  18285. * @private
  18286. * @param {Array} [array] The array to iterate over.
  18287. * @param {Function} iteratee The function invoked per iteration.
  18288. * @returns {Array} Returns the new mapped array.
  18289. */
  18290. function arrayMap(array, iteratee) {
  18291. var index = -1,
  18292. length = array == null ? 0 : array.length,
  18293. result = Array(length);
  18294. while (++index < length) {
  18295. result[index] = iteratee(array[index], index, array);
  18296. }
  18297. return result;
  18298. }
  18299. /**
  18300. * Appends the elements of `values` to `array`.
  18301. *
  18302. * @private
  18303. * @param {Array} array The array to modify.
  18304. * @param {Array} values The values to append.
  18305. * @returns {Array} Returns `array`.
  18306. */
  18307. function arrayPush(array, values) {
  18308. var index = -1,
  18309. length = values.length,
  18310. offset = array.length;
  18311. while (++index < length) {
  18312. array[offset + index] = values[index];
  18313. }
  18314. return array;
  18315. }
  18316. /**
  18317. * A specialized version of `_.reduce` for arrays without support for
  18318. * iteratee shorthands.
  18319. *
  18320. * @private
  18321. * @param {Array} [array] The array to iterate over.
  18322. * @param {Function} iteratee The function invoked per iteration.
  18323. * @param {*} [accumulator] The initial value.
  18324. * @param {boolean} [initAccum] Specify using the first element of `array` as
  18325. * the initial value.
  18326. * @returns {*} Returns the accumulated value.
  18327. */
  18328. function arrayReduce(array, iteratee, accumulator, initAccum) {
  18329. var index = -1,
  18330. length = array == null ? 0 : array.length;
  18331. if (initAccum && length) {
  18332. accumulator = array[++index];
  18333. }
  18334. while (++index < length) {
  18335. accumulator = iteratee(accumulator, array[index], index, array);
  18336. }
  18337. return accumulator;
  18338. }
  18339. /**
  18340. * A specialized version of `_.reduceRight` for arrays without support for
  18341. * iteratee shorthands.
  18342. *
  18343. * @private
  18344. * @param {Array} [array] The array to iterate over.
  18345. * @param {Function} iteratee The function invoked per iteration.
  18346. * @param {*} [accumulator] The initial value.
  18347. * @param {boolean} [initAccum] Specify using the last element of `array` as
  18348. * the initial value.
  18349. * @returns {*} Returns the accumulated value.
  18350. */
  18351. function arrayReduceRight(array, iteratee, accumulator, initAccum) {
  18352. var length = array == null ? 0 : array.length;
  18353. if (initAccum && length) {
  18354. accumulator = array[--length];
  18355. }
  18356. while (length--) {
  18357. accumulator = iteratee(accumulator, array[length], length, array);
  18358. }
  18359. return accumulator;
  18360. }
  18361. /**
  18362. * A specialized version of `_.some` for arrays without support for iteratee
  18363. * shorthands.
  18364. *
  18365. * @private
  18366. * @param {Array} [array] The array to iterate over.
  18367. * @param {Function} predicate The function invoked per iteration.
  18368. * @returns {boolean} Returns `true` if any element passes the predicate check,
  18369. * else `false`.
  18370. */
  18371. function arraySome(array, predicate) {
  18372. var index = -1,
  18373. length = array == null ? 0 : array.length;
  18374. while (++index < length) {
  18375. if (predicate(array[index], index, array)) {
  18376. return true;
  18377. }
  18378. }
  18379. return false;
  18380. }
  18381. /**
  18382. * Gets the size of an ASCII `string`.
  18383. *
  18384. * @private
  18385. * @param {string} string The string inspect.
  18386. * @returns {number} Returns the string size.
  18387. */
  18388. var asciiSize = baseProperty('length');
  18389. /**
  18390. * Converts an ASCII `string` to an array.
  18391. *
  18392. * @private
  18393. * @param {string} string The string to convert.
  18394. * @returns {Array} Returns the converted array.
  18395. */
  18396. function asciiToArray(string) {
  18397. return string.split('');
  18398. }
  18399. /**
  18400. * Splits an ASCII `string` into an array of its words.
  18401. *
  18402. * @private
  18403. * @param {string} The string to inspect.
  18404. * @returns {Array} Returns the words of `string`.
  18405. */
  18406. function asciiWords(string) {
  18407. return string.match(reAsciiWord) || [];
  18408. }
  18409. /**
  18410. * The base implementation of methods like `_.findKey` and `_.findLastKey`,
  18411. * without support for iteratee shorthands, which iterates over `collection`
  18412. * using `eachFunc`.
  18413. *
  18414. * @private
  18415. * @param {Array|Object} collection The collection to inspect.
  18416. * @param {Function} predicate The function invoked per iteration.
  18417. * @param {Function} eachFunc The function to iterate over `collection`.
  18418. * @returns {*} Returns the found element or its key, else `undefined`.
  18419. */
  18420. function baseFindKey(collection, predicate, eachFunc) {
  18421. var result;
  18422. eachFunc(collection, function(value, key, collection) {
  18423. if (predicate(value, key, collection)) {
  18424. result = key;
  18425. return false;
  18426. }
  18427. });
  18428. return result;
  18429. }
  18430. /**
  18431. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  18432. * support for iteratee shorthands.
  18433. *
  18434. * @private
  18435. * @param {Array} array The array to inspect.
  18436. * @param {Function} predicate The function invoked per iteration.
  18437. * @param {number} fromIndex The index to search from.
  18438. * @param {boolean} [fromRight] Specify iterating from right to left.
  18439. * @returns {number} Returns the index of the matched value, else `-1`.
  18440. */
  18441. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  18442. var length = array.length,
  18443. index = fromIndex + (fromRight ? 1 : -1);
  18444. while ((fromRight ? index-- : ++index < length)) {
  18445. if (predicate(array[index], index, array)) {
  18446. return index;
  18447. }
  18448. }
  18449. return -1;
  18450. }
  18451. /**
  18452. * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
  18453. *
  18454. * @private
  18455. * @param {Array} array The array to inspect.
  18456. * @param {*} value The value to search for.
  18457. * @param {number} fromIndex The index to search from.
  18458. * @returns {number} Returns the index of the matched value, else `-1`.
  18459. */
  18460. function baseIndexOf(array, value, fromIndex) {
  18461. return value === value
  18462. ? strictIndexOf(array, value, fromIndex)
  18463. : baseFindIndex(array, baseIsNaN, fromIndex);
  18464. }
  18465. /**
  18466. * This function is like `baseIndexOf` except that it accepts a comparator.
  18467. *
  18468. * @private
  18469. * @param {Array} array The array to inspect.
  18470. * @param {*} value The value to search for.
  18471. * @param {number} fromIndex The index to search from.
  18472. * @param {Function} comparator The comparator invoked per element.
  18473. * @returns {number} Returns the index of the matched value, else `-1`.
  18474. */
  18475. function baseIndexOfWith(array, value, fromIndex, comparator) {
  18476. var index = fromIndex - 1,
  18477. length = array.length;
  18478. while (++index < length) {
  18479. if (comparator(array[index], value)) {
  18480. return index;
  18481. }
  18482. }
  18483. return -1;
  18484. }
  18485. /**
  18486. * The base implementation of `_.isNaN` without support for number objects.
  18487. *
  18488. * @private
  18489. * @param {*} value The value to check.
  18490. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  18491. */
  18492. function baseIsNaN(value) {
  18493. return value !== value;
  18494. }
  18495. /**
  18496. * The base implementation of `_.mean` and `_.meanBy` without support for
  18497. * iteratee shorthands.
  18498. *
  18499. * @private
  18500. * @param {Array} array The array to iterate over.
  18501. * @param {Function} iteratee The function invoked per iteration.
  18502. * @returns {number} Returns the mean.
  18503. */
  18504. function baseMean(array, iteratee) {
  18505. var length = array == null ? 0 : array.length;
  18506. return length ? (baseSum(array, iteratee) / length) : NAN;
  18507. }
  18508. /**
  18509. * The base implementation of `_.property` without support for deep paths.
  18510. *
  18511. * @private
  18512. * @param {string} key The key of the property to get.
  18513. * @returns {Function} Returns the new accessor function.
  18514. */
  18515. function baseProperty(key) {
  18516. return function(object) {
  18517. return object == null ? undefined : object[key];
  18518. };
  18519. }
  18520. /**
  18521. * The base implementation of `_.propertyOf` without support for deep paths.
  18522. *
  18523. * @private
  18524. * @param {Object} object The object to query.
  18525. * @returns {Function} Returns the new accessor function.
  18526. */
  18527. function basePropertyOf(object) {
  18528. return function(key) {
  18529. return object == null ? undefined : object[key];
  18530. };
  18531. }
  18532. /**
  18533. * The base implementation of `_.reduce` and `_.reduceRight`, without support
  18534. * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
  18535. *
  18536. * @private
  18537. * @param {Array|Object} collection The collection to iterate over.
  18538. * @param {Function} iteratee The function invoked per iteration.
  18539. * @param {*} accumulator The initial value.
  18540. * @param {boolean} initAccum Specify using the first or last element of
  18541. * `collection` as the initial value.
  18542. * @param {Function} eachFunc The function to iterate over `collection`.
  18543. * @returns {*} Returns the accumulated value.
  18544. */
  18545. function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
  18546. eachFunc(collection, function(value, index, collection) {
  18547. accumulator = initAccum
  18548. ? (initAccum = false, value)
  18549. : iteratee(accumulator, value, index, collection);
  18550. });
  18551. return accumulator;
  18552. }
  18553. /**
  18554. * The base implementation of `_.sortBy` which uses `comparer` to define the
  18555. * sort order of `array` and replaces criteria objects with their corresponding
  18556. * values.
  18557. *
  18558. * @private
  18559. * @param {Array} array The array to sort.
  18560. * @param {Function} comparer The function to define sort order.
  18561. * @returns {Array} Returns `array`.
  18562. */
  18563. function baseSortBy(array, comparer) {
  18564. var length = array.length;
  18565. array.sort(comparer);
  18566. while (length--) {
  18567. array[length] = array[length].value;
  18568. }
  18569. return array;
  18570. }
  18571. /**
  18572. * The base implementation of `_.sum` and `_.sumBy` without support for
  18573. * iteratee shorthands.
  18574. *
  18575. * @private
  18576. * @param {Array} array The array to iterate over.
  18577. * @param {Function} iteratee The function invoked per iteration.
  18578. * @returns {number} Returns the sum.
  18579. */
  18580. function baseSum(array, iteratee) {
  18581. var result,
  18582. index = -1,
  18583. length = array.length;
  18584. while (++index < length) {
  18585. var current = iteratee(array[index]);
  18586. if (current !== undefined) {
  18587. result = result === undefined ? current : (result + current);
  18588. }
  18589. }
  18590. return result;
  18591. }
  18592. /**
  18593. * The base implementation of `_.times` without support for iteratee shorthands
  18594. * or max array length checks.
  18595. *
  18596. * @private
  18597. * @param {number} n The number of times to invoke `iteratee`.
  18598. * @param {Function} iteratee The function invoked per iteration.
  18599. * @returns {Array} Returns the array of results.
  18600. */
  18601. function baseTimes(n, iteratee) {
  18602. var index = -1,
  18603. result = Array(n);
  18604. while (++index < n) {
  18605. result[index] = iteratee(index);
  18606. }
  18607. return result;
  18608. }
  18609. /**
  18610. * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array
  18611. * of key-value pairs for `object` corresponding to the property names of `props`.
  18612. *
  18613. * @private
  18614. * @param {Object} object The object to query.
  18615. * @param {Array} props The property names to get values for.
  18616. * @returns {Object} Returns the key-value pairs.
  18617. */
  18618. function baseToPairs(object, props) {
  18619. return arrayMap(props, function(key) {
  18620. return [key, object[key]];
  18621. });
  18622. }
  18623. /**
  18624. * The base implementation of `_.unary` without support for storing metadata.
  18625. *
  18626. * @private
  18627. * @param {Function} func The function to cap arguments for.
  18628. * @returns {Function} Returns the new capped function.
  18629. */
  18630. function baseUnary(func) {
  18631. return function(value) {
  18632. return func(value);
  18633. };
  18634. }
  18635. /**
  18636. * The base implementation of `_.values` and `_.valuesIn` which creates an
  18637. * array of `object` property values corresponding to the property names
  18638. * of `props`.
  18639. *
  18640. * @private
  18641. * @param {Object} object The object to query.
  18642. * @param {Array} props The property names to get values for.
  18643. * @returns {Object} Returns the array of property values.
  18644. */
  18645. function baseValues(object, props) {
  18646. return arrayMap(props, function(key) {
  18647. return object[key];
  18648. });
  18649. }
  18650. /**
  18651. * Checks if a `cache` value for `key` exists.
  18652. *
  18653. * @private
  18654. * @param {Object} cache The cache to query.
  18655. * @param {string} key The key of the entry to check.
  18656. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  18657. */
  18658. function cacheHas(cache, key) {
  18659. return cache.has(key);
  18660. }
  18661. /**
  18662. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  18663. * that is not found in the character symbols.
  18664. *
  18665. * @private
  18666. * @param {Array} strSymbols The string symbols to inspect.
  18667. * @param {Array} chrSymbols The character symbols to find.
  18668. * @returns {number} Returns the index of the first unmatched string symbol.
  18669. */
  18670. function charsStartIndex(strSymbols, chrSymbols) {
  18671. var index = -1,
  18672. length = strSymbols.length;
  18673. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  18674. return index;
  18675. }
  18676. /**
  18677. * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
  18678. * that is not found in the character symbols.
  18679. *
  18680. * @private
  18681. * @param {Array} strSymbols The string symbols to inspect.
  18682. * @param {Array} chrSymbols The character symbols to find.
  18683. * @returns {number} Returns the index of the last unmatched string symbol.
  18684. */
  18685. function charsEndIndex(strSymbols, chrSymbols) {
  18686. var index = strSymbols.length;
  18687. while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  18688. return index;
  18689. }
  18690. /**
  18691. * Gets the number of `placeholder` occurrences in `array`.
  18692. *
  18693. * @private
  18694. * @param {Array} array The array to inspect.
  18695. * @param {*} placeholder The placeholder to search for.
  18696. * @returns {number} Returns the placeholder count.
  18697. */
  18698. function countHolders(array, placeholder) {
  18699. var length = array.length,
  18700. result = 0;
  18701. while (length--) {
  18702. if (array[length] === placeholder) {
  18703. ++result;
  18704. }
  18705. }
  18706. return result;
  18707. }
  18708. /**
  18709. * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
  18710. * letters to basic Latin letters.
  18711. *
  18712. * @private
  18713. * @param {string} letter The matched letter to deburr.
  18714. * @returns {string} Returns the deburred letter.
  18715. */
  18716. var deburrLetter = basePropertyOf(deburredLetters);
  18717. /**
  18718. * Used by `_.escape` to convert characters to HTML entities.
  18719. *
  18720. * @private
  18721. * @param {string} chr The matched character to escape.
  18722. * @returns {string} Returns the escaped character.
  18723. */
  18724. var escapeHtmlChar = basePropertyOf(htmlEscapes);
  18725. /**
  18726. * Used by `_.template` to escape characters for inclusion in compiled string literals.
  18727. *
  18728. * @private
  18729. * @param {string} chr The matched character to escape.
  18730. * @returns {string} Returns the escaped character.
  18731. */
  18732. function escapeStringChar(chr) {
  18733. return '\\' + stringEscapes[chr];
  18734. }
  18735. /**
  18736. * Gets the value at `key` of `object`.
  18737. *
  18738. * @private
  18739. * @param {Object} [object] The object to query.
  18740. * @param {string} key The key of the property to get.
  18741. * @returns {*} Returns the property value.
  18742. */
  18743. function getValue(object, key) {
  18744. return object == null ? undefined : object[key];
  18745. }
  18746. /**
  18747. * Checks if `string` contains Unicode symbols.
  18748. *
  18749. * @private
  18750. * @param {string} string The string to inspect.
  18751. * @returns {boolean} Returns `true` if a symbol is found, else `false`.
  18752. */
  18753. function hasUnicode(string) {
  18754. return reHasUnicode.test(string);
  18755. }
  18756. /**
  18757. * Checks if `string` contains a word composed of Unicode symbols.
  18758. *
  18759. * @private
  18760. * @param {string} string The string to inspect.
  18761. * @returns {boolean} Returns `true` if a word is found, else `false`.
  18762. */
  18763. function hasUnicodeWord(string) {
  18764. return reHasUnicodeWord.test(string);
  18765. }
  18766. /**
  18767. * Converts `iterator` to an array.
  18768. *
  18769. * @private
  18770. * @param {Object} iterator The iterator to convert.
  18771. * @returns {Array} Returns the converted array.
  18772. */
  18773. function iteratorToArray(iterator) {
  18774. var data,
  18775. result = [];
  18776. while (!(data = iterator.next()).done) {
  18777. result.push(data.value);
  18778. }
  18779. return result;
  18780. }
  18781. /**
  18782. * Converts `map` to its key-value pairs.
  18783. *
  18784. * @private
  18785. * @param {Object} map The map to convert.
  18786. * @returns {Array} Returns the key-value pairs.
  18787. */
  18788. function mapToArray(map) {
  18789. var index = -1,
  18790. result = Array(map.size);
  18791. map.forEach(function(value, key) {
  18792. result[++index] = [key, value];
  18793. });
  18794. return result;
  18795. }
  18796. /**
  18797. * Creates a unary function that invokes `func` with its argument transformed.
  18798. *
  18799. * @private
  18800. * @param {Function} func The function to wrap.
  18801. * @param {Function} transform The argument transform.
  18802. * @returns {Function} Returns the new function.
  18803. */
  18804. function overArg(func, transform) {
  18805. return function(arg) {
  18806. return func(transform(arg));
  18807. };
  18808. }
  18809. /**
  18810. * Replaces all `placeholder` elements in `array` with an internal placeholder
  18811. * and returns an array of their indexes.
  18812. *
  18813. * @private
  18814. * @param {Array} array The array to modify.
  18815. * @param {*} placeholder The placeholder to replace.
  18816. * @returns {Array} Returns the new array of placeholder indexes.
  18817. */
  18818. function replaceHolders(array, placeholder) {
  18819. var index = -1,
  18820. length = array.length,
  18821. resIndex = 0,
  18822. result = [];
  18823. while (++index < length) {
  18824. var value = array[index];
  18825. if (value === placeholder || value === PLACEHOLDER) {
  18826. array[index] = PLACEHOLDER;
  18827. result[resIndex++] = index;
  18828. }
  18829. }
  18830. return result;
  18831. }
  18832. /**
  18833. * Converts `set` to an array of its values.
  18834. *
  18835. * @private
  18836. * @param {Object} set The set to convert.
  18837. * @returns {Array} Returns the values.
  18838. */
  18839. function setToArray(set) {
  18840. var index = -1,
  18841. result = Array(set.size);
  18842. set.forEach(function(value) {
  18843. result[++index] = value;
  18844. });
  18845. return result;
  18846. }
  18847. /**
  18848. * Converts `set` to its value-value pairs.
  18849. *
  18850. * @private
  18851. * @param {Object} set The set to convert.
  18852. * @returns {Array} Returns the value-value pairs.
  18853. */
  18854. function setToPairs(set) {
  18855. var index = -1,
  18856. result = Array(set.size);
  18857. set.forEach(function(value) {
  18858. result[++index] = [value, value];
  18859. });
  18860. return result;
  18861. }
  18862. /**
  18863. * A specialized version of `_.indexOf` which performs strict equality
  18864. * comparisons of values, i.e. `===`.
  18865. *
  18866. * @private
  18867. * @param {Array} array The array to inspect.
  18868. * @param {*} value The value to search for.
  18869. * @param {number} fromIndex The index to search from.
  18870. * @returns {number} Returns the index of the matched value, else `-1`.
  18871. */
  18872. function strictIndexOf(array, value, fromIndex) {
  18873. var index = fromIndex - 1,
  18874. length = array.length;
  18875. while (++index < length) {
  18876. if (array[index] === value) {
  18877. return index;
  18878. }
  18879. }
  18880. return -1;
  18881. }
  18882. /**
  18883. * A specialized version of `_.lastIndexOf` which performs strict equality
  18884. * comparisons of values, i.e. `===`.
  18885. *
  18886. * @private
  18887. * @param {Array} array The array to inspect.
  18888. * @param {*} value The value to search for.
  18889. * @param {number} fromIndex The index to search from.
  18890. * @returns {number} Returns the index of the matched value, else `-1`.
  18891. */
  18892. function strictLastIndexOf(array, value, fromIndex) {
  18893. var index = fromIndex + 1;
  18894. while (index--) {
  18895. if (array[index] === value) {
  18896. return index;
  18897. }
  18898. }
  18899. return index;
  18900. }
  18901. /**
  18902. * Gets the number of symbols in `string`.
  18903. *
  18904. * @private
  18905. * @param {string} string The string to inspect.
  18906. * @returns {number} Returns the string size.
  18907. */
  18908. function stringSize(string) {
  18909. return hasUnicode(string)
  18910. ? unicodeSize(string)
  18911. : asciiSize(string);
  18912. }
  18913. /**
  18914. * Converts `string` to an array.
  18915. *
  18916. * @private
  18917. * @param {string} string The string to convert.
  18918. * @returns {Array} Returns the converted array.
  18919. */
  18920. function stringToArray(string) {
  18921. return hasUnicode(string)
  18922. ? unicodeToArray(string)
  18923. : asciiToArray(string);
  18924. }
  18925. /**
  18926. * Used by `_.unescape` to convert HTML entities to characters.
  18927. *
  18928. * @private
  18929. * @param {string} chr The matched character to unescape.
  18930. * @returns {string} Returns the unescaped character.
  18931. */
  18932. var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
  18933. /**
  18934. * Gets the size of a Unicode `string`.
  18935. *
  18936. * @private
  18937. * @param {string} string The string inspect.
  18938. * @returns {number} Returns the string size.
  18939. */
  18940. function unicodeSize(string) {
  18941. var result = reUnicode.lastIndex = 0;
  18942. while (reUnicode.test(string)) {
  18943. ++result;
  18944. }
  18945. return result;
  18946. }
  18947. /**
  18948. * Converts a Unicode `string` to an array.
  18949. *
  18950. * @private
  18951. * @param {string} string The string to convert.
  18952. * @returns {Array} Returns the converted array.
  18953. */
  18954. function unicodeToArray(string) {
  18955. return string.match(reUnicode) || [];
  18956. }
  18957. /**
  18958. * Splits a Unicode `string` into an array of its words.
  18959. *
  18960. * @private
  18961. * @param {string} The string to inspect.
  18962. * @returns {Array} Returns the words of `string`.
  18963. */
  18964. function unicodeWords(string) {
  18965. return string.match(reUnicodeWord) || [];
  18966. }
  18967. /*--------------------------------------------------------------------------*/
  18968. /**
  18969. * Create a new pristine `lodash` function using the `context` object.
  18970. *
  18971. * @static
  18972. * @memberOf _
  18973. * @since 1.1.0
  18974. * @category Util
  18975. * @param {Object} [context=root] The context object.
  18976. * @returns {Function} Returns a new `lodash` function.
  18977. * @example
  18978. *
  18979. * _.mixin({ 'foo': _.constant('foo') });
  18980. *
  18981. * var lodash = _.runInContext();
  18982. * lodash.mixin({ 'bar': lodash.constant('bar') });
  18983. *
  18984. * _.isFunction(_.foo);
  18985. * // => true
  18986. * _.isFunction(_.bar);
  18987. * // => false
  18988. *
  18989. * lodash.isFunction(lodash.foo);
  18990. * // => false
  18991. * lodash.isFunction(lodash.bar);
  18992. * // => true
  18993. *
  18994. * // Create a suped-up `defer` in Node.js.
  18995. * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
  18996. */
  18997. var runInContext = (function runInContext(context) {
  18998. context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
  18999. /** Built-in constructor references. */
  19000. var Array = context.Array,
  19001. Date = context.Date,
  19002. Error = context.Error,
  19003. Function = context.Function,
  19004. Math = context.Math,
  19005. Object = context.Object,
  19006. RegExp = context.RegExp,
  19007. String = context.String,
  19008. TypeError = context.TypeError;
  19009. /** Used for built-in method references. */
  19010. var arrayProto = Array.prototype,
  19011. funcProto = Function.prototype,
  19012. objectProto = Object.prototype;
  19013. /** Used to detect overreaching core-js shims. */
  19014. var coreJsData = context['__core-js_shared__'];
  19015. /** Used to resolve the decompiled source of functions. */
  19016. var funcToString = funcProto.toString;
  19017. /** Used to check objects for own properties. */
  19018. var hasOwnProperty = objectProto.hasOwnProperty;
  19019. /** Used to generate unique IDs. */
  19020. var idCounter = 0;
  19021. /** Used to detect methods masquerading as native. */
  19022. var maskSrcKey = (function() {
  19023. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  19024. return uid ? ('Symbol(src)_1.' + uid) : '';
  19025. }());
  19026. /**
  19027. * Used to resolve the
  19028. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  19029. * of values.
  19030. */
  19031. var nativeObjectToString = objectProto.toString;
  19032. /** Used to infer the `Object` constructor. */
  19033. var objectCtorString = funcToString.call(Object);
  19034. /** Used to restore the original `_` reference in `_.noConflict`. */
  19035. var oldDash = root._;
  19036. /** Used to detect if a method is native. */
  19037. var reIsNative = RegExp('^' +
  19038. funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
  19039. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  19040. );
  19041. /** Built-in value references. */
  19042. var Buffer = moduleExports ? context.Buffer : undefined,
  19043. Symbol = context.Symbol,
  19044. Uint8Array = context.Uint8Array,
  19045. allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
  19046. getPrototype = overArg(Object.getPrototypeOf, Object),
  19047. objectCreate = Object.create,
  19048. propertyIsEnumerable = objectProto.propertyIsEnumerable,
  19049. splice = arrayProto.splice,
  19050. spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
  19051. symIterator = Symbol ? Symbol.iterator : undefined,
  19052. symToStringTag = Symbol ? Symbol.toStringTag : undefined;
  19053. var defineProperty = (function() {
  19054. try {
  19055. var func = getNative(Object, 'defineProperty');
  19056. func({}, '', {});
  19057. return func;
  19058. } catch (e) {}
  19059. }());
  19060. /** Mocked built-ins. */
  19061. var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
  19062. ctxNow = Date && Date.now !== root.Date.now && Date.now,
  19063. ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
  19064. /* Built-in method references for those with the same name as other `lodash` methods. */
  19065. var nativeCeil = Math.ceil,
  19066. nativeFloor = Math.floor,
  19067. nativeGetSymbols = Object.getOwnPropertySymbols,
  19068. nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
  19069. nativeIsFinite = context.isFinite,
  19070. nativeJoin = arrayProto.join,
  19071. nativeKeys = overArg(Object.keys, Object),
  19072. nativeMax = Math.max,
  19073. nativeMin = Math.min,
  19074. nativeNow = Date.now,
  19075. nativeParseInt = context.parseInt,
  19076. nativeRandom = Math.random,
  19077. nativeReverse = arrayProto.reverse;
  19078. /* Built-in method references that are verified to be native. */
  19079. var DataView = getNative(context, 'DataView'),
  19080. Map = getNative(context, 'Map'),
  19081. Promise = getNative(context, 'Promise'),
  19082. Set = getNative(context, 'Set'),
  19083. WeakMap = getNative(context, 'WeakMap'),
  19084. nativeCreate = getNative(Object, 'create');
  19085. /** Used to store function metadata. */
  19086. var metaMap = WeakMap && new WeakMap;
  19087. /** Used to lookup unminified function names. */
  19088. var realNames = {};
  19089. /** Used to detect maps, sets, and weakmaps. */
  19090. var dataViewCtorString = toSource(DataView),
  19091. mapCtorString = toSource(Map),
  19092. promiseCtorString = toSource(Promise),
  19093. setCtorString = toSource(Set),
  19094. weakMapCtorString = toSource(WeakMap);
  19095. /** Used to convert symbols to primitives and strings. */
  19096. var symbolProto = Symbol ? Symbol.prototype : undefined,
  19097. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined,
  19098. symbolToString = symbolProto ? symbolProto.toString : undefined;
  19099. /*------------------------------------------------------------------------*/
  19100. /**
  19101. * Creates a `lodash` object which wraps `value` to enable implicit method
  19102. * chain sequences. Methods that operate on and return arrays, collections,
  19103. * and functions can be chained together. Methods that retrieve a single value
  19104. * or may return a primitive value will automatically end the chain sequence
  19105. * and return the unwrapped value. Otherwise, the value must be unwrapped
  19106. * with `_#value`.
  19107. *
  19108. * Explicit chain sequences, which must be unwrapped with `_#value`, may be
  19109. * enabled using `_.chain`.
  19110. *
  19111. * The execution of chained methods is lazy, that is, it's deferred until
  19112. * `_#value` is implicitly or explicitly called.
  19113. *
  19114. * Lazy evaluation allows several methods to support shortcut fusion.
  19115. * Shortcut fusion is an optimization to merge iteratee calls; this avoids
  19116. * the creation of intermediate arrays and can greatly reduce the number of
  19117. * iteratee executions. Sections of a chain sequence qualify for shortcut
  19118. * fusion if the section is applied to an array and iteratees accept only
  19119. * one argument. The heuristic for whether a section qualifies for shortcut
  19120. * fusion is subject to change.
  19121. *
  19122. * Chaining is supported in custom builds as long as the `_#value` method is
  19123. * directly or indirectly included in the build.
  19124. *
  19125. * In addition to lodash methods, wrappers have `Array` and `String` methods.
  19126. *
  19127. * The wrapper `Array` methods are:
  19128. * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
  19129. *
  19130. * The wrapper `String` methods are:
  19131. * `replace` and `split`
  19132. *
  19133. * The wrapper methods that support shortcut fusion are:
  19134. * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
  19135. * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
  19136. * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
  19137. *
  19138. * The chainable wrapper methods are:
  19139. * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
  19140. * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
  19141. * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
  19142. * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
  19143. * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
  19144. * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
  19145. * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
  19146. * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
  19147. * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
  19148. * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
  19149. * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
  19150. * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
  19151. * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
  19152. * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
  19153. * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
  19154. * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
  19155. * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
  19156. * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
  19157. * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
  19158. * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
  19159. * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
  19160. * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
  19161. * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
  19162. * `zipObject`, `zipObjectDeep`, and `zipWith`
  19163. *
  19164. * The wrapper methods that are **not** chainable by default are:
  19165. * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
  19166. * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
  19167. * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
  19168. * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
  19169. * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
  19170. * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
  19171. * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
  19172. * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
  19173. * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
  19174. * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
  19175. * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
  19176. * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
  19177. * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
  19178. * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
  19179. * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
  19180. * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
  19181. * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
  19182. * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
  19183. * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
  19184. * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
  19185. * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
  19186. * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
  19187. * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
  19188. * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
  19189. * `upperFirst`, `value`, and `words`
  19190. *
  19191. * @name _
  19192. * @constructor
  19193. * @category Seq
  19194. * @param {*} value The value to wrap in a `lodash` instance.
  19195. * @returns {Object} Returns the new `lodash` wrapper instance.
  19196. * @example
  19197. *
  19198. * function square(n) {
  19199. * return n * n;
  19200. * }
  19201. *
  19202. * var wrapped = _([1, 2, 3]);
  19203. *
  19204. * // Returns an unwrapped value.
  19205. * wrapped.reduce(_.add);
  19206. * // => 6
  19207. *
  19208. * // Returns a wrapped value.
  19209. * var squares = wrapped.map(square);
  19210. *
  19211. * _.isArray(squares);
  19212. * // => false
  19213. *
  19214. * _.isArray(squares.value());
  19215. * // => true
  19216. */
  19217. function lodash(value) {
  19218. if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
  19219. if (value instanceof LodashWrapper) {
  19220. return value;
  19221. }
  19222. if (hasOwnProperty.call(value, '__wrapped__')) {
  19223. return wrapperClone(value);
  19224. }
  19225. }
  19226. return new LodashWrapper(value);
  19227. }
  19228. /**
  19229. * The base implementation of `_.create` without support for assigning
  19230. * properties to the created object.
  19231. *
  19232. * @private
  19233. * @param {Object} proto The object to inherit from.
  19234. * @returns {Object} Returns the new object.
  19235. */
  19236. var baseCreate = (function() {
  19237. function object() {}
  19238. return function(proto) {
  19239. if (!isObject(proto)) {
  19240. return {};
  19241. }
  19242. if (objectCreate) {
  19243. return objectCreate(proto);
  19244. }
  19245. object.prototype = proto;
  19246. var result = new object;
  19247. object.prototype = undefined;
  19248. return result;
  19249. };
  19250. }());
  19251. /**
  19252. * The function whose prototype chain sequence wrappers inherit from.
  19253. *
  19254. * @private
  19255. */
  19256. function baseLodash() {
  19257. // No operation performed.
  19258. }
  19259. /**
  19260. * The base constructor for creating `lodash` wrapper objects.
  19261. *
  19262. * @private
  19263. * @param {*} value The value to wrap.
  19264. * @param {boolean} [chainAll] Enable explicit method chain sequences.
  19265. */
  19266. function LodashWrapper(value, chainAll) {
  19267. this.__wrapped__ = value;
  19268. this.__actions__ = [];
  19269. this.__chain__ = !!chainAll;
  19270. this.__index__ = 0;
  19271. this.__values__ = undefined;
  19272. }
  19273. /**
  19274. * By default, the template delimiters used by lodash are like those in
  19275. * embedded Ruby (ERB) as well as ES2015 template strings. Change the
  19276. * following template settings to use alternative delimiters.
  19277. *
  19278. * @static
  19279. * @memberOf _
  19280. * @type {Object}
  19281. */
  19282. lodash.templateSettings = {
  19283. /**
  19284. * Used to detect `data` property values to be HTML-escaped.
  19285. *
  19286. * @memberOf _.templateSettings
  19287. * @type {RegExp}
  19288. */
  19289. 'escape': reEscape,
  19290. /**
  19291. * Used to detect code to be evaluated.
  19292. *
  19293. * @memberOf _.templateSettings
  19294. * @type {RegExp}
  19295. */
  19296. 'evaluate': reEvaluate,
  19297. /**
  19298. * Used to detect `data` property values to inject.
  19299. *
  19300. * @memberOf _.templateSettings
  19301. * @type {RegExp}
  19302. */
  19303. 'interpolate': reInterpolate,
  19304. /**
  19305. * Used to reference the data object in the template text.
  19306. *
  19307. * @memberOf _.templateSettings
  19308. * @type {string}
  19309. */
  19310. 'variable': '',
  19311. /**
  19312. * Used to import variables into the compiled template.
  19313. *
  19314. * @memberOf _.templateSettings
  19315. * @type {Object}
  19316. */
  19317. 'imports': {
  19318. /**
  19319. * A reference to the `lodash` function.
  19320. *
  19321. * @memberOf _.templateSettings.imports
  19322. * @type {Function}
  19323. */
  19324. '_': lodash
  19325. }
  19326. };
  19327. // Ensure wrappers are instances of `baseLodash`.
  19328. lodash.prototype = baseLodash.prototype;
  19329. lodash.prototype.constructor = lodash;
  19330. LodashWrapper.prototype = baseCreate(baseLodash.prototype);
  19331. LodashWrapper.prototype.constructor = LodashWrapper;
  19332. /*------------------------------------------------------------------------*/
  19333. /**
  19334. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
  19335. *
  19336. * @private
  19337. * @constructor
  19338. * @param {*} value The value to wrap.
  19339. */
  19340. function LazyWrapper(value) {
  19341. this.__wrapped__ = value;
  19342. this.__actions__ = [];
  19343. this.__dir__ = 1;
  19344. this.__filtered__ = false;
  19345. this.__iteratees__ = [];
  19346. this.__takeCount__ = MAX_ARRAY_LENGTH;
  19347. this.__views__ = [];
  19348. }
  19349. /**
  19350. * Creates a clone of the lazy wrapper object.
  19351. *
  19352. * @private
  19353. * @name clone
  19354. * @memberOf LazyWrapper
  19355. * @returns {Object} Returns the cloned `LazyWrapper` object.
  19356. */
  19357. function lazyClone() {
  19358. var result = new LazyWrapper(this.__wrapped__);
  19359. result.__actions__ = copyArray(this.__actions__);
  19360. result.__dir__ = this.__dir__;
  19361. result.__filtered__ = this.__filtered__;
  19362. result.__iteratees__ = copyArray(this.__iteratees__);
  19363. result.__takeCount__ = this.__takeCount__;
  19364. result.__views__ = copyArray(this.__views__);
  19365. return result;
  19366. }
  19367. /**
  19368. * Reverses the direction of lazy iteration.
  19369. *
  19370. * @private
  19371. * @name reverse
  19372. * @memberOf LazyWrapper
  19373. * @returns {Object} Returns the new reversed `LazyWrapper` object.
  19374. */
  19375. function lazyReverse() {
  19376. if (this.__filtered__) {
  19377. var result = new LazyWrapper(this);
  19378. result.__dir__ = -1;
  19379. result.__filtered__ = true;
  19380. } else {
  19381. result = this.clone();
  19382. result.__dir__ *= -1;
  19383. }
  19384. return result;
  19385. }
  19386. /**
  19387. * Extracts the unwrapped value from its lazy wrapper.
  19388. *
  19389. * @private
  19390. * @name value
  19391. * @memberOf LazyWrapper
  19392. * @returns {*} Returns the unwrapped value.
  19393. */
  19394. function lazyValue() {
  19395. var array = this.__wrapped__.value(),
  19396. dir = this.__dir__,
  19397. isArr = isArray(array),
  19398. isRight = dir < 0,
  19399. arrLength = isArr ? array.length : 0,
  19400. view = getView(0, arrLength, this.__views__),
  19401. start = view.start,
  19402. end = view.end,
  19403. length = end - start,
  19404. index = isRight ? end : (start - 1),
  19405. iteratees = this.__iteratees__,
  19406. iterLength = iteratees.length,
  19407. resIndex = 0,
  19408. takeCount = nativeMin(length, this.__takeCount__);
  19409. if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
  19410. return baseWrapperValue(array, this.__actions__);
  19411. }
  19412. var result = [];
  19413. outer:
  19414. while (length-- && resIndex < takeCount) {
  19415. index += dir;
  19416. var iterIndex = -1,
  19417. value = array[index];
  19418. while (++iterIndex < iterLength) {
  19419. var data = iteratees[iterIndex],
  19420. iteratee = data.iteratee,
  19421. type = data.type,
  19422. computed = iteratee(value);
  19423. if (type == LAZY_MAP_FLAG) {
  19424. value = computed;
  19425. } else if (!computed) {
  19426. if (type == LAZY_FILTER_FLAG) {
  19427. continue outer;
  19428. } else {
  19429. break outer;
  19430. }
  19431. }
  19432. }
  19433. result[resIndex++] = value;
  19434. }
  19435. return result;
  19436. }
  19437. // Ensure `LazyWrapper` is an instance of `baseLodash`.
  19438. LazyWrapper.prototype = baseCreate(baseLodash.prototype);
  19439. LazyWrapper.prototype.constructor = LazyWrapper;
  19440. /*------------------------------------------------------------------------*/
  19441. /**
  19442. * Creates a hash object.
  19443. *
  19444. * @private
  19445. * @constructor
  19446. * @param {Array} [entries] The key-value pairs to cache.
  19447. */
  19448. function Hash(entries) {
  19449. var index = -1,
  19450. length = entries == null ? 0 : entries.length;
  19451. this.clear();
  19452. while (++index < length) {
  19453. var entry = entries[index];
  19454. this.set(entry[0], entry[1]);
  19455. }
  19456. }
  19457. /**
  19458. * Removes all key-value entries from the hash.
  19459. *
  19460. * @private
  19461. * @name clear
  19462. * @memberOf Hash
  19463. */
  19464. function hashClear() {
  19465. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  19466. this.size = 0;
  19467. }
  19468. /**
  19469. * Removes `key` and its value from the hash.
  19470. *
  19471. * @private
  19472. * @name delete
  19473. * @memberOf Hash
  19474. * @param {Object} hash The hash to modify.
  19475. * @param {string} key The key of the value to remove.
  19476. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19477. */
  19478. function hashDelete(key) {
  19479. var result = this.has(key) && delete this.__data__[key];
  19480. this.size -= result ? 1 : 0;
  19481. return result;
  19482. }
  19483. /**
  19484. * Gets the hash value for `key`.
  19485. *
  19486. * @private
  19487. * @name get
  19488. * @memberOf Hash
  19489. * @param {string} key The key of the value to get.
  19490. * @returns {*} Returns the entry value.
  19491. */
  19492. function hashGet(key) {
  19493. var data = this.__data__;
  19494. if (nativeCreate) {
  19495. var result = data[key];
  19496. return result === HASH_UNDEFINED ? undefined : result;
  19497. }
  19498. return hasOwnProperty.call(data, key) ? data[key] : undefined;
  19499. }
  19500. /**
  19501. * Checks if a hash value for `key` exists.
  19502. *
  19503. * @private
  19504. * @name has
  19505. * @memberOf Hash
  19506. * @param {string} key The key of the entry to check.
  19507. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19508. */
  19509. function hashHas(key) {
  19510. var data = this.__data__;
  19511. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
  19512. }
  19513. /**
  19514. * Sets the hash `key` to `value`.
  19515. *
  19516. * @private
  19517. * @name set
  19518. * @memberOf Hash
  19519. * @param {string} key The key of the value to set.
  19520. * @param {*} value The value to set.
  19521. * @returns {Object} Returns the hash instance.
  19522. */
  19523. function hashSet(key, value) {
  19524. var data = this.__data__;
  19525. this.size += this.has(key) ? 0 : 1;
  19526. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  19527. return this;
  19528. }
  19529. // Add methods to `Hash`.
  19530. Hash.prototype.clear = hashClear;
  19531. Hash.prototype['delete'] = hashDelete;
  19532. Hash.prototype.get = hashGet;
  19533. Hash.prototype.has = hashHas;
  19534. Hash.prototype.set = hashSet;
  19535. /*------------------------------------------------------------------------*/
  19536. /**
  19537. * Creates an list cache object.
  19538. *
  19539. * @private
  19540. * @constructor
  19541. * @param {Array} [entries] The key-value pairs to cache.
  19542. */
  19543. function ListCache(entries) {
  19544. var index = -1,
  19545. length = entries == null ? 0 : entries.length;
  19546. this.clear();
  19547. while (++index < length) {
  19548. var entry = entries[index];
  19549. this.set(entry[0], entry[1]);
  19550. }
  19551. }
  19552. /**
  19553. * Removes all key-value entries from the list cache.
  19554. *
  19555. * @private
  19556. * @name clear
  19557. * @memberOf ListCache
  19558. */
  19559. function listCacheClear() {
  19560. this.__data__ = [];
  19561. this.size = 0;
  19562. }
  19563. /**
  19564. * Removes `key` and its value from the list cache.
  19565. *
  19566. * @private
  19567. * @name delete
  19568. * @memberOf ListCache
  19569. * @param {string} key The key of the value to remove.
  19570. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19571. */
  19572. function listCacheDelete(key) {
  19573. var data = this.__data__,
  19574. index = assocIndexOf(data, key);
  19575. if (index < 0) {
  19576. return false;
  19577. }
  19578. var lastIndex = data.length - 1;
  19579. if (index == lastIndex) {
  19580. data.pop();
  19581. } else {
  19582. splice.call(data, index, 1);
  19583. }
  19584. --this.size;
  19585. return true;
  19586. }
  19587. /**
  19588. * Gets the list cache value for `key`.
  19589. *
  19590. * @private
  19591. * @name get
  19592. * @memberOf ListCache
  19593. * @param {string} key The key of the value to get.
  19594. * @returns {*} Returns the entry value.
  19595. */
  19596. function listCacheGet(key) {
  19597. var data = this.__data__,
  19598. index = assocIndexOf(data, key);
  19599. return index < 0 ? undefined : data[index][1];
  19600. }
  19601. /**
  19602. * Checks if a list cache value for `key` exists.
  19603. *
  19604. * @private
  19605. * @name has
  19606. * @memberOf ListCache
  19607. * @param {string} key The key of the entry to check.
  19608. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19609. */
  19610. function listCacheHas(key) {
  19611. return assocIndexOf(this.__data__, key) > -1;
  19612. }
  19613. /**
  19614. * Sets the list cache `key` to `value`.
  19615. *
  19616. * @private
  19617. * @name set
  19618. * @memberOf ListCache
  19619. * @param {string} key The key of the value to set.
  19620. * @param {*} value The value to set.
  19621. * @returns {Object} Returns the list cache instance.
  19622. */
  19623. function listCacheSet(key, value) {
  19624. var data = this.__data__,
  19625. index = assocIndexOf(data, key);
  19626. if (index < 0) {
  19627. ++this.size;
  19628. data.push([key, value]);
  19629. } else {
  19630. data[index][1] = value;
  19631. }
  19632. return this;
  19633. }
  19634. // Add methods to `ListCache`.
  19635. ListCache.prototype.clear = listCacheClear;
  19636. ListCache.prototype['delete'] = listCacheDelete;
  19637. ListCache.prototype.get = listCacheGet;
  19638. ListCache.prototype.has = listCacheHas;
  19639. ListCache.prototype.set = listCacheSet;
  19640. /*------------------------------------------------------------------------*/
  19641. /**
  19642. * Creates a map cache object to store key-value pairs.
  19643. *
  19644. * @private
  19645. * @constructor
  19646. * @param {Array} [entries] The key-value pairs to cache.
  19647. */
  19648. function MapCache(entries) {
  19649. var index = -1,
  19650. length = entries == null ? 0 : entries.length;
  19651. this.clear();
  19652. while (++index < length) {
  19653. var entry = entries[index];
  19654. this.set(entry[0], entry[1]);
  19655. }
  19656. }
  19657. /**
  19658. * Removes all key-value entries from the map.
  19659. *
  19660. * @private
  19661. * @name clear
  19662. * @memberOf MapCache
  19663. */
  19664. function mapCacheClear() {
  19665. this.size = 0;
  19666. this.__data__ = {
  19667. 'hash': new Hash,
  19668. 'map': new (Map || ListCache),
  19669. 'string': new Hash
  19670. };
  19671. }
  19672. /**
  19673. * Removes `key` and its value from the map.
  19674. *
  19675. * @private
  19676. * @name delete
  19677. * @memberOf MapCache
  19678. * @param {string} key The key of the value to remove.
  19679. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19680. */
  19681. function mapCacheDelete(key) {
  19682. var result = getMapData(this, key)['delete'](key);
  19683. this.size -= result ? 1 : 0;
  19684. return result;
  19685. }
  19686. /**
  19687. * Gets the map value for `key`.
  19688. *
  19689. * @private
  19690. * @name get
  19691. * @memberOf MapCache
  19692. * @param {string} key The key of the value to get.
  19693. * @returns {*} Returns the entry value.
  19694. */
  19695. function mapCacheGet(key) {
  19696. return getMapData(this, key).get(key);
  19697. }
  19698. /**
  19699. * Checks if a map value for `key` exists.
  19700. *
  19701. * @private
  19702. * @name has
  19703. * @memberOf MapCache
  19704. * @param {string} key The key of the entry to check.
  19705. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19706. */
  19707. function mapCacheHas(key) {
  19708. return getMapData(this, key).has(key);
  19709. }
  19710. /**
  19711. * Sets the map `key` to `value`.
  19712. *
  19713. * @private
  19714. * @name set
  19715. * @memberOf MapCache
  19716. * @param {string} key The key of the value to set.
  19717. * @param {*} value The value to set.
  19718. * @returns {Object} Returns the map cache instance.
  19719. */
  19720. function mapCacheSet(key, value) {
  19721. var data = getMapData(this, key),
  19722. size = data.size;
  19723. data.set(key, value);
  19724. this.size += data.size == size ? 0 : 1;
  19725. return this;
  19726. }
  19727. // Add methods to `MapCache`.
  19728. MapCache.prototype.clear = mapCacheClear;
  19729. MapCache.prototype['delete'] = mapCacheDelete;
  19730. MapCache.prototype.get = mapCacheGet;
  19731. MapCache.prototype.has = mapCacheHas;
  19732. MapCache.prototype.set = mapCacheSet;
  19733. /*------------------------------------------------------------------------*/
  19734. /**
  19735. *
  19736. * Creates an array cache object to store unique values.
  19737. *
  19738. * @private
  19739. * @constructor
  19740. * @param {Array} [values] The values to cache.
  19741. */
  19742. function SetCache(values) {
  19743. var index = -1,
  19744. length = values == null ? 0 : values.length;
  19745. this.__data__ = new MapCache;
  19746. while (++index < length) {
  19747. this.add(values[index]);
  19748. }
  19749. }
  19750. /**
  19751. * Adds `value` to the array cache.
  19752. *
  19753. * @private
  19754. * @name add
  19755. * @memberOf SetCache
  19756. * @alias push
  19757. * @param {*} value The value to cache.
  19758. * @returns {Object} Returns the cache instance.
  19759. */
  19760. function setCacheAdd(value) {
  19761. this.__data__.set(value, HASH_UNDEFINED);
  19762. return this;
  19763. }
  19764. /**
  19765. * Checks if `value` is in the array cache.
  19766. *
  19767. * @private
  19768. * @name has
  19769. * @memberOf SetCache
  19770. * @param {*} value The value to search for.
  19771. * @returns {number} Returns `true` if `value` is found, else `false`.
  19772. */
  19773. function setCacheHas(value) {
  19774. return this.__data__.has(value);
  19775. }
  19776. // Add methods to `SetCache`.
  19777. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  19778. SetCache.prototype.has = setCacheHas;
  19779. /*------------------------------------------------------------------------*/
  19780. /**
  19781. * Creates a stack cache object to store key-value pairs.
  19782. *
  19783. * @private
  19784. * @constructor
  19785. * @param {Array} [entries] The key-value pairs to cache.
  19786. */
  19787. function Stack(entries) {
  19788. var data = this.__data__ = new ListCache(entries);
  19789. this.size = data.size;
  19790. }
  19791. /**
  19792. * Removes all key-value entries from the stack.
  19793. *
  19794. * @private
  19795. * @name clear
  19796. * @memberOf Stack
  19797. */
  19798. function stackClear() {
  19799. this.__data__ = new ListCache;
  19800. this.size = 0;
  19801. }
  19802. /**
  19803. * Removes `key` and its value from the stack.
  19804. *
  19805. * @private
  19806. * @name delete
  19807. * @memberOf Stack
  19808. * @param {string} key The key of the value to remove.
  19809. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  19810. */
  19811. function stackDelete(key) {
  19812. var data = this.__data__,
  19813. result = data['delete'](key);
  19814. this.size = data.size;
  19815. return result;
  19816. }
  19817. /**
  19818. * Gets the stack value for `key`.
  19819. *
  19820. * @private
  19821. * @name get
  19822. * @memberOf Stack
  19823. * @param {string} key The key of the value to get.
  19824. * @returns {*} Returns the entry value.
  19825. */
  19826. function stackGet(key) {
  19827. return this.__data__.get(key);
  19828. }
  19829. /**
  19830. * Checks if a stack value for `key` exists.
  19831. *
  19832. * @private
  19833. * @name has
  19834. * @memberOf Stack
  19835. * @param {string} key The key of the entry to check.
  19836. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  19837. */
  19838. function stackHas(key) {
  19839. return this.__data__.has(key);
  19840. }
  19841. /**
  19842. * Sets the stack `key` to `value`.
  19843. *
  19844. * @private
  19845. * @name set
  19846. * @memberOf Stack
  19847. * @param {string} key The key of the value to set.
  19848. * @param {*} value The value to set.
  19849. * @returns {Object} Returns the stack cache instance.
  19850. */
  19851. function stackSet(key, value) {
  19852. var data = this.__data__;
  19853. if (data instanceof ListCache) {
  19854. var pairs = data.__data__;
  19855. if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  19856. pairs.push([key, value]);
  19857. this.size = ++data.size;
  19858. return this;
  19859. }
  19860. data = this.__data__ = new MapCache(pairs);
  19861. }
  19862. data.set(key, value);
  19863. this.size = data.size;
  19864. return this;
  19865. }
  19866. // Add methods to `Stack`.
  19867. Stack.prototype.clear = stackClear;
  19868. Stack.prototype['delete'] = stackDelete;
  19869. Stack.prototype.get = stackGet;
  19870. Stack.prototype.has = stackHas;
  19871. Stack.prototype.set = stackSet;
  19872. /*------------------------------------------------------------------------*/
  19873. /**
  19874. * Creates an array of the enumerable property names of the array-like `value`.
  19875. *
  19876. * @private
  19877. * @param {*} value The value to query.
  19878. * @param {boolean} inherited Specify returning inherited property names.
  19879. * @returns {Array} Returns the array of property names.
  19880. */
  19881. function arrayLikeKeys(value, inherited) {
  19882. var isArr = isArray(value),
  19883. isArg = !isArr && isArguments(value),
  19884. isBuff = !isArr && !isArg && isBuffer(value),
  19885. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  19886. skipIndexes = isArr || isArg || isBuff || isType,
  19887. result = skipIndexes ? baseTimes(value.length, String) : [],
  19888. length = result.length;
  19889. for (var key in value) {
  19890. if ((inherited || hasOwnProperty.call(value, key)) &&
  19891. !(skipIndexes && (
  19892. // Safari 9 has enumerable `arguments.length` in strict mode.
  19893. key == 'length' ||
  19894. // Node.js 0.10 has enumerable non-index properties on buffers.
  19895. (isBuff && (key == 'offset' || key == 'parent')) ||
  19896. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  19897. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  19898. // Skip index properties.
  19899. isIndex(key, length)
  19900. ))) {
  19901. result.push(key);
  19902. }
  19903. }
  19904. return result;
  19905. }
  19906. /**
  19907. * A specialized version of `_.sample` for arrays.
  19908. *
  19909. * @private
  19910. * @param {Array} array The array to sample.
  19911. * @returns {*} Returns the random element.
  19912. */
  19913. function arraySample(array) {
  19914. var length = array.length;
  19915. return length ? array[baseRandom(0, length - 1)] : undefined;
  19916. }
  19917. /**
  19918. * A specialized version of `_.sampleSize` for arrays.
  19919. *
  19920. * @private
  19921. * @param {Array} array The array to sample.
  19922. * @param {number} n The number of elements to sample.
  19923. * @returns {Array} Returns the random elements.
  19924. */
  19925. function arraySampleSize(array, n) {
  19926. return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
  19927. }
  19928. /**
  19929. * A specialized version of `_.shuffle` for arrays.
  19930. *
  19931. * @private
  19932. * @param {Array} array The array to shuffle.
  19933. * @returns {Array} Returns the new shuffled array.
  19934. */
  19935. function arrayShuffle(array) {
  19936. return shuffleSelf(copyArray(array));
  19937. }
  19938. /**
  19939. * This function is like `assignValue` except that it doesn't assign
  19940. * `undefined` values.
  19941. *
  19942. * @private
  19943. * @param {Object} object The object to modify.
  19944. * @param {string} key The key of the property to assign.
  19945. * @param {*} value The value to assign.
  19946. */
  19947. function assignMergeValue(object, key, value) {
  19948. if ((value !== undefined && !eq(object[key], value)) ||
  19949. (value === undefined && !(key in object))) {
  19950. baseAssignValue(object, key, value);
  19951. }
  19952. }
  19953. /**
  19954. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  19955. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  19956. * for equality comparisons.
  19957. *
  19958. * @private
  19959. * @param {Object} object The object to modify.
  19960. * @param {string} key The key of the property to assign.
  19961. * @param {*} value The value to assign.
  19962. */
  19963. function assignValue(object, key, value) {
  19964. var objValue = object[key];
  19965. if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
  19966. (value === undefined && !(key in object))) {
  19967. baseAssignValue(object, key, value);
  19968. }
  19969. }
  19970. /**
  19971. * Gets the index at which the `key` is found in `array` of key-value pairs.
  19972. *
  19973. * @private
  19974. * @param {Array} array The array to inspect.
  19975. * @param {*} key The key to search for.
  19976. * @returns {number} Returns the index of the matched value, else `-1`.
  19977. */
  19978. function assocIndexOf(array, key) {
  19979. var length = array.length;
  19980. while (length--) {
  19981. if (eq(array[length][0], key)) {
  19982. return length;
  19983. }
  19984. }
  19985. return -1;
  19986. }
  19987. /**
  19988. * Aggregates elements of `collection` on `accumulator` with keys transformed
  19989. * by `iteratee` and values set by `setter`.
  19990. *
  19991. * @private
  19992. * @param {Array|Object} collection The collection to iterate over.
  19993. * @param {Function} setter The function to set `accumulator` values.
  19994. * @param {Function} iteratee The iteratee to transform keys.
  19995. * @param {Object} accumulator The initial aggregated object.
  19996. * @returns {Function} Returns `accumulator`.
  19997. */
  19998. function baseAggregator(collection, setter, iteratee, accumulator) {
  19999. baseEach(collection, function(value, key, collection) {
  20000. setter(accumulator, value, iteratee(value), collection);
  20001. });
  20002. return accumulator;
  20003. }
  20004. /**
  20005. * The base implementation of `_.assign` without support for multiple sources
  20006. * or `customizer` functions.
  20007. *
  20008. * @private
  20009. * @param {Object} object The destination object.
  20010. * @param {Object} source The source object.
  20011. * @returns {Object} Returns `object`.
  20012. */
  20013. function baseAssign(object, source) {
  20014. return object && copyObject(source, keys(source), object);
  20015. }
  20016. /**
  20017. * The base implementation of `_.assignIn` without support for multiple sources
  20018. * or `customizer` functions.
  20019. *
  20020. * @private
  20021. * @param {Object} object The destination object.
  20022. * @param {Object} source The source object.
  20023. * @returns {Object} Returns `object`.
  20024. */
  20025. function baseAssignIn(object, source) {
  20026. return object && copyObject(source, keysIn(source), object);
  20027. }
  20028. /**
  20029. * The base implementation of `assignValue` and `assignMergeValue` without
  20030. * value checks.
  20031. *
  20032. * @private
  20033. * @param {Object} object The object to modify.
  20034. * @param {string} key The key of the property to assign.
  20035. * @param {*} value The value to assign.
  20036. */
  20037. function baseAssignValue(object, key, value) {
  20038. if (key == '__proto__' && defineProperty) {
  20039. defineProperty(object, key, {
  20040. 'configurable': true,
  20041. 'enumerable': true,
  20042. 'value': value,
  20043. 'writable': true
  20044. });
  20045. } else {
  20046. object[key] = value;
  20047. }
  20048. }
  20049. /**
  20050. * The base implementation of `_.at` without support for individual paths.
  20051. *
  20052. * @private
  20053. * @param {Object} object The object to iterate over.
  20054. * @param {string[]} paths The property paths to pick.
  20055. * @returns {Array} Returns the picked elements.
  20056. */
  20057. function baseAt(object, paths) {
  20058. var index = -1,
  20059. length = paths.length,
  20060. result = Array(length),
  20061. skip = object == null;
  20062. while (++index < length) {
  20063. result[index] = skip ? undefined : get(object, paths[index]);
  20064. }
  20065. return result;
  20066. }
  20067. /**
  20068. * The base implementation of `_.clamp` which doesn't coerce arguments.
  20069. *
  20070. * @private
  20071. * @param {number} number The number to clamp.
  20072. * @param {number} [lower] The lower bound.
  20073. * @param {number} upper The upper bound.
  20074. * @returns {number} Returns the clamped number.
  20075. */
  20076. function baseClamp(number, lower, upper) {
  20077. if (number === number) {
  20078. if (upper !== undefined) {
  20079. number = number <= upper ? number : upper;
  20080. }
  20081. if (lower !== undefined) {
  20082. number = number >= lower ? number : lower;
  20083. }
  20084. }
  20085. return number;
  20086. }
  20087. /**
  20088. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  20089. * traversed objects.
  20090. *
  20091. * @private
  20092. * @param {*} value The value to clone.
  20093. * @param {boolean} bitmask The bitmask flags.
  20094. * 1 - Deep clone
  20095. * 2 - Flatten inherited properties
  20096. * 4 - Clone symbols
  20097. * @param {Function} [customizer] The function to customize cloning.
  20098. * @param {string} [key] The key of `value`.
  20099. * @param {Object} [object] The parent object of `value`.
  20100. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  20101. * @returns {*} Returns the cloned value.
  20102. */
  20103. function baseClone(value, bitmask, customizer, key, object, stack) {
  20104. var result,
  20105. isDeep = bitmask & CLONE_DEEP_FLAG,
  20106. isFlat = bitmask & CLONE_FLAT_FLAG,
  20107. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  20108. if (customizer) {
  20109. result = object ? customizer(value, key, object, stack) : customizer(value);
  20110. }
  20111. if (result !== undefined) {
  20112. return result;
  20113. }
  20114. if (!isObject(value)) {
  20115. return value;
  20116. }
  20117. var isArr = isArray(value);
  20118. if (isArr) {
  20119. result = initCloneArray(value);
  20120. if (!isDeep) {
  20121. return copyArray(value, result);
  20122. }
  20123. } else {
  20124. var tag = getTag(value),
  20125. isFunc = tag == funcTag || tag == genTag;
  20126. if (isBuffer(value)) {
  20127. return cloneBuffer(value, isDeep);
  20128. }
  20129. if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
  20130. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  20131. if (!isDeep) {
  20132. return isFlat
  20133. ? copySymbolsIn(value, baseAssignIn(result, value))
  20134. : copySymbols(value, baseAssign(result, value));
  20135. }
  20136. } else {
  20137. if (!cloneableTags[tag]) {
  20138. return object ? value : {};
  20139. }
  20140. result = initCloneByTag(value, tag, isDeep);
  20141. }
  20142. }
  20143. // Check for circular references and return its corresponding clone.
  20144. stack || (stack = new Stack);
  20145. var stacked = stack.get(value);
  20146. if (stacked) {
  20147. return stacked;
  20148. }
  20149. stack.set(value, result);
  20150. if (isSet(value)) {
  20151. value.forEach(function(subValue) {
  20152. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  20153. });
  20154. } else if (isMap(value)) {
  20155. value.forEach(function(subValue, key) {
  20156. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  20157. });
  20158. }
  20159. var keysFunc = isFull
  20160. ? (isFlat ? getAllKeysIn : getAllKeys)
  20161. : (isFlat ? keysIn : keys);
  20162. var props = isArr ? undefined : keysFunc(value);
  20163. arrayEach(props || value, function(subValue, key) {
  20164. if (props) {
  20165. key = subValue;
  20166. subValue = value[key];
  20167. }
  20168. // Recursively populate clone (susceptible to call stack limits).
  20169. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  20170. });
  20171. return result;
  20172. }
  20173. /**
  20174. * The base implementation of `_.conforms` which doesn't clone `source`.
  20175. *
  20176. * @private
  20177. * @param {Object} source The object of property predicates to conform to.
  20178. * @returns {Function} Returns the new spec function.
  20179. */
  20180. function baseConforms(source) {
  20181. var props = keys(source);
  20182. return function(object) {
  20183. return baseConformsTo(object, source, props);
  20184. };
  20185. }
  20186. /**
  20187. * The base implementation of `_.conformsTo` which accepts `props` to check.
  20188. *
  20189. * @private
  20190. * @param {Object} object The object to inspect.
  20191. * @param {Object} source The object of property predicates to conform to.
  20192. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  20193. */
  20194. function baseConformsTo(object, source, props) {
  20195. var length = props.length;
  20196. if (object == null) {
  20197. return !length;
  20198. }
  20199. object = Object(object);
  20200. while (length--) {
  20201. var key = props[length],
  20202. predicate = source[key],
  20203. value = object[key];
  20204. if ((value === undefined && !(key in object)) || !predicate(value)) {
  20205. return false;
  20206. }
  20207. }
  20208. return true;
  20209. }
  20210. /**
  20211. * The base implementation of `_.delay` and `_.defer` which accepts `args`
  20212. * to provide to `func`.
  20213. *
  20214. * @private
  20215. * @param {Function} func The function to delay.
  20216. * @param {number} wait The number of milliseconds to delay invocation.
  20217. * @param {Array} args The arguments to provide to `func`.
  20218. * @returns {number|Object} Returns the timer id or timeout object.
  20219. */
  20220. function baseDelay(func, wait, args) {
  20221. if (typeof func != 'function') {
  20222. throw new TypeError(FUNC_ERROR_TEXT);
  20223. }
  20224. return setTimeout(function() { func.apply(undefined, args); }, wait);
  20225. }
  20226. /**
  20227. * The base implementation of methods like `_.difference` without support
  20228. * for excluding multiple arrays or iteratee shorthands.
  20229. *
  20230. * @private
  20231. * @param {Array} array The array to inspect.
  20232. * @param {Array} values The values to exclude.
  20233. * @param {Function} [iteratee] The iteratee invoked per element.
  20234. * @param {Function} [comparator] The comparator invoked per element.
  20235. * @returns {Array} Returns the new array of filtered values.
  20236. */
  20237. function baseDifference(array, values, iteratee, comparator) {
  20238. var index = -1,
  20239. includes = arrayIncludes,
  20240. isCommon = true,
  20241. length = array.length,
  20242. result = [],
  20243. valuesLength = values.length;
  20244. if (!length) {
  20245. return result;
  20246. }
  20247. if (iteratee) {
  20248. values = arrayMap(values, baseUnary(iteratee));
  20249. }
  20250. if (comparator) {
  20251. includes = arrayIncludesWith;
  20252. isCommon = false;
  20253. }
  20254. else if (values.length >= LARGE_ARRAY_SIZE) {
  20255. includes = cacheHas;
  20256. isCommon = false;
  20257. values = new SetCache(values);
  20258. }
  20259. outer:
  20260. while (++index < length) {
  20261. var value = array[index],
  20262. computed = iteratee == null ? value : iteratee(value);
  20263. value = (comparator || value !== 0) ? value : 0;
  20264. if (isCommon && computed === computed) {
  20265. var valuesIndex = valuesLength;
  20266. while (valuesIndex--) {
  20267. if (values[valuesIndex] === computed) {
  20268. continue outer;
  20269. }
  20270. }
  20271. result.push(value);
  20272. }
  20273. else if (!includes(values, computed, comparator)) {
  20274. result.push(value);
  20275. }
  20276. }
  20277. return result;
  20278. }
  20279. /**
  20280. * The base implementation of `_.forEach` without support for iteratee shorthands.
  20281. *
  20282. * @private
  20283. * @param {Array|Object} collection The collection to iterate over.
  20284. * @param {Function} iteratee The function invoked per iteration.
  20285. * @returns {Array|Object} Returns `collection`.
  20286. */
  20287. var baseEach = createBaseEach(baseForOwn);
  20288. /**
  20289. * The base implementation of `_.forEachRight` without support for iteratee shorthands.
  20290. *
  20291. * @private
  20292. * @param {Array|Object} collection The collection to iterate over.
  20293. * @param {Function} iteratee The function invoked per iteration.
  20294. * @returns {Array|Object} Returns `collection`.
  20295. */
  20296. var baseEachRight = createBaseEach(baseForOwnRight, true);
  20297. /**
  20298. * The base implementation of `_.every` without support for iteratee shorthands.
  20299. *
  20300. * @private
  20301. * @param {Array|Object} collection The collection to iterate over.
  20302. * @param {Function} predicate The function invoked per iteration.
  20303. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  20304. * else `false`
  20305. */
  20306. function baseEvery(collection, predicate) {
  20307. var result = true;
  20308. baseEach(collection, function(value, index, collection) {
  20309. result = !!predicate(value, index, collection);
  20310. return result;
  20311. });
  20312. return result;
  20313. }
  20314. /**
  20315. * The base implementation of methods like `_.max` and `_.min` which accepts a
  20316. * `comparator` to determine the extremum value.
  20317. *
  20318. * @private
  20319. * @param {Array} array The array to iterate over.
  20320. * @param {Function} iteratee The iteratee invoked per iteration.
  20321. * @param {Function} comparator The comparator used to compare values.
  20322. * @returns {*} Returns the extremum value.
  20323. */
  20324. function baseExtremum(array, iteratee, comparator) {
  20325. var index = -1,
  20326. length = array.length;
  20327. while (++index < length) {
  20328. var value = array[index],
  20329. current = iteratee(value);
  20330. if (current != null && (computed === undefined
  20331. ? (current === current && !isSymbol(current))
  20332. : comparator(current, computed)
  20333. )) {
  20334. var computed = current,
  20335. result = value;
  20336. }
  20337. }
  20338. return result;
  20339. }
  20340. /**
  20341. * The base implementation of `_.fill` without an iteratee call guard.
  20342. *
  20343. * @private
  20344. * @param {Array} array The array to fill.
  20345. * @param {*} value The value to fill `array` with.
  20346. * @param {number} [start=0] The start position.
  20347. * @param {number} [end=array.length] The end position.
  20348. * @returns {Array} Returns `array`.
  20349. */
  20350. function baseFill(array, value, start, end) {
  20351. var length = array.length;
  20352. start = toInteger(start);
  20353. if (start < 0) {
  20354. start = -start > length ? 0 : (length + start);
  20355. }
  20356. end = (end === undefined || end > length) ? length : toInteger(end);
  20357. if (end < 0) {
  20358. end += length;
  20359. }
  20360. end = start > end ? 0 : toLength(end);
  20361. while (start < end) {
  20362. array[start++] = value;
  20363. }
  20364. return array;
  20365. }
  20366. /**
  20367. * The base implementation of `_.filter` without support for iteratee shorthands.
  20368. *
  20369. * @private
  20370. * @param {Array|Object} collection The collection to iterate over.
  20371. * @param {Function} predicate The function invoked per iteration.
  20372. * @returns {Array} Returns the new filtered array.
  20373. */
  20374. function baseFilter(collection, predicate) {
  20375. var result = [];
  20376. baseEach(collection, function(value, index, collection) {
  20377. if (predicate(value, index, collection)) {
  20378. result.push(value);
  20379. }
  20380. });
  20381. return result;
  20382. }
  20383. /**
  20384. * The base implementation of `_.flatten` with support for restricting flattening.
  20385. *
  20386. * @private
  20387. * @param {Array} array The array to flatten.
  20388. * @param {number} depth The maximum recursion depth.
  20389. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  20390. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  20391. * @param {Array} [result=[]] The initial result value.
  20392. * @returns {Array} Returns the new flattened array.
  20393. */
  20394. function baseFlatten(array, depth, predicate, isStrict, result) {
  20395. var index = -1,
  20396. length = array.length;
  20397. predicate || (predicate = isFlattenable);
  20398. result || (result = []);
  20399. while (++index < length) {
  20400. var value = array[index];
  20401. if (depth > 0 && predicate(value)) {
  20402. if (depth > 1) {
  20403. // Recursively flatten arrays (susceptible to call stack limits).
  20404. baseFlatten(value, depth - 1, predicate, isStrict, result);
  20405. } else {
  20406. arrayPush(result, value);
  20407. }
  20408. } else if (!isStrict) {
  20409. result[result.length] = value;
  20410. }
  20411. }
  20412. return result;
  20413. }
  20414. /**
  20415. * The base implementation of `baseForOwn` which iterates over `object`
  20416. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  20417. * Iteratee functions may exit iteration early by explicitly returning `false`.
  20418. *
  20419. * @private
  20420. * @param {Object} object The object to iterate over.
  20421. * @param {Function} iteratee The function invoked per iteration.
  20422. * @param {Function} keysFunc The function to get the keys of `object`.
  20423. * @returns {Object} Returns `object`.
  20424. */
  20425. var baseFor = createBaseFor();
  20426. /**
  20427. * This function is like `baseFor` except that it iterates over properties
  20428. * in the opposite order.
  20429. *
  20430. * @private
  20431. * @param {Object} object The object to iterate over.
  20432. * @param {Function} iteratee The function invoked per iteration.
  20433. * @param {Function} keysFunc The function to get the keys of `object`.
  20434. * @returns {Object} Returns `object`.
  20435. */
  20436. var baseForRight = createBaseFor(true);
  20437. /**
  20438. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  20439. *
  20440. * @private
  20441. * @param {Object} object The object to iterate over.
  20442. * @param {Function} iteratee The function invoked per iteration.
  20443. * @returns {Object} Returns `object`.
  20444. */
  20445. function baseForOwn(object, iteratee) {
  20446. return object && baseFor(object, iteratee, keys);
  20447. }
  20448. /**
  20449. * The base implementation of `_.forOwnRight` without support for iteratee shorthands.
  20450. *
  20451. * @private
  20452. * @param {Object} object The object to iterate over.
  20453. * @param {Function} iteratee The function invoked per iteration.
  20454. * @returns {Object} Returns `object`.
  20455. */
  20456. function baseForOwnRight(object, iteratee) {
  20457. return object && baseForRight(object, iteratee, keys);
  20458. }
  20459. /**
  20460. * The base implementation of `_.functions` which creates an array of
  20461. * `object` function property names filtered from `props`.
  20462. *
  20463. * @private
  20464. * @param {Object} object The object to inspect.
  20465. * @param {Array} props The property names to filter.
  20466. * @returns {Array} Returns the function names.
  20467. */
  20468. function baseFunctions(object, props) {
  20469. return arrayFilter(props, function(key) {
  20470. return isFunction(object[key]);
  20471. });
  20472. }
  20473. /**
  20474. * The base implementation of `_.get` without support for default values.
  20475. *
  20476. * @private
  20477. * @param {Object} object The object to query.
  20478. * @param {Array|string} path The path of the property to get.
  20479. * @returns {*} Returns the resolved value.
  20480. */
  20481. function baseGet(object, path) {
  20482. path = castPath(path, object);
  20483. var index = 0,
  20484. length = path.length;
  20485. while (object != null && index < length) {
  20486. object = object[toKey(path[index++])];
  20487. }
  20488. return (index && index == length) ? object : undefined;
  20489. }
  20490. /**
  20491. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  20492. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  20493. * symbols of `object`.
  20494. *
  20495. * @private
  20496. * @param {Object} object The object to query.
  20497. * @param {Function} keysFunc The function to get the keys of `object`.
  20498. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  20499. * @returns {Array} Returns the array of property names and symbols.
  20500. */
  20501. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  20502. var result = keysFunc(object);
  20503. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  20504. }
  20505. /**
  20506. * The base implementation of `getTag` without fallbacks for buggy environments.
  20507. *
  20508. * @private
  20509. * @param {*} value The value to query.
  20510. * @returns {string} Returns the `toStringTag`.
  20511. */
  20512. function baseGetTag(value) {
  20513. if (value == null) {
  20514. return value === undefined ? undefinedTag : nullTag;
  20515. }
  20516. return (symToStringTag && symToStringTag in Object(value))
  20517. ? getRawTag(value)
  20518. : objectToString(value);
  20519. }
  20520. /**
  20521. * The base implementation of `_.gt` which doesn't coerce arguments.
  20522. *
  20523. * @private
  20524. * @param {*} value The value to compare.
  20525. * @param {*} other The other value to compare.
  20526. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  20527. * else `false`.
  20528. */
  20529. function baseGt(value, other) {
  20530. return value > other;
  20531. }
  20532. /**
  20533. * The base implementation of `_.has` without support for deep paths.
  20534. *
  20535. * @private
  20536. * @param {Object} [object] The object to query.
  20537. * @param {Array|string} key The key to check.
  20538. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  20539. */
  20540. function baseHas(object, key) {
  20541. return object != null && hasOwnProperty.call(object, key);
  20542. }
  20543. /**
  20544. * The base implementation of `_.hasIn` without support for deep paths.
  20545. *
  20546. * @private
  20547. * @param {Object} [object] The object to query.
  20548. * @param {Array|string} key The key to check.
  20549. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  20550. */
  20551. function baseHasIn(object, key) {
  20552. return object != null && key in Object(object);
  20553. }
  20554. /**
  20555. * The base implementation of `_.inRange` which doesn't coerce arguments.
  20556. *
  20557. * @private
  20558. * @param {number} number The number to check.
  20559. * @param {number} start The start of the range.
  20560. * @param {number} end The end of the range.
  20561. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  20562. */
  20563. function baseInRange(number, start, end) {
  20564. return number >= nativeMin(start, end) && number < nativeMax(start, end);
  20565. }
  20566. /**
  20567. * The base implementation of methods like `_.intersection`, without support
  20568. * for iteratee shorthands, that accepts an array of arrays to inspect.
  20569. *
  20570. * @private
  20571. * @param {Array} arrays The arrays to inspect.
  20572. * @param {Function} [iteratee] The iteratee invoked per element.
  20573. * @param {Function} [comparator] The comparator invoked per element.
  20574. * @returns {Array} Returns the new array of shared values.
  20575. */
  20576. function baseIntersection(arrays, iteratee, comparator) {
  20577. var includes = comparator ? arrayIncludesWith : arrayIncludes,
  20578. length = arrays[0].length,
  20579. othLength = arrays.length,
  20580. othIndex = othLength,
  20581. caches = Array(othLength),
  20582. maxLength = Infinity,
  20583. result = [];
  20584. while (othIndex--) {
  20585. var array = arrays[othIndex];
  20586. if (othIndex && iteratee) {
  20587. array = arrayMap(array, baseUnary(iteratee));
  20588. }
  20589. maxLength = nativeMin(array.length, maxLength);
  20590. caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
  20591. ? new SetCache(othIndex && array)
  20592. : undefined;
  20593. }
  20594. array = arrays[0];
  20595. var index = -1,
  20596. seen = caches[0];
  20597. outer:
  20598. while (++index < length && result.length < maxLength) {
  20599. var value = array[index],
  20600. computed = iteratee ? iteratee(value) : value;
  20601. value = (comparator || value !== 0) ? value : 0;
  20602. if (!(seen
  20603. ? cacheHas(seen, computed)
  20604. : includes(result, computed, comparator)
  20605. )) {
  20606. othIndex = othLength;
  20607. while (--othIndex) {
  20608. var cache = caches[othIndex];
  20609. if (!(cache
  20610. ? cacheHas(cache, computed)
  20611. : includes(arrays[othIndex], computed, comparator))
  20612. ) {
  20613. continue outer;
  20614. }
  20615. }
  20616. if (seen) {
  20617. seen.push(computed);
  20618. }
  20619. result.push(value);
  20620. }
  20621. }
  20622. return result;
  20623. }
  20624. /**
  20625. * The base implementation of `_.invert` and `_.invertBy` which inverts
  20626. * `object` with values transformed by `iteratee` and set by `setter`.
  20627. *
  20628. * @private
  20629. * @param {Object} object The object to iterate over.
  20630. * @param {Function} setter The function to set `accumulator` values.
  20631. * @param {Function} iteratee The iteratee to transform values.
  20632. * @param {Object} accumulator The initial inverted object.
  20633. * @returns {Function} Returns `accumulator`.
  20634. */
  20635. function baseInverter(object, setter, iteratee, accumulator) {
  20636. baseForOwn(object, function(value, key, object) {
  20637. setter(accumulator, iteratee(value), key, object);
  20638. });
  20639. return accumulator;
  20640. }
  20641. /**
  20642. * The base implementation of `_.invoke` without support for individual
  20643. * method arguments.
  20644. *
  20645. * @private
  20646. * @param {Object} object The object to query.
  20647. * @param {Array|string} path The path of the method to invoke.
  20648. * @param {Array} args The arguments to invoke the method with.
  20649. * @returns {*} Returns the result of the invoked method.
  20650. */
  20651. function baseInvoke(object, path, args) {
  20652. path = castPath(path, object);
  20653. object = parent(object, path);
  20654. var func = object == null ? object : object[toKey(last(path))];
  20655. return func == null ? undefined : apply(func, object, args);
  20656. }
  20657. /**
  20658. * The base implementation of `_.isArguments`.
  20659. *
  20660. * @private
  20661. * @param {*} value The value to check.
  20662. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  20663. */
  20664. function baseIsArguments(value) {
  20665. return isObjectLike(value) && baseGetTag(value) == argsTag;
  20666. }
  20667. /**
  20668. * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
  20669. *
  20670. * @private
  20671. * @param {*} value The value to check.
  20672. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  20673. */
  20674. function baseIsArrayBuffer(value) {
  20675. return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
  20676. }
  20677. /**
  20678. * The base implementation of `_.isDate` without Node.js optimizations.
  20679. *
  20680. * @private
  20681. * @param {*} value The value to check.
  20682. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  20683. */
  20684. function baseIsDate(value) {
  20685. return isObjectLike(value) && baseGetTag(value) == dateTag;
  20686. }
  20687. /**
  20688. * The base implementation of `_.isEqual` which supports partial comparisons
  20689. * and tracks traversed objects.
  20690. *
  20691. * @private
  20692. * @param {*} value The value to compare.
  20693. * @param {*} other The other value to compare.
  20694. * @param {boolean} bitmask The bitmask flags.
  20695. * 1 - Unordered comparison
  20696. * 2 - Partial comparison
  20697. * @param {Function} [customizer] The function to customize comparisons.
  20698. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  20699. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  20700. */
  20701. function baseIsEqual(value, other, bitmask, customizer, stack) {
  20702. if (value === other) {
  20703. return true;
  20704. }
  20705. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  20706. return value !== value && other !== other;
  20707. }
  20708. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  20709. }
  20710. /**
  20711. * A specialized version of `baseIsEqual` for arrays and objects which performs
  20712. * deep comparisons and tracks traversed objects enabling objects with circular
  20713. * references to be compared.
  20714. *
  20715. * @private
  20716. * @param {Object} object The object to compare.
  20717. * @param {Object} other The other object to compare.
  20718. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  20719. * @param {Function} customizer The function to customize comparisons.
  20720. * @param {Function} equalFunc The function to determine equivalents of values.
  20721. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  20722. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  20723. */
  20724. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  20725. var objIsArr = isArray(object),
  20726. othIsArr = isArray(other),
  20727. objTag = objIsArr ? arrayTag : getTag(object),
  20728. othTag = othIsArr ? arrayTag : getTag(other);
  20729. objTag = objTag == argsTag ? objectTag : objTag;
  20730. othTag = othTag == argsTag ? objectTag : othTag;
  20731. var objIsObj = objTag == objectTag,
  20732. othIsObj = othTag == objectTag,
  20733. isSameTag = objTag == othTag;
  20734. if (isSameTag && isBuffer(object)) {
  20735. if (!isBuffer(other)) {
  20736. return false;
  20737. }
  20738. objIsArr = true;
  20739. objIsObj = false;
  20740. }
  20741. if (isSameTag && !objIsObj) {
  20742. stack || (stack = new Stack);
  20743. return (objIsArr || isTypedArray(object))
  20744. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  20745. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  20746. }
  20747. if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
  20748. var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
  20749. othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
  20750. if (objIsWrapped || othIsWrapped) {
  20751. var objUnwrapped = objIsWrapped ? object.value() : object,
  20752. othUnwrapped = othIsWrapped ? other.value() : other;
  20753. stack || (stack = new Stack);
  20754. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  20755. }
  20756. }
  20757. if (!isSameTag) {
  20758. return false;
  20759. }
  20760. stack || (stack = new Stack);
  20761. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  20762. }
  20763. /**
  20764. * The base implementation of `_.isMap` without Node.js optimizations.
  20765. *
  20766. * @private
  20767. * @param {*} value The value to check.
  20768. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  20769. */
  20770. function baseIsMap(value) {
  20771. return isObjectLike(value) && getTag(value) == mapTag;
  20772. }
  20773. /**
  20774. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  20775. *
  20776. * @private
  20777. * @param {Object} object The object to inspect.
  20778. * @param {Object} source The object of property values to match.
  20779. * @param {Array} matchData The property names, values, and compare flags to match.
  20780. * @param {Function} [customizer] The function to customize comparisons.
  20781. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  20782. */
  20783. function baseIsMatch(object, source, matchData, customizer) {
  20784. var index = matchData.length,
  20785. length = index,
  20786. noCustomizer = !customizer;
  20787. if (object == null) {
  20788. return !length;
  20789. }
  20790. object = Object(object);
  20791. while (index--) {
  20792. var data = matchData[index];
  20793. if ((noCustomizer && data[2])
  20794. ? data[1] !== object[data[0]]
  20795. : !(data[0] in object)
  20796. ) {
  20797. return false;
  20798. }
  20799. }
  20800. while (++index < length) {
  20801. data = matchData[index];
  20802. var key = data[0],
  20803. objValue = object[key],
  20804. srcValue = data[1];
  20805. if (noCustomizer && data[2]) {
  20806. if (objValue === undefined && !(key in object)) {
  20807. return false;
  20808. }
  20809. } else {
  20810. var stack = new Stack;
  20811. if (customizer) {
  20812. var result = customizer(objValue, srcValue, key, object, source, stack);
  20813. }
  20814. if (!(result === undefined
  20815. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
  20816. : result
  20817. )) {
  20818. return false;
  20819. }
  20820. }
  20821. }
  20822. return true;
  20823. }
  20824. /**
  20825. * The base implementation of `_.isNative` without bad shim checks.
  20826. *
  20827. * @private
  20828. * @param {*} value The value to check.
  20829. * @returns {boolean} Returns `true` if `value` is a native function,
  20830. * else `false`.
  20831. */
  20832. function baseIsNative(value) {
  20833. if (!isObject(value) || isMasked(value)) {
  20834. return false;
  20835. }
  20836. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  20837. return pattern.test(toSource(value));
  20838. }
  20839. /**
  20840. * The base implementation of `_.isRegExp` without Node.js optimizations.
  20841. *
  20842. * @private
  20843. * @param {*} value The value to check.
  20844. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  20845. */
  20846. function baseIsRegExp(value) {
  20847. return isObjectLike(value) && baseGetTag(value) == regexpTag;
  20848. }
  20849. /**
  20850. * The base implementation of `_.isSet` without Node.js optimizations.
  20851. *
  20852. * @private
  20853. * @param {*} value The value to check.
  20854. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  20855. */
  20856. function baseIsSet(value) {
  20857. return isObjectLike(value) && getTag(value) == setTag;
  20858. }
  20859. /**
  20860. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  20861. *
  20862. * @private
  20863. * @param {*} value The value to check.
  20864. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  20865. */
  20866. function baseIsTypedArray(value) {
  20867. return isObjectLike(value) &&
  20868. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  20869. }
  20870. /**
  20871. * The base implementation of `_.iteratee`.
  20872. *
  20873. * @private
  20874. * @param {*} [value=_.identity] The value to convert to an iteratee.
  20875. * @returns {Function} Returns the iteratee.
  20876. */
  20877. function baseIteratee(value) {
  20878. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  20879. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  20880. if (typeof value == 'function') {
  20881. return value;
  20882. }
  20883. if (value == null) {
  20884. return identity;
  20885. }
  20886. if (typeof value == 'object') {
  20887. return isArray(value)
  20888. ? baseMatchesProperty(value[0], value[1])
  20889. : baseMatches(value);
  20890. }
  20891. return property(value);
  20892. }
  20893. /**
  20894. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  20895. *
  20896. * @private
  20897. * @param {Object} object The object to query.
  20898. * @returns {Array} Returns the array of property names.
  20899. */
  20900. function baseKeys(object) {
  20901. if (!isPrototype(object)) {
  20902. return nativeKeys(object);
  20903. }
  20904. var result = [];
  20905. for (var key in Object(object)) {
  20906. if (hasOwnProperty.call(object, key) && key != 'constructor') {
  20907. result.push(key);
  20908. }
  20909. }
  20910. return result;
  20911. }
  20912. /**
  20913. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  20914. *
  20915. * @private
  20916. * @param {Object} object The object to query.
  20917. * @returns {Array} Returns the array of property names.
  20918. */
  20919. function baseKeysIn(object) {
  20920. if (!isObject(object)) {
  20921. return nativeKeysIn(object);
  20922. }
  20923. var isProto = isPrototype(object),
  20924. result = [];
  20925. for (var key in object) {
  20926. if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
  20927. result.push(key);
  20928. }
  20929. }
  20930. return result;
  20931. }
  20932. /**
  20933. * The base implementation of `_.lt` which doesn't coerce arguments.
  20934. *
  20935. * @private
  20936. * @param {*} value The value to compare.
  20937. * @param {*} other The other value to compare.
  20938. * @returns {boolean} Returns `true` if `value` is less than `other`,
  20939. * else `false`.
  20940. */
  20941. function baseLt(value, other) {
  20942. return value < other;
  20943. }
  20944. /**
  20945. * The base implementation of `_.map` without support for iteratee shorthands.
  20946. *
  20947. * @private
  20948. * @param {Array|Object} collection The collection to iterate over.
  20949. * @param {Function} iteratee The function invoked per iteration.
  20950. * @returns {Array} Returns the new mapped array.
  20951. */
  20952. function baseMap(collection, iteratee) {
  20953. var index = -1,
  20954. result = isArrayLike(collection) ? Array(collection.length) : [];
  20955. baseEach(collection, function(value, key, collection) {
  20956. result[++index] = iteratee(value, key, collection);
  20957. });
  20958. return result;
  20959. }
  20960. /**
  20961. * The base implementation of `_.matches` which doesn't clone `source`.
  20962. *
  20963. * @private
  20964. * @param {Object} source The object of property values to match.
  20965. * @returns {Function} Returns the new spec function.
  20966. */
  20967. function baseMatches(source) {
  20968. var matchData = getMatchData(source);
  20969. if (matchData.length == 1 && matchData[0][2]) {
  20970. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  20971. }
  20972. return function(object) {
  20973. return object === source || baseIsMatch(object, source, matchData);
  20974. };
  20975. }
  20976. /**
  20977. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  20978. *
  20979. * @private
  20980. * @param {string} path The path of the property to get.
  20981. * @param {*} srcValue The value to match.
  20982. * @returns {Function} Returns the new spec function.
  20983. */
  20984. function baseMatchesProperty(path, srcValue) {
  20985. if (isKey(path) && isStrictComparable(srcValue)) {
  20986. return matchesStrictComparable(toKey(path), srcValue);
  20987. }
  20988. return function(object) {
  20989. var objValue = get(object, path);
  20990. return (objValue === undefined && objValue === srcValue)
  20991. ? hasIn(object, path)
  20992. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
  20993. };
  20994. }
  20995. /**
  20996. * The base implementation of `_.merge` without support for multiple sources.
  20997. *
  20998. * @private
  20999. * @param {Object} object The destination object.
  21000. * @param {Object} source The source object.
  21001. * @param {number} srcIndex The index of `source`.
  21002. * @param {Function} [customizer] The function to customize merged values.
  21003. * @param {Object} [stack] Tracks traversed source values and their merged
  21004. * counterparts.
  21005. */
  21006. function baseMerge(object, source, srcIndex, customizer, stack) {
  21007. if (object === source) {
  21008. return;
  21009. }
  21010. baseFor(source, function(srcValue, key) {
  21011. stack || (stack = new Stack);
  21012. if (isObject(srcValue)) {
  21013. baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
  21014. }
  21015. else {
  21016. var newValue = customizer
  21017. ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
  21018. : undefined;
  21019. if (newValue === undefined) {
  21020. newValue = srcValue;
  21021. }
  21022. assignMergeValue(object, key, newValue);
  21023. }
  21024. }, keysIn);
  21025. }
  21026. /**
  21027. * A specialized version of `baseMerge` for arrays and objects which performs
  21028. * deep merges and tracks traversed objects enabling objects with circular
  21029. * references to be merged.
  21030. *
  21031. * @private
  21032. * @param {Object} object The destination object.
  21033. * @param {Object} source The source object.
  21034. * @param {string} key The key of the value to merge.
  21035. * @param {number} srcIndex The index of `source`.
  21036. * @param {Function} mergeFunc The function to merge values.
  21037. * @param {Function} [customizer] The function to customize assigned values.
  21038. * @param {Object} [stack] Tracks traversed source values and their merged
  21039. * counterparts.
  21040. */
  21041. function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
  21042. var objValue = safeGet(object, key),
  21043. srcValue = safeGet(source, key),
  21044. stacked = stack.get(srcValue);
  21045. if (stacked) {
  21046. assignMergeValue(object, key, stacked);
  21047. return;
  21048. }
  21049. var newValue = customizer
  21050. ? customizer(objValue, srcValue, (key + ''), object, source, stack)
  21051. : undefined;
  21052. var isCommon = newValue === undefined;
  21053. if (isCommon) {
  21054. var isArr = isArray(srcValue),
  21055. isBuff = !isArr && isBuffer(srcValue),
  21056. isTyped = !isArr && !isBuff && isTypedArray(srcValue);
  21057. newValue = srcValue;
  21058. if (isArr || isBuff || isTyped) {
  21059. if (isArray(objValue)) {
  21060. newValue = objValue;
  21061. }
  21062. else if (isArrayLikeObject(objValue)) {
  21063. newValue = copyArray(objValue);
  21064. }
  21065. else if (isBuff) {
  21066. isCommon = false;
  21067. newValue = cloneBuffer(srcValue, true);
  21068. }
  21069. else if (isTyped) {
  21070. isCommon = false;
  21071. newValue = cloneTypedArray(srcValue, true);
  21072. }
  21073. else {
  21074. newValue = [];
  21075. }
  21076. }
  21077. else if (isPlainObject(srcValue) || isArguments(srcValue)) {
  21078. newValue = objValue;
  21079. if (isArguments(objValue)) {
  21080. newValue = toPlainObject(objValue);
  21081. }
  21082. else if (!isObject(objValue) || isFunction(objValue)) {
  21083. newValue = initCloneObject(srcValue);
  21084. }
  21085. }
  21086. else {
  21087. isCommon = false;
  21088. }
  21089. }
  21090. if (isCommon) {
  21091. // Recursively merge objects and arrays (susceptible to call stack limits).
  21092. stack.set(srcValue, newValue);
  21093. mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
  21094. stack['delete'](srcValue);
  21095. }
  21096. assignMergeValue(object, key, newValue);
  21097. }
  21098. /**
  21099. * The base implementation of `_.nth` which doesn't coerce arguments.
  21100. *
  21101. * @private
  21102. * @param {Array} array The array to query.
  21103. * @param {number} n The index of the element to return.
  21104. * @returns {*} Returns the nth element of `array`.
  21105. */
  21106. function baseNth(array, n) {
  21107. var length = array.length;
  21108. if (!length) {
  21109. return;
  21110. }
  21111. n += n < 0 ? length : 0;
  21112. return isIndex(n, length) ? array[n] : undefined;
  21113. }
  21114. /**
  21115. * The base implementation of `_.orderBy` without param guards.
  21116. *
  21117. * @private
  21118. * @param {Array|Object} collection The collection to iterate over.
  21119. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  21120. * @param {string[]} orders The sort orders of `iteratees`.
  21121. * @returns {Array} Returns the new sorted array.
  21122. */
  21123. function baseOrderBy(collection, iteratees, orders) {
  21124. var index = -1;
  21125. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee()));
  21126. var result = baseMap(collection, function(value, key, collection) {
  21127. var criteria = arrayMap(iteratees, function(iteratee) {
  21128. return iteratee(value);
  21129. });
  21130. return { 'criteria': criteria, 'index': ++index, 'value': value };
  21131. });
  21132. return baseSortBy(result, function(object, other) {
  21133. return compareMultiple(object, other, orders);
  21134. });
  21135. }
  21136. /**
  21137. * The base implementation of `_.pick` without support for individual
  21138. * property identifiers.
  21139. *
  21140. * @private
  21141. * @param {Object} object The source object.
  21142. * @param {string[]} paths The property paths to pick.
  21143. * @returns {Object} Returns the new object.
  21144. */
  21145. function basePick(object, paths) {
  21146. return basePickBy(object, paths, function(value, path) {
  21147. return hasIn(object, path);
  21148. });
  21149. }
  21150. /**
  21151. * The base implementation of `_.pickBy` without support for iteratee shorthands.
  21152. *
  21153. * @private
  21154. * @param {Object} object The source object.
  21155. * @param {string[]} paths The property paths to pick.
  21156. * @param {Function} predicate The function invoked per property.
  21157. * @returns {Object} Returns the new object.
  21158. */
  21159. function basePickBy(object, paths, predicate) {
  21160. var index = -1,
  21161. length = paths.length,
  21162. result = {};
  21163. while (++index < length) {
  21164. var path = paths[index],
  21165. value = baseGet(object, path);
  21166. if (predicate(value, path)) {
  21167. baseSet(result, castPath(path, object), value);
  21168. }
  21169. }
  21170. return result;
  21171. }
  21172. /**
  21173. * A specialized version of `baseProperty` which supports deep paths.
  21174. *
  21175. * @private
  21176. * @param {Array|string} path The path of the property to get.
  21177. * @returns {Function} Returns the new accessor function.
  21178. */
  21179. function basePropertyDeep(path) {
  21180. return function(object) {
  21181. return baseGet(object, path);
  21182. };
  21183. }
  21184. /**
  21185. * The base implementation of `_.pullAllBy` without support for iteratee
  21186. * shorthands.
  21187. *
  21188. * @private
  21189. * @param {Array} array The array to modify.
  21190. * @param {Array} values The values to remove.
  21191. * @param {Function} [iteratee] The iteratee invoked per element.
  21192. * @param {Function} [comparator] The comparator invoked per element.
  21193. * @returns {Array} Returns `array`.
  21194. */
  21195. function basePullAll(array, values, iteratee, comparator) {
  21196. var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
  21197. index = -1,
  21198. length = values.length,
  21199. seen = array;
  21200. if (array === values) {
  21201. values = copyArray(values);
  21202. }
  21203. if (iteratee) {
  21204. seen = arrayMap(array, baseUnary(iteratee));
  21205. }
  21206. while (++index < length) {
  21207. var fromIndex = 0,
  21208. value = values[index],
  21209. computed = iteratee ? iteratee(value) : value;
  21210. while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
  21211. if (seen !== array) {
  21212. splice.call(seen, fromIndex, 1);
  21213. }
  21214. splice.call(array, fromIndex, 1);
  21215. }
  21216. }
  21217. return array;
  21218. }
  21219. /**
  21220. * The base implementation of `_.pullAt` without support for individual
  21221. * indexes or capturing the removed elements.
  21222. *
  21223. * @private
  21224. * @param {Array} array The array to modify.
  21225. * @param {number[]} indexes The indexes of elements to remove.
  21226. * @returns {Array} Returns `array`.
  21227. */
  21228. function basePullAt(array, indexes) {
  21229. var length = array ? indexes.length : 0,
  21230. lastIndex = length - 1;
  21231. while (length--) {
  21232. var index = indexes[length];
  21233. if (length == lastIndex || index !== previous) {
  21234. var previous = index;
  21235. if (isIndex(index)) {
  21236. splice.call(array, index, 1);
  21237. } else {
  21238. baseUnset(array, index);
  21239. }
  21240. }
  21241. }
  21242. return array;
  21243. }
  21244. /**
  21245. * The base implementation of `_.random` without support for returning
  21246. * floating-point numbers.
  21247. *
  21248. * @private
  21249. * @param {number} lower The lower bound.
  21250. * @param {number} upper The upper bound.
  21251. * @returns {number} Returns the random number.
  21252. */
  21253. function baseRandom(lower, upper) {
  21254. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  21255. }
  21256. /**
  21257. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  21258. * coerce arguments.
  21259. *
  21260. * @private
  21261. * @param {number} start The start of the range.
  21262. * @param {number} end The end of the range.
  21263. * @param {number} step The value to increment or decrement by.
  21264. * @param {boolean} [fromRight] Specify iterating from right to left.
  21265. * @returns {Array} Returns the range of numbers.
  21266. */
  21267. function baseRange(start, end, step, fromRight) {
  21268. var index = -1,
  21269. length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
  21270. result = Array(length);
  21271. while (length--) {
  21272. result[fromRight ? length : ++index] = start;
  21273. start += step;
  21274. }
  21275. return result;
  21276. }
  21277. /**
  21278. * The base implementation of `_.repeat` which doesn't coerce arguments.
  21279. *
  21280. * @private
  21281. * @param {string} string The string to repeat.
  21282. * @param {number} n The number of times to repeat the string.
  21283. * @returns {string} Returns the repeated string.
  21284. */
  21285. function baseRepeat(string, n) {
  21286. var result = '';
  21287. if (!string || n < 1 || n > MAX_SAFE_INTEGER) {
  21288. return result;
  21289. }
  21290. // Leverage the exponentiation by squaring algorithm for a faster repeat.
  21291. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
  21292. do {
  21293. if (n % 2) {
  21294. result += string;
  21295. }
  21296. n = nativeFloor(n / 2);
  21297. if (n) {
  21298. string += string;
  21299. }
  21300. } while (n);
  21301. return result;
  21302. }
  21303. /**
  21304. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  21305. *
  21306. * @private
  21307. * @param {Function} func The function to apply a rest parameter to.
  21308. * @param {number} [start=func.length-1] The start position of the rest parameter.
  21309. * @returns {Function} Returns the new function.
  21310. */
  21311. function baseRest(func, start) {
  21312. return setToString(overRest(func, start, identity), func + '');
  21313. }
  21314. /**
  21315. * The base implementation of `_.sample`.
  21316. *
  21317. * @private
  21318. * @param {Array|Object} collection The collection to sample.
  21319. * @returns {*} Returns the random element.
  21320. */
  21321. function baseSample(collection) {
  21322. return arraySample(values(collection));
  21323. }
  21324. /**
  21325. * The base implementation of `_.sampleSize` without param guards.
  21326. *
  21327. * @private
  21328. * @param {Array|Object} collection The collection to sample.
  21329. * @param {number} n The number of elements to sample.
  21330. * @returns {Array} Returns the random elements.
  21331. */
  21332. function baseSampleSize(collection, n) {
  21333. var array = values(collection);
  21334. return shuffleSelf(array, baseClamp(n, 0, array.length));
  21335. }
  21336. /**
  21337. * The base implementation of `_.set`.
  21338. *
  21339. * @private
  21340. * @param {Object} object The object to modify.
  21341. * @param {Array|string} path The path of the property to set.
  21342. * @param {*} value The value to set.
  21343. * @param {Function} [customizer] The function to customize path creation.
  21344. * @returns {Object} Returns `object`.
  21345. */
  21346. function baseSet(object, path, value, customizer) {
  21347. if (!isObject(object)) {
  21348. return object;
  21349. }
  21350. path = castPath(path, object);
  21351. var index = -1,
  21352. length = path.length,
  21353. lastIndex = length - 1,
  21354. nested = object;
  21355. while (nested != null && ++index < length) {
  21356. var key = toKey(path[index]),
  21357. newValue = value;
  21358. if (index != lastIndex) {
  21359. var objValue = nested[key];
  21360. newValue = customizer ? customizer(objValue, key, nested) : undefined;
  21361. if (newValue === undefined) {
  21362. newValue = isObject(objValue)
  21363. ? objValue
  21364. : (isIndex(path[index + 1]) ? [] : {});
  21365. }
  21366. }
  21367. assignValue(nested, key, newValue);
  21368. nested = nested[key];
  21369. }
  21370. return object;
  21371. }
  21372. /**
  21373. * The base implementation of `setData` without support for hot loop shorting.
  21374. *
  21375. * @private
  21376. * @param {Function} func The function to associate metadata with.
  21377. * @param {*} data The metadata.
  21378. * @returns {Function} Returns `func`.
  21379. */
  21380. var baseSetData = !metaMap ? identity : function(func, data) {
  21381. metaMap.set(func, data);
  21382. return func;
  21383. };
  21384. /**
  21385. * The base implementation of `setToString` without support for hot loop shorting.
  21386. *
  21387. * @private
  21388. * @param {Function} func The function to modify.
  21389. * @param {Function} string The `toString` result.
  21390. * @returns {Function} Returns `func`.
  21391. */
  21392. var baseSetToString = !defineProperty ? identity : function(func, string) {
  21393. return defineProperty(func, 'toString', {
  21394. 'configurable': true,
  21395. 'enumerable': false,
  21396. 'value': constant(string),
  21397. 'writable': true
  21398. });
  21399. };
  21400. /**
  21401. * The base implementation of `_.shuffle`.
  21402. *
  21403. * @private
  21404. * @param {Array|Object} collection The collection to shuffle.
  21405. * @returns {Array} Returns the new shuffled array.
  21406. */
  21407. function baseShuffle(collection) {
  21408. return shuffleSelf(values(collection));
  21409. }
  21410. /**
  21411. * The base implementation of `_.slice` without an iteratee call guard.
  21412. *
  21413. * @private
  21414. * @param {Array} array The array to slice.
  21415. * @param {number} [start=0] The start position.
  21416. * @param {number} [end=array.length] The end position.
  21417. * @returns {Array} Returns the slice of `array`.
  21418. */
  21419. function baseSlice(array, start, end) {
  21420. var index = -1,
  21421. length = array.length;
  21422. if (start < 0) {
  21423. start = -start > length ? 0 : (length + start);
  21424. }
  21425. end = end > length ? length : end;
  21426. if (end < 0) {
  21427. end += length;
  21428. }
  21429. length = start > end ? 0 : ((end - start) >>> 0);
  21430. start >>>= 0;
  21431. var result = Array(length);
  21432. while (++index < length) {
  21433. result[index] = array[index + start];
  21434. }
  21435. return result;
  21436. }
  21437. /**
  21438. * The base implementation of `_.some` without support for iteratee shorthands.
  21439. *
  21440. * @private
  21441. * @param {Array|Object} collection The collection to iterate over.
  21442. * @param {Function} predicate The function invoked per iteration.
  21443. * @returns {boolean} Returns `true` if any element passes the predicate check,
  21444. * else `false`.
  21445. */
  21446. function baseSome(collection, predicate) {
  21447. var result;
  21448. baseEach(collection, function(value, index, collection) {
  21449. result = predicate(value, index, collection);
  21450. return !result;
  21451. });
  21452. return !!result;
  21453. }
  21454. /**
  21455. * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which
  21456. * performs a binary search of `array` to determine the index at which `value`
  21457. * should be inserted into `array` in order to maintain its sort order.
  21458. *
  21459. * @private
  21460. * @param {Array} array The sorted array to inspect.
  21461. * @param {*} value The value to evaluate.
  21462. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  21463. * @returns {number} Returns the index at which `value` should be inserted
  21464. * into `array`.
  21465. */
  21466. function baseSortedIndex(array, value, retHighest) {
  21467. var low = 0,
  21468. high = array == null ? low : array.length;
  21469. if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
  21470. while (low < high) {
  21471. var mid = (low + high) >>> 1,
  21472. computed = array[mid];
  21473. if (computed !== null && !isSymbol(computed) &&
  21474. (retHighest ? (computed <= value) : (computed < value))) {
  21475. low = mid + 1;
  21476. } else {
  21477. high = mid;
  21478. }
  21479. }
  21480. return high;
  21481. }
  21482. return baseSortedIndexBy(array, value, identity, retHighest);
  21483. }
  21484. /**
  21485. * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy`
  21486. * which invokes `iteratee` for `value` and each element of `array` to compute
  21487. * their sort ranking. The iteratee is invoked with one argument; (value).
  21488. *
  21489. * @private
  21490. * @param {Array} array The sorted array to inspect.
  21491. * @param {*} value The value to evaluate.
  21492. * @param {Function} iteratee The iteratee invoked per element.
  21493. * @param {boolean} [retHighest] Specify returning the highest qualified index.
  21494. * @returns {number} Returns the index at which `value` should be inserted
  21495. * into `array`.
  21496. */
  21497. function baseSortedIndexBy(array, value, iteratee, retHighest) {
  21498. value = iteratee(value);
  21499. var low = 0,
  21500. high = array == null ? 0 : array.length,
  21501. valIsNaN = value !== value,
  21502. valIsNull = value === null,
  21503. valIsSymbol = isSymbol(value),
  21504. valIsUndefined = value === undefined;
  21505. while (low < high) {
  21506. var mid = nativeFloor((low + high) / 2),
  21507. computed = iteratee(array[mid]),
  21508. othIsDefined = computed !== undefined,
  21509. othIsNull = computed === null,
  21510. othIsReflexive = computed === computed,
  21511. othIsSymbol = isSymbol(computed);
  21512. if (valIsNaN) {
  21513. var setLow = retHighest || othIsReflexive;
  21514. } else if (valIsUndefined) {
  21515. setLow = othIsReflexive && (retHighest || othIsDefined);
  21516. } else if (valIsNull) {
  21517. setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
  21518. } else if (valIsSymbol) {
  21519. setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
  21520. } else if (othIsNull || othIsSymbol) {
  21521. setLow = false;
  21522. } else {
  21523. setLow = retHighest ? (computed <= value) : (computed < value);
  21524. }
  21525. if (setLow) {
  21526. low = mid + 1;
  21527. } else {
  21528. high = mid;
  21529. }
  21530. }
  21531. return nativeMin(high, MAX_ARRAY_INDEX);
  21532. }
  21533. /**
  21534. * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without
  21535. * support for iteratee shorthands.
  21536. *
  21537. * @private
  21538. * @param {Array} array The array to inspect.
  21539. * @param {Function} [iteratee] The iteratee invoked per element.
  21540. * @returns {Array} Returns the new duplicate free array.
  21541. */
  21542. function baseSortedUniq(array, iteratee) {
  21543. var index = -1,
  21544. length = array.length,
  21545. resIndex = 0,
  21546. result = [];
  21547. while (++index < length) {
  21548. var value = array[index],
  21549. computed = iteratee ? iteratee(value) : value;
  21550. if (!index || !eq(computed, seen)) {
  21551. var seen = computed;
  21552. result[resIndex++] = value === 0 ? 0 : value;
  21553. }
  21554. }
  21555. return result;
  21556. }
  21557. /**
  21558. * The base implementation of `_.toNumber` which doesn't ensure correct
  21559. * conversions of binary, hexadecimal, or octal string values.
  21560. *
  21561. * @private
  21562. * @param {*} value The value to process.
  21563. * @returns {number} Returns the number.
  21564. */
  21565. function baseToNumber(value) {
  21566. if (typeof value == 'number') {
  21567. return value;
  21568. }
  21569. if (isSymbol(value)) {
  21570. return NAN;
  21571. }
  21572. return +value;
  21573. }
  21574. /**
  21575. * The base implementation of `_.toString` which doesn't convert nullish
  21576. * values to empty strings.
  21577. *
  21578. * @private
  21579. * @param {*} value The value to process.
  21580. * @returns {string} Returns the string.
  21581. */
  21582. function baseToString(value) {
  21583. // Exit early for strings to avoid a performance hit in some environments.
  21584. if (typeof value == 'string') {
  21585. return value;
  21586. }
  21587. if (isArray(value)) {
  21588. // Recursively convert values (susceptible to call stack limits).
  21589. return arrayMap(value, baseToString) + '';
  21590. }
  21591. if (isSymbol(value)) {
  21592. return symbolToString ? symbolToString.call(value) : '';
  21593. }
  21594. var result = (value + '');
  21595. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  21596. }
  21597. /**
  21598. * The base implementation of `_.uniqBy` without support for iteratee shorthands.
  21599. *
  21600. * @private
  21601. * @param {Array} array The array to inspect.
  21602. * @param {Function} [iteratee] The iteratee invoked per element.
  21603. * @param {Function} [comparator] The comparator invoked per element.
  21604. * @returns {Array} Returns the new duplicate free array.
  21605. */
  21606. function baseUniq(array, iteratee, comparator) {
  21607. var index = -1,
  21608. includes = arrayIncludes,
  21609. length = array.length,
  21610. isCommon = true,
  21611. result = [],
  21612. seen = result;
  21613. if (comparator) {
  21614. isCommon = false;
  21615. includes = arrayIncludesWith;
  21616. }
  21617. else if (length >= LARGE_ARRAY_SIZE) {
  21618. var set = iteratee ? null : createSet(array);
  21619. if (set) {
  21620. return setToArray(set);
  21621. }
  21622. isCommon = false;
  21623. includes = cacheHas;
  21624. seen = new SetCache;
  21625. }
  21626. else {
  21627. seen = iteratee ? [] : result;
  21628. }
  21629. outer:
  21630. while (++index < length) {
  21631. var value = array[index],
  21632. computed = iteratee ? iteratee(value) : value;
  21633. value = (comparator || value !== 0) ? value : 0;
  21634. if (isCommon && computed === computed) {
  21635. var seenIndex = seen.length;
  21636. while (seenIndex--) {
  21637. if (seen[seenIndex] === computed) {
  21638. continue outer;
  21639. }
  21640. }
  21641. if (iteratee) {
  21642. seen.push(computed);
  21643. }
  21644. result.push(value);
  21645. }
  21646. else if (!includes(seen, computed, comparator)) {
  21647. if (seen !== result) {
  21648. seen.push(computed);
  21649. }
  21650. result.push(value);
  21651. }
  21652. }
  21653. return result;
  21654. }
  21655. /**
  21656. * The base implementation of `_.unset`.
  21657. *
  21658. * @private
  21659. * @param {Object} object The object to modify.
  21660. * @param {Array|string} path The property path to unset.
  21661. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  21662. */
  21663. function baseUnset(object, path) {
  21664. path = castPath(path, object);
  21665. object = parent(object, path);
  21666. return object == null || delete object[toKey(last(path))];
  21667. }
  21668. /**
  21669. * The base implementation of `_.update`.
  21670. *
  21671. * @private
  21672. * @param {Object} object The object to modify.
  21673. * @param {Array|string} path The path of the property to update.
  21674. * @param {Function} updater The function to produce the updated value.
  21675. * @param {Function} [customizer] The function to customize path creation.
  21676. * @returns {Object} Returns `object`.
  21677. */
  21678. function baseUpdate(object, path, updater, customizer) {
  21679. return baseSet(object, path, updater(baseGet(object, path)), customizer);
  21680. }
  21681. /**
  21682. * The base implementation of methods like `_.dropWhile` and `_.takeWhile`
  21683. * without support for iteratee shorthands.
  21684. *
  21685. * @private
  21686. * @param {Array} array The array to query.
  21687. * @param {Function} predicate The function invoked per iteration.
  21688. * @param {boolean} [isDrop] Specify dropping elements instead of taking them.
  21689. * @param {boolean} [fromRight] Specify iterating from right to left.
  21690. * @returns {Array} Returns the slice of `array`.
  21691. */
  21692. function baseWhile(array, predicate, isDrop, fromRight) {
  21693. var length = array.length,
  21694. index = fromRight ? length : -1;
  21695. while ((fromRight ? index-- : ++index < length) &&
  21696. predicate(array[index], index, array)) {}
  21697. return isDrop
  21698. ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length))
  21699. : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index));
  21700. }
  21701. /**
  21702. * The base implementation of `wrapperValue` which returns the result of
  21703. * performing a sequence of actions on the unwrapped `value`, where each
  21704. * successive action is supplied the return value of the previous.
  21705. *
  21706. * @private
  21707. * @param {*} value The unwrapped value.
  21708. * @param {Array} actions Actions to perform to resolve the unwrapped value.
  21709. * @returns {*} Returns the resolved value.
  21710. */
  21711. function baseWrapperValue(value, actions) {
  21712. var result = value;
  21713. if (result instanceof LazyWrapper) {
  21714. result = result.value();
  21715. }
  21716. return arrayReduce(actions, function(result, action) {
  21717. return action.func.apply(action.thisArg, arrayPush([result], action.args));
  21718. }, result);
  21719. }
  21720. /**
  21721. * The base implementation of methods like `_.xor`, without support for
  21722. * iteratee shorthands, that accepts an array of arrays to inspect.
  21723. *
  21724. * @private
  21725. * @param {Array} arrays The arrays to inspect.
  21726. * @param {Function} [iteratee] The iteratee invoked per element.
  21727. * @param {Function} [comparator] The comparator invoked per element.
  21728. * @returns {Array} Returns the new array of values.
  21729. */
  21730. function baseXor(arrays, iteratee, comparator) {
  21731. var length = arrays.length;
  21732. if (length < 2) {
  21733. return length ? baseUniq(arrays[0]) : [];
  21734. }
  21735. var index = -1,
  21736. result = Array(length);
  21737. while (++index < length) {
  21738. var array = arrays[index],
  21739. othIndex = -1;
  21740. while (++othIndex < length) {
  21741. if (othIndex != index) {
  21742. result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
  21743. }
  21744. }
  21745. }
  21746. return baseUniq(baseFlatten(result, 1), iteratee, comparator);
  21747. }
  21748. /**
  21749. * This base implementation of `_.zipObject` which assigns values using `assignFunc`.
  21750. *
  21751. * @private
  21752. * @param {Array} props The property identifiers.
  21753. * @param {Array} values The property values.
  21754. * @param {Function} assignFunc The function to assign values.
  21755. * @returns {Object} Returns the new object.
  21756. */
  21757. function baseZipObject(props, values, assignFunc) {
  21758. var index = -1,
  21759. length = props.length,
  21760. valsLength = values.length,
  21761. result = {};
  21762. while (++index < length) {
  21763. var value = index < valsLength ? values[index] : undefined;
  21764. assignFunc(result, props[index], value);
  21765. }
  21766. return result;
  21767. }
  21768. /**
  21769. * Casts `value` to an empty array if it's not an array like object.
  21770. *
  21771. * @private
  21772. * @param {*} value The value to inspect.
  21773. * @returns {Array|Object} Returns the cast array-like object.
  21774. */
  21775. function castArrayLikeObject(value) {
  21776. return isArrayLikeObject(value) ? value : [];
  21777. }
  21778. /**
  21779. * Casts `value` to `identity` if it's not a function.
  21780. *
  21781. * @private
  21782. * @param {*} value The value to inspect.
  21783. * @returns {Function} Returns cast function.
  21784. */
  21785. function castFunction(value) {
  21786. return typeof value == 'function' ? value : identity;
  21787. }
  21788. /**
  21789. * Casts `value` to a path array if it's not one.
  21790. *
  21791. * @private
  21792. * @param {*} value The value to inspect.
  21793. * @param {Object} [object] The object to query keys on.
  21794. * @returns {Array} Returns the cast property path array.
  21795. */
  21796. function castPath(value, object) {
  21797. if (isArray(value)) {
  21798. return value;
  21799. }
  21800. return isKey(value, object) ? [value] : stringToPath(toString(value));
  21801. }
  21802. /**
  21803. * A `baseRest` alias which can be replaced with `identity` by module
  21804. * replacement plugins.
  21805. *
  21806. * @private
  21807. * @type {Function}
  21808. * @param {Function} func The function to apply a rest parameter to.
  21809. * @returns {Function} Returns the new function.
  21810. */
  21811. var castRest = baseRest;
  21812. /**
  21813. * Casts `array` to a slice if it's needed.
  21814. *
  21815. * @private
  21816. * @param {Array} array The array to inspect.
  21817. * @param {number} start The start position.
  21818. * @param {number} [end=array.length] The end position.
  21819. * @returns {Array} Returns the cast slice.
  21820. */
  21821. function castSlice(array, start, end) {
  21822. var length = array.length;
  21823. end = end === undefined ? length : end;
  21824. return (!start && end >= length) ? array : baseSlice(array, start, end);
  21825. }
  21826. /**
  21827. * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
  21828. *
  21829. * @private
  21830. * @param {number|Object} id The timer id or timeout object of the timer to clear.
  21831. */
  21832. var clearTimeout = ctxClearTimeout || function(id) {
  21833. return root.clearTimeout(id);
  21834. };
  21835. /**
  21836. * Creates a clone of `buffer`.
  21837. *
  21838. * @private
  21839. * @param {Buffer} buffer The buffer to clone.
  21840. * @param {boolean} [isDeep] Specify a deep clone.
  21841. * @returns {Buffer} Returns the cloned buffer.
  21842. */
  21843. function cloneBuffer(buffer, isDeep) {
  21844. if (isDeep) {
  21845. return buffer.slice();
  21846. }
  21847. var length = buffer.length,
  21848. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  21849. buffer.copy(result);
  21850. return result;
  21851. }
  21852. /**
  21853. * Creates a clone of `arrayBuffer`.
  21854. *
  21855. * @private
  21856. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  21857. * @returns {ArrayBuffer} Returns the cloned array buffer.
  21858. */
  21859. function cloneArrayBuffer(arrayBuffer) {
  21860. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  21861. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  21862. return result;
  21863. }
  21864. /**
  21865. * Creates a clone of `dataView`.
  21866. *
  21867. * @private
  21868. * @param {Object} dataView The data view to clone.
  21869. * @param {boolean} [isDeep] Specify a deep clone.
  21870. * @returns {Object} Returns the cloned data view.
  21871. */
  21872. function cloneDataView(dataView, isDeep) {
  21873. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  21874. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  21875. }
  21876. /**
  21877. * Creates a clone of `regexp`.
  21878. *
  21879. * @private
  21880. * @param {Object} regexp The regexp to clone.
  21881. * @returns {Object} Returns the cloned regexp.
  21882. */
  21883. function cloneRegExp(regexp) {
  21884. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  21885. result.lastIndex = regexp.lastIndex;
  21886. return result;
  21887. }
  21888. /**
  21889. * Creates a clone of the `symbol` object.
  21890. *
  21891. * @private
  21892. * @param {Object} symbol The symbol object to clone.
  21893. * @returns {Object} Returns the cloned symbol object.
  21894. */
  21895. function cloneSymbol(symbol) {
  21896. return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
  21897. }
  21898. /**
  21899. * Creates a clone of `typedArray`.
  21900. *
  21901. * @private
  21902. * @param {Object} typedArray The typed array to clone.
  21903. * @param {boolean} [isDeep] Specify a deep clone.
  21904. * @returns {Object} Returns the cloned typed array.
  21905. */
  21906. function cloneTypedArray(typedArray, isDeep) {
  21907. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  21908. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  21909. }
  21910. /**
  21911. * Compares values to sort them in ascending order.
  21912. *
  21913. * @private
  21914. * @param {*} value The value to compare.
  21915. * @param {*} other The other value to compare.
  21916. * @returns {number} Returns the sort order indicator for `value`.
  21917. */
  21918. function compareAscending(value, other) {
  21919. if (value !== other) {
  21920. var valIsDefined = value !== undefined,
  21921. valIsNull = value === null,
  21922. valIsReflexive = value === value,
  21923. valIsSymbol = isSymbol(value);
  21924. var othIsDefined = other !== undefined,
  21925. othIsNull = other === null,
  21926. othIsReflexive = other === other,
  21927. othIsSymbol = isSymbol(other);
  21928. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  21929. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  21930. (valIsNull && othIsDefined && othIsReflexive) ||
  21931. (!valIsDefined && othIsReflexive) ||
  21932. !valIsReflexive) {
  21933. return 1;
  21934. }
  21935. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  21936. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  21937. (othIsNull && valIsDefined && valIsReflexive) ||
  21938. (!othIsDefined && valIsReflexive) ||
  21939. !othIsReflexive) {
  21940. return -1;
  21941. }
  21942. }
  21943. return 0;
  21944. }
  21945. /**
  21946. * Used by `_.orderBy` to compare multiple properties of a value to another
  21947. * and stable sort them.
  21948. *
  21949. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  21950. * specify an order of "desc" for descending or "asc" for ascending sort order
  21951. * of corresponding values.
  21952. *
  21953. * @private
  21954. * @param {Object} object The object to compare.
  21955. * @param {Object} other The other object to compare.
  21956. * @param {boolean[]|string[]} orders The order to sort by for each property.
  21957. * @returns {number} Returns the sort order indicator for `object`.
  21958. */
  21959. function compareMultiple(object, other, orders) {
  21960. var index = -1,
  21961. objCriteria = object.criteria,
  21962. othCriteria = other.criteria,
  21963. length = objCriteria.length,
  21964. ordersLength = orders.length;
  21965. while (++index < length) {
  21966. var result = compareAscending(objCriteria[index], othCriteria[index]);
  21967. if (result) {
  21968. if (index >= ordersLength) {
  21969. return result;
  21970. }
  21971. var order = orders[index];
  21972. return result * (order == 'desc' ? -1 : 1);
  21973. }
  21974. }
  21975. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  21976. // that causes it, under certain circumstances, to provide the same value for
  21977. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  21978. // for more details.
  21979. //
  21980. // This also ensures a stable sort in V8 and other engines.
  21981. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  21982. return object.index - other.index;
  21983. }
  21984. /**
  21985. * Creates an array that is the composition of partially applied arguments,
  21986. * placeholders, and provided arguments into a single array of arguments.
  21987. *
  21988. * @private
  21989. * @param {Array} args The provided arguments.
  21990. * @param {Array} partials The arguments to prepend to those provided.
  21991. * @param {Array} holders The `partials` placeholder indexes.
  21992. * @params {boolean} [isCurried] Specify composing for a curried function.
  21993. * @returns {Array} Returns the new array of composed arguments.
  21994. */
  21995. function composeArgs(args, partials, holders, isCurried) {
  21996. var argsIndex = -1,
  21997. argsLength = args.length,
  21998. holdersLength = holders.length,
  21999. leftIndex = -1,
  22000. leftLength = partials.length,
  22001. rangeLength = nativeMax(argsLength - holdersLength, 0),
  22002. result = Array(leftLength + rangeLength),
  22003. isUncurried = !isCurried;
  22004. while (++leftIndex < leftLength) {
  22005. result[leftIndex] = partials[leftIndex];
  22006. }
  22007. while (++argsIndex < holdersLength) {
  22008. if (isUncurried || argsIndex < argsLength) {
  22009. result[holders[argsIndex]] = args[argsIndex];
  22010. }
  22011. }
  22012. while (rangeLength--) {
  22013. result[leftIndex++] = args[argsIndex++];
  22014. }
  22015. return result;
  22016. }
  22017. /**
  22018. * This function is like `composeArgs` except that the arguments composition
  22019. * is tailored for `_.partialRight`.
  22020. *
  22021. * @private
  22022. * @param {Array} args The provided arguments.
  22023. * @param {Array} partials The arguments to append to those provided.
  22024. * @param {Array} holders The `partials` placeholder indexes.
  22025. * @params {boolean} [isCurried] Specify composing for a curried function.
  22026. * @returns {Array} Returns the new array of composed arguments.
  22027. */
  22028. function composeArgsRight(args, partials, holders, isCurried) {
  22029. var argsIndex = -1,
  22030. argsLength = args.length,
  22031. holdersIndex = -1,
  22032. holdersLength = holders.length,
  22033. rightIndex = -1,
  22034. rightLength = partials.length,
  22035. rangeLength = nativeMax(argsLength - holdersLength, 0),
  22036. result = Array(rangeLength + rightLength),
  22037. isUncurried = !isCurried;
  22038. while (++argsIndex < rangeLength) {
  22039. result[argsIndex] = args[argsIndex];
  22040. }
  22041. var offset = argsIndex;
  22042. while (++rightIndex < rightLength) {
  22043. result[offset + rightIndex] = partials[rightIndex];
  22044. }
  22045. while (++holdersIndex < holdersLength) {
  22046. if (isUncurried || argsIndex < argsLength) {
  22047. result[offset + holders[holdersIndex]] = args[argsIndex++];
  22048. }
  22049. }
  22050. return result;
  22051. }
  22052. /**
  22053. * Copies the values of `source` to `array`.
  22054. *
  22055. * @private
  22056. * @param {Array} source The array to copy values from.
  22057. * @param {Array} [array=[]] The array to copy values to.
  22058. * @returns {Array} Returns `array`.
  22059. */
  22060. function copyArray(source, array) {
  22061. var index = -1,
  22062. length = source.length;
  22063. array || (array = Array(length));
  22064. while (++index < length) {
  22065. array[index] = source[index];
  22066. }
  22067. return array;
  22068. }
  22069. /**
  22070. * Copies properties of `source` to `object`.
  22071. *
  22072. * @private
  22073. * @param {Object} source The object to copy properties from.
  22074. * @param {Array} props The property identifiers to copy.
  22075. * @param {Object} [object={}] The object to copy properties to.
  22076. * @param {Function} [customizer] The function to customize copied values.
  22077. * @returns {Object} Returns `object`.
  22078. */
  22079. function copyObject(source, props, object, customizer) {
  22080. var isNew = !object;
  22081. object || (object = {});
  22082. var index = -1,
  22083. length = props.length;
  22084. while (++index < length) {
  22085. var key = props[index];
  22086. var newValue = customizer
  22087. ? customizer(object[key], source[key], key, object, source)
  22088. : undefined;
  22089. if (newValue === undefined) {
  22090. newValue = source[key];
  22091. }
  22092. if (isNew) {
  22093. baseAssignValue(object, key, newValue);
  22094. } else {
  22095. assignValue(object, key, newValue);
  22096. }
  22097. }
  22098. return object;
  22099. }
  22100. /**
  22101. * Copies own symbols of `source` to `object`.
  22102. *
  22103. * @private
  22104. * @param {Object} source The object to copy symbols from.
  22105. * @param {Object} [object={}] The object to copy symbols to.
  22106. * @returns {Object} Returns `object`.
  22107. */
  22108. function copySymbols(source, object) {
  22109. return copyObject(source, getSymbols(source), object);
  22110. }
  22111. /**
  22112. * Copies own and inherited symbols of `source` to `object`.
  22113. *
  22114. * @private
  22115. * @param {Object} source The object to copy symbols from.
  22116. * @param {Object} [object={}] The object to copy symbols to.
  22117. * @returns {Object} Returns `object`.
  22118. */
  22119. function copySymbolsIn(source, object) {
  22120. return copyObject(source, getSymbolsIn(source), object);
  22121. }
  22122. /**
  22123. * Creates a function like `_.groupBy`.
  22124. *
  22125. * @private
  22126. * @param {Function} setter The function to set accumulator values.
  22127. * @param {Function} [initializer] The accumulator object initializer.
  22128. * @returns {Function} Returns the new aggregator function.
  22129. */
  22130. function createAggregator(setter, initializer) {
  22131. return function(collection, iteratee) {
  22132. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  22133. accumulator = initializer ? initializer() : {};
  22134. return func(collection, setter, getIteratee(iteratee, 2), accumulator);
  22135. };
  22136. }
  22137. /**
  22138. * Creates a function like `_.assign`.
  22139. *
  22140. * @private
  22141. * @param {Function} assigner The function to assign values.
  22142. * @returns {Function} Returns the new assigner function.
  22143. */
  22144. function createAssigner(assigner) {
  22145. return baseRest(function(object, sources) {
  22146. var index = -1,
  22147. length = sources.length,
  22148. customizer = length > 1 ? sources[length - 1] : undefined,
  22149. guard = length > 2 ? sources[2] : undefined;
  22150. customizer = (assigner.length > 3 && typeof customizer == 'function')
  22151. ? (length--, customizer)
  22152. : undefined;
  22153. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  22154. customizer = length < 3 ? undefined : customizer;
  22155. length = 1;
  22156. }
  22157. object = Object(object);
  22158. while (++index < length) {
  22159. var source = sources[index];
  22160. if (source) {
  22161. assigner(object, source, index, customizer);
  22162. }
  22163. }
  22164. return object;
  22165. });
  22166. }
  22167. /**
  22168. * Creates a `baseEach` or `baseEachRight` function.
  22169. *
  22170. * @private
  22171. * @param {Function} eachFunc The function to iterate over a collection.
  22172. * @param {boolean} [fromRight] Specify iterating from right to left.
  22173. * @returns {Function} Returns the new base function.
  22174. */
  22175. function createBaseEach(eachFunc, fromRight) {
  22176. return function(collection, iteratee) {
  22177. if (collection == null) {
  22178. return collection;
  22179. }
  22180. if (!isArrayLike(collection)) {
  22181. return eachFunc(collection, iteratee);
  22182. }
  22183. var length = collection.length,
  22184. index = fromRight ? length : -1,
  22185. iterable = Object(collection);
  22186. while ((fromRight ? index-- : ++index < length)) {
  22187. if (iteratee(iterable[index], index, iterable) === false) {
  22188. break;
  22189. }
  22190. }
  22191. return collection;
  22192. };
  22193. }
  22194. /**
  22195. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  22196. *
  22197. * @private
  22198. * @param {boolean} [fromRight] Specify iterating from right to left.
  22199. * @returns {Function} Returns the new base function.
  22200. */
  22201. function createBaseFor(fromRight) {
  22202. return function(object, iteratee, keysFunc) {
  22203. var index = -1,
  22204. iterable = Object(object),
  22205. props = keysFunc(object),
  22206. length = props.length;
  22207. while (length--) {
  22208. var key = props[fromRight ? length : ++index];
  22209. if (iteratee(iterable[key], key, iterable) === false) {
  22210. break;
  22211. }
  22212. }
  22213. return object;
  22214. };
  22215. }
  22216. /**
  22217. * Creates a function that wraps `func` to invoke it with the optional `this`
  22218. * binding of `thisArg`.
  22219. *
  22220. * @private
  22221. * @param {Function} func The function to wrap.
  22222. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22223. * @param {*} [thisArg] The `this` binding of `func`.
  22224. * @returns {Function} Returns the new wrapped function.
  22225. */
  22226. function createBind(func, bitmask, thisArg) {
  22227. var isBind = bitmask & WRAP_BIND_FLAG,
  22228. Ctor = createCtor(func);
  22229. function wrapper() {
  22230. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22231. return fn.apply(isBind ? thisArg : this, arguments);
  22232. }
  22233. return wrapper;
  22234. }
  22235. /**
  22236. * Creates a function like `_.lowerFirst`.
  22237. *
  22238. * @private
  22239. * @param {string} methodName The name of the `String` case method to use.
  22240. * @returns {Function} Returns the new case function.
  22241. */
  22242. function createCaseFirst(methodName) {
  22243. return function(string) {
  22244. string = toString(string);
  22245. var strSymbols = hasUnicode(string)
  22246. ? stringToArray(string)
  22247. : undefined;
  22248. var chr = strSymbols
  22249. ? strSymbols[0]
  22250. : string.charAt(0);
  22251. var trailing = strSymbols
  22252. ? castSlice(strSymbols, 1).join('')
  22253. : string.slice(1);
  22254. return chr[methodName]() + trailing;
  22255. };
  22256. }
  22257. /**
  22258. * Creates a function like `_.camelCase`.
  22259. *
  22260. * @private
  22261. * @param {Function} callback The function to combine each word.
  22262. * @returns {Function} Returns the new compounder function.
  22263. */
  22264. function createCompounder(callback) {
  22265. return function(string) {
  22266. return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
  22267. };
  22268. }
  22269. /**
  22270. * Creates a function that produces an instance of `Ctor` regardless of
  22271. * whether it was invoked as part of a `new` expression or by `call` or `apply`.
  22272. *
  22273. * @private
  22274. * @param {Function} Ctor The constructor to wrap.
  22275. * @returns {Function} Returns the new wrapped function.
  22276. */
  22277. function createCtor(Ctor) {
  22278. return function() {
  22279. // Use a `switch` statement to work with class constructors. See
  22280. // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
  22281. // for more details.
  22282. var args = arguments;
  22283. switch (args.length) {
  22284. case 0: return new Ctor;
  22285. case 1: return new Ctor(args[0]);
  22286. case 2: return new Ctor(args[0], args[1]);
  22287. case 3: return new Ctor(args[0], args[1], args[2]);
  22288. case 4: return new Ctor(args[0], args[1], args[2], args[3]);
  22289. case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
  22290. case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
  22291. case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
  22292. }
  22293. var thisBinding = baseCreate(Ctor.prototype),
  22294. result = Ctor.apply(thisBinding, args);
  22295. // Mimic the constructor's `return` behavior.
  22296. // See https://es5.github.io/#x13.2.2 for more details.
  22297. return isObject(result) ? result : thisBinding;
  22298. };
  22299. }
  22300. /**
  22301. * Creates a function that wraps `func` to enable currying.
  22302. *
  22303. * @private
  22304. * @param {Function} func The function to wrap.
  22305. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22306. * @param {number} arity The arity of `func`.
  22307. * @returns {Function} Returns the new wrapped function.
  22308. */
  22309. function createCurry(func, bitmask, arity) {
  22310. var Ctor = createCtor(func);
  22311. function wrapper() {
  22312. var length = arguments.length,
  22313. args = Array(length),
  22314. index = length,
  22315. placeholder = getHolder(wrapper);
  22316. while (index--) {
  22317. args[index] = arguments[index];
  22318. }
  22319. var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
  22320. ? []
  22321. : replaceHolders(args, placeholder);
  22322. length -= holders.length;
  22323. if (length < arity) {
  22324. return createRecurry(
  22325. func, bitmask, createHybrid, wrapper.placeholder, undefined,
  22326. args, holders, undefined, undefined, arity - length);
  22327. }
  22328. var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22329. return apply(fn, this, args);
  22330. }
  22331. return wrapper;
  22332. }
  22333. /**
  22334. * Creates a `_.find` or `_.findLast` function.
  22335. *
  22336. * @private
  22337. * @param {Function} findIndexFunc The function to find the collection index.
  22338. * @returns {Function} Returns the new find function.
  22339. */
  22340. function createFind(findIndexFunc) {
  22341. return function(collection, predicate, fromIndex) {
  22342. var iterable = Object(collection);
  22343. if (!isArrayLike(collection)) {
  22344. var iteratee = getIteratee(predicate, 3);
  22345. collection = keys(collection);
  22346. predicate = function(key) { return iteratee(iterable[key], key, iterable); };
  22347. }
  22348. var index = findIndexFunc(collection, predicate, fromIndex);
  22349. return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
  22350. };
  22351. }
  22352. /**
  22353. * Creates a `_.flow` or `_.flowRight` function.
  22354. *
  22355. * @private
  22356. * @param {boolean} [fromRight] Specify iterating from right to left.
  22357. * @returns {Function} Returns the new flow function.
  22358. */
  22359. function createFlow(fromRight) {
  22360. return flatRest(function(funcs) {
  22361. var length = funcs.length,
  22362. index = length,
  22363. prereq = LodashWrapper.prototype.thru;
  22364. if (fromRight) {
  22365. funcs.reverse();
  22366. }
  22367. while (index--) {
  22368. var func = funcs[index];
  22369. if (typeof func != 'function') {
  22370. throw new TypeError(FUNC_ERROR_TEXT);
  22371. }
  22372. if (prereq && !wrapper && getFuncName(func) == 'wrapper') {
  22373. var wrapper = new LodashWrapper([], true);
  22374. }
  22375. }
  22376. index = wrapper ? index : length;
  22377. while (++index < length) {
  22378. func = funcs[index];
  22379. var funcName = getFuncName(func),
  22380. data = funcName == 'wrapper' ? getData(func) : undefined;
  22381. if (data && isLaziable(data[0]) &&
  22382. data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
  22383. !data[4].length && data[9] == 1
  22384. ) {
  22385. wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
  22386. } else {
  22387. wrapper = (func.length == 1 && isLaziable(func))
  22388. ? wrapper[funcName]()
  22389. : wrapper.thru(func);
  22390. }
  22391. }
  22392. return function() {
  22393. var args = arguments,
  22394. value = args[0];
  22395. if (wrapper && args.length == 1 && isArray(value)) {
  22396. return wrapper.plant(value).value();
  22397. }
  22398. var index = 0,
  22399. result = length ? funcs[index].apply(this, args) : value;
  22400. while (++index < length) {
  22401. result = funcs[index].call(this, result);
  22402. }
  22403. return result;
  22404. };
  22405. });
  22406. }
  22407. /**
  22408. * Creates a function that wraps `func` to invoke it with optional `this`
  22409. * binding of `thisArg`, partial application, and currying.
  22410. *
  22411. * @private
  22412. * @param {Function|string} func The function or method name to wrap.
  22413. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22414. * @param {*} [thisArg] The `this` binding of `func`.
  22415. * @param {Array} [partials] The arguments to prepend to those provided to
  22416. * the new function.
  22417. * @param {Array} [holders] The `partials` placeholder indexes.
  22418. * @param {Array} [partialsRight] The arguments to append to those provided
  22419. * to the new function.
  22420. * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
  22421. * @param {Array} [argPos] The argument positions of the new function.
  22422. * @param {number} [ary] The arity cap of `func`.
  22423. * @param {number} [arity] The arity of `func`.
  22424. * @returns {Function} Returns the new wrapped function.
  22425. */
  22426. function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
  22427. var isAry = bitmask & WRAP_ARY_FLAG,
  22428. isBind = bitmask & WRAP_BIND_FLAG,
  22429. isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
  22430. isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
  22431. isFlip = bitmask & WRAP_FLIP_FLAG,
  22432. Ctor = isBindKey ? undefined : createCtor(func);
  22433. function wrapper() {
  22434. var length = arguments.length,
  22435. args = Array(length),
  22436. index = length;
  22437. while (index--) {
  22438. args[index] = arguments[index];
  22439. }
  22440. if (isCurried) {
  22441. var placeholder = getHolder(wrapper),
  22442. holdersCount = countHolders(args, placeholder);
  22443. }
  22444. if (partials) {
  22445. args = composeArgs(args, partials, holders, isCurried);
  22446. }
  22447. if (partialsRight) {
  22448. args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
  22449. }
  22450. length -= holdersCount;
  22451. if (isCurried && length < arity) {
  22452. var newHolders = replaceHolders(args, placeholder);
  22453. return createRecurry(
  22454. func, bitmask, createHybrid, wrapper.placeholder, thisArg,
  22455. args, newHolders, argPos, ary, arity - length
  22456. );
  22457. }
  22458. var thisBinding = isBind ? thisArg : this,
  22459. fn = isBindKey ? thisBinding[func] : func;
  22460. length = args.length;
  22461. if (argPos) {
  22462. args = reorder(args, argPos);
  22463. } else if (isFlip && length > 1) {
  22464. args.reverse();
  22465. }
  22466. if (isAry && ary < length) {
  22467. args.length = ary;
  22468. }
  22469. if (this && this !== root && this instanceof wrapper) {
  22470. fn = Ctor || createCtor(fn);
  22471. }
  22472. return fn.apply(thisBinding, args);
  22473. }
  22474. return wrapper;
  22475. }
  22476. /**
  22477. * Creates a function like `_.invertBy`.
  22478. *
  22479. * @private
  22480. * @param {Function} setter The function to set accumulator values.
  22481. * @param {Function} toIteratee The function to resolve iteratees.
  22482. * @returns {Function} Returns the new inverter function.
  22483. */
  22484. function createInverter(setter, toIteratee) {
  22485. return function(object, iteratee) {
  22486. return baseInverter(object, setter, toIteratee(iteratee), {});
  22487. };
  22488. }
  22489. /**
  22490. * Creates a function that performs a mathematical operation on two values.
  22491. *
  22492. * @private
  22493. * @param {Function} operator The function to perform the operation.
  22494. * @param {number} [defaultValue] The value used for `undefined` arguments.
  22495. * @returns {Function} Returns the new mathematical operation function.
  22496. */
  22497. function createMathOperation(operator, defaultValue) {
  22498. return function(value, other) {
  22499. var result;
  22500. if (value === undefined && other === undefined) {
  22501. return defaultValue;
  22502. }
  22503. if (value !== undefined) {
  22504. result = value;
  22505. }
  22506. if (other !== undefined) {
  22507. if (result === undefined) {
  22508. return other;
  22509. }
  22510. if (typeof value == 'string' || typeof other == 'string') {
  22511. value = baseToString(value);
  22512. other = baseToString(other);
  22513. } else {
  22514. value = baseToNumber(value);
  22515. other = baseToNumber(other);
  22516. }
  22517. result = operator(value, other);
  22518. }
  22519. return result;
  22520. };
  22521. }
  22522. /**
  22523. * Creates a function like `_.over`.
  22524. *
  22525. * @private
  22526. * @param {Function} arrayFunc The function to iterate over iteratees.
  22527. * @returns {Function} Returns the new over function.
  22528. */
  22529. function createOver(arrayFunc) {
  22530. return flatRest(function(iteratees) {
  22531. iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
  22532. return baseRest(function(args) {
  22533. var thisArg = this;
  22534. return arrayFunc(iteratees, function(iteratee) {
  22535. return apply(iteratee, thisArg, args);
  22536. });
  22537. });
  22538. });
  22539. }
  22540. /**
  22541. * Creates the padding for `string` based on `length`. The `chars` string
  22542. * is truncated if the number of characters exceeds `length`.
  22543. *
  22544. * @private
  22545. * @param {number} length The padding length.
  22546. * @param {string} [chars=' '] The string used as padding.
  22547. * @returns {string} Returns the padding for `string`.
  22548. */
  22549. function createPadding(length, chars) {
  22550. chars = chars === undefined ? ' ' : baseToString(chars);
  22551. var charsLength = chars.length;
  22552. if (charsLength < 2) {
  22553. return charsLength ? baseRepeat(chars, length) : chars;
  22554. }
  22555. var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
  22556. return hasUnicode(chars)
  22557. ? castSlice(stringToArray(result), 0, length).join('')
  22558. : result.slice(0, length);
  22559. }
  22560. /**
  22561. * Creates a function that wraps `func` to invoke it with the `this` binding
  22562. * of `thisArg` and `partials` prepended to the arguments it receives.
  22563. *
  22564. * @private
  22565. * @param {Function} func The function to wrap.
  22566. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22567. * @param {*} thisArg The `this` binding of `func`.
  22568. * @param {Array} partials The arguments to prepend to those provided to
  22569. * the new function.
  22570. * @returns {Function} Returns the new wrapped function.
  22571. */
  22572. function createPartial(func, bitmask, thisArg, partials) {
  22573. var isBind = bitmask & WRAP_BIND_FLAG,
  22574. Ctor = createCtor(func);
  22575. function wrapper() {
  22576. var argsIndex = -1,
  22577. argsLength = arguments.length,
  22578. leftIndex = -1,
  22579. leftLength = partials.length,
  22580. args = Array(leftLength + argsLength),
  22581. fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
  22582. while (++leftIndex < leftLength) {
  22583. args[leftIndex] = partials[leftIndex];
  22584. }
  22585. while (argsLength--) {
  22586. args[leftIndex++] = arguments[++argsIndex];
  22587. }
  22588. return apply(fn, isBind ? thisArg : this, args);
  22589. }
  22590. return wrapper;
  22591. }
  22592. /**
  22593. * Creates a `_.range` or `_.rangeRight` function.
  22594. *
  22595. * @private
  22596. * @param {boolean} [fromRight] Specify iterating from right to left.
  22597. * @returns {Function} Returns the new range function.
  22598. */
  22599. function createRange(fromRight) {
  22600. return function(start, end, step) {
  22601. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  22602. end = step = undefined;
  22603. }
  22604. // Ensure the sign of `-0` is preserved.
  22605. start = toFinite(start);
  22606. if (end === undefined) {
  22607. end = start;
  22608. start = 0;
  22609. } else {
  22610. end = toFinite(end);
  22611. }
  22612. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  22613. return baseRange(start, end, step, fromRight);
  22614. };
  22615. }
  22616. /**
  22617. * Creates a function that performs a relational operation on two values.
  22618. *
  22619. * @private
  22620. * @param {Function} operator The function to perform the operation.
  22621. * @returns {Function} Returns the new relational operation function.
  22622. */
  22623. function createRelationalOperation(operator) {
  22624. return function(value, other) {
  22625. if (!(typeof value == 'string' && typeof other == 'string')) {
  22626. value = toNumber(value);
  22627. other = toNumber(other);
  22628. }
  22629. return operator(value, other);
  22630. };
  22631. }
  22632. /**
  22633. * Creates a function that wraps `func` to continue currying.
  22634. *
  22635. * @private
  22636. * @param {Function} func The function to wrap.
  22637. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  22638. * @param {Function} wrapFunc The function to create the `func` wrapper.
  22639. * @param {*} placeholder The placeholder value.
  22640. * @param {*} [thisArg] The `this` binding of `func`.
  22641. * @param {Array} [partials] The arguments to prepend to those provided to
  22642. * the new function.
  22643. * @param {Array} [holders] The `partials` placeholder indexes.
  22644. * @param {Array} [argPos] The argument positions of the new function.
  22645. * @param {number} [ary] The arity cap of `func`.
  22646. * @param {number} [arity] The arity of `func`.
  22647. * @returns {Function} Returns the new wrapped function.
  22648. */
  22649. function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
  22650. var isCurry = bitmask & WRAP_CURRY_FLAG,
  22651. newHolders = isCurry ? holders : undefined,
  22652. newHoldersRight = isCurry ? undefined : holders,
  22653. newPartials = isCurry ? partials : undefined,
  22654. newPartialsRight = isCurry ? undefined : partials;
  22655. bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
  22656. bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
  22657. if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
  22658. bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
  22659. }
  22660. var newData = [
  22661. func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
  22662. newHoldersRight, argPos, ary, arity
  22663. ];
  22664. var result = wrapFunc.apply(undefined, newData);
  22665. if (isLaziable(func)) {
  22666. setData(result, newData);
  22667. }
  22668. result.placeholder = placeholder;
  22669. return setWrapToString(result, func, bitmask);
  22670. }
  22671. /**
  22672. * Creates a function like `_.round`.
  22673. *
  22674. * @private
  22675. * @param {string} methodName The name of the `Math` method to use when rounding.
  22676. * @returns {Function} Returns the new round function.
  22677. */
  22678. function createRound(methodName) {
  22679. var func = Math[methodName];
  22680. return function(number, precision) {
  22681. number = toNumber(number);
  22682. precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
  22683. if (precision && nativeIsFinite(number)) {
  22684. // Shift with exponential notation to avoid floating-point issues.
  22685. // See [MDN](https://mdn.io/round#Examples) for more details.
  22686. var pair = (toString(number) + 'e').split('e'),
  22687. value = func(pair[0] + 'e' + (+pair[1] + precision));
  22688. pair = (toString(value) + 'e').split('e');
  22689. return +(pair[0] + 'e' + (+pair[1] - precision));
  22690. }
  22691. return func(number);
  22692. };
  22693. }
  22694. /**
  22695. * Creates a set object of `values`.
  22696. *
  22697. * @private
  22698. * @param {Array} values The values to add to the set.
  22699. * @returns {Object} Returns the new set.
  22700. */
  22701. var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
  22702. return new Set(values);
  22703. };
  22704. /**
  22705. * Creates a `_.toPairs` or `_.toPairsIn` function.
  22706. *
  22707. * @private
  22708. * @param {Function} keysFunc The function to get the keys of a given object.
  22709. * @returns {Function} Returns the new pairs function.
  22710. */
  22711. function createToPairs(keysFunc) {
  22712. return function(object) {
  22713. var tag = getTag(object);
  22714. if (tag == mapTag) {
  22715. return mapToArray(object);
  22716. }
  22717. if (tag == setTag) {
  22718. return setToPairs(object);
  22719. }
  22720. return baseToPairs(object, keysFunc(object));
  22721. };
  22722. }
  22723. /**
  22724. * Creates a function that either curries or invokes `func` with optional
  22725. * `this` binding and partially applied arguments.
  22726. *
  22727. * @private
  22728. * @param {Function|string} func The function or method name to wrap.
  22729. * @param {number} bitmask The bitmask flags.
  22730. * 1 - `_.bind`
  22731. * 2 - `_.bindKey`
  22732. * 4 - `_.curry` or `_.curryRight` of a bound function
  22733. * 8 - `_.curry`
  22734. * 16 - `_.curryRight`
  22735. * 32 - `_.partial`
  22736. * 64 - `_.partialRight`
  22737. * 128 - `_.rearg`
  22738. * 256 - `_.ary`
  22739. * 512 - `_.flip`
  22740. * @param {*} [thisArg] The `this` binding of `func`.
  22741. * @param {Array} [partials] The arguments to be partially applied.
  22742. * @param {Array} [holders] The `partials` placeholder indexes.
  22743. * @param {Array} [argPos] The argument positions of the new function.
  22744. * @param {number} [ary] The arity cap of `func`.
  22745. * @param {number} [arity] The arity of `func`.
  22746. * @returns {Function} Returns the new wrapped function.
  22747. */
  22748. function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
  22749. var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
  22750. if (!isBindKey && typeof func != 'function') {
  22751. throw new TypeError(FUNC_ERROR_TEXT);
  22752. }
  22753. var length = partials ? partials.length : 0;
  22754. if (!length) {
  22755. bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
  22756. partials = holders = undefined;
  22757. }
  22758. ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
  22759. arity = arity === undefined ? arity : toInteger(arity);
  22760. length -= holders ? holders.length : 0;
  22761. if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
  22762. var partialsRight = partials,
  22763. holdersRight = holders;
  22764. partials = holders = undefined;
  22765. }
  22766. var data = isBindKey ? undefined : getData(func);
  22767. var newData = [
  22768. func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
  22769. argPos, ary, arity
  22770. ];
  22771. if (data) {
  22772. mergeData(newData, data);
  22773. }
  22774. func = newData[0];
  22775. bitmask = newData[1];
  22776. thisArg = newData[2];
  22777. partials = newData[3];
  22778. holders = newData[4];
  22779. arity = newData[9] = newData[9] === undefined
  22780. ? (isBindKey ? 0 : func.length)
  22781. : nativeMax(newData[9] - length, 0);
  22782. if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
  22783. bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
  22784. }
  22785. if (!bitmask || bitmask == WRAP_BIND_FLAG) {
  22786. var result = createBind(func, bitmask, thisArg);
  22787. } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
  22788. result = createCurry(func, bitmask, arity);
  22789. } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
  22790. result = createPartial(func, bitmask, thisArg, partials);
  22791. } else {
  22792. result = createHybrid.apply(undefined, newData);
  22793. }
  22794. var setter = data ? baseSetData : setData;
  22795. return setWrapToString(setter(result, newData), func, bitmask);
  22796. }
  22797. /**
  22798. * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
  22799. * of source objects to the destination object for all destination properties
  22800. * that resolve to `undefined`.
  22801. *
  22802. * @private
  22803. * @param {*} objValue The destination value.
  22804. * @param {*} srcValue The source value.
  22805. * @param {string} key The key of the property to assign.
  22806. * @param {Object} object The parent object of `objValue`.
  22807. * @returns {*} Returns the value to assign.
  22808. */
  22809. function customDefaultsAssignIn(objValue, srcValue, key, object) {
  22810. if (objValue === undefined ||
  22811. (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  22812. return srcValue;
  22813. }
  22814. return objValue;
  22815. }
  22816. /**
  22817. * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
  22818. * objects into destination objects that are passed thru.
  22819. *
  22820. * @private
  22821. * @param {*} objValue The destination value.
  22822. * @param {*} srcValue The source value.
  22823. * @param {string} key The key of the property to merge.
  22824. * @param {Object} object The parent object of `objValue`.
  22825. * @param {Object} source The parent object of `srcValue`.
  22826. * @param {Object} [stack] Tracks traversed source values and their merged
  22827. * counterparts.
  22828. * @returns {*} Returns the value to assign.
  22829. */
  22830. function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
  22831. if (isObject(objValue) && isObject(srcValue)) {
  22832. // Recursively merge objects and arrays (susceptible to call stack limits).
  22833. stack.set(srcValue, objValue);
  22834. baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
  22835. stack['delete'](srcValue);
  22836. }
  22837. return objValue;
  22838. }
  22839. /**
  22840. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  22841. * objects.
  22842. *
  22843. * @private
  22844. * @param {*} value The value to inspect.
  22845. * @param {string} key The key of the property to inspect.
  22846. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  22847. */
  22848. function customOmitClone(value) {
  22849. return isPlainObject(value) ? undefined : value;
  22850. }
  22851. /**
  22852. * A specialized version of `baseIsEqualDeep` for arrays with support for
  22853. * partial deep comparisons.
  22854. *
  22855. * @private
  22856. * @param {Array} array The array to compare.
  22857. * @param {Array} other The other array to compare.
  22858. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22859. * @param {Function} customizer The function to customize comparisons.
  22860. * @param {Function} equalFunc The function to determine equivalents of values.
  22861. * @param {Object} stack Tracks traversed `array` and `other` objects.
  22862. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  22863. */
  22864. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  22865. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  22866. arrLength = array.length,
  22867. othLength = other.length;
  22868. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  22869. return false;
  22870. }
  22871. // Assume cyclic values are equal.
  22872. var stacked = stack.get(array);
  22873. if (stacked && stack.get(other)) {
  22874. return stacked == other;
  22875. }
  22876. var index = -1,
  22877. result = true,
  22878. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  22879. stack.set(array, other);
  22880. stack.set(other, array);
  22881. // Ignore non-index properties.
  22882. while (++index < arrLength) {
  22883. var arrValue = array[index],
  22884. othValue = other[index];
  22885. if (customizer) {
  22886. var compared = isPartial
  22887. ? customizer(othValue, arrValue, index, other, array, stack)
  22888. : customizer(arrValue, othValue, index, array, other, stack);
  22889. }
  22890. if (compared !== undefined) {
  22891. if (compared) {
  22892. continue;
  22893. }
  22894. result = false;
  22895. break;
  22896. }
  22897. // Recursively compare arrays (susceptible to call stack limits).
  22898. if (seen) {
  22899. if (!arraySome(other, function(othValue, othIndex) {
  22900. if (!cacheHas(seen, othIndex) &&
  22901. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  22902. return seen.push(othIndex);
  22903. }
  22904. })) {
  22905. result = false;
  22906. break;
  22907. }
  22908. } else if (!(
  22909. arrValue === othValue ||
  22910. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  22911. )) {
  22912. result = false;
  22913. break;
  22914. }
  22915. }
  22916. stack['delete'](array);
  22917. stack['delete'](other);
  22918. return result;
  22919. }
  22920. /**
  22921. * A specialized version of `baseIsEqualDeep` for comparing objects of
  22922. * the same `toStringTag`.
  22923. *
  22924. * **Note:** This function only supports comparing values with tags of
  22925. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  22926. *
  22927. * @private
  22928. * @param {Object} object The object to compare.
  22929. * @param {Object} other The other object to compare.
  22930. * @param {string} tag The `toStringTag` of the objects to compare.
  22931. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  22932. * @param {Function} customizer The function to customize comparisons.
  22933. * @param {Function} equalFunc The function to determine equivalents of values.
  22934. * @param {Object} stack Tracks traversed `object` and `other` objects.
  22935. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  22936. */
  22937. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  22938. switch (tag) {
  22939. case dataViewTag:
  22940. if ((object.byteLength != other.byteLength) ||
  22941. (object.byteOffset != other.byteOffset)) {
  22942. return false;
  22943. }
  22944. object = object.buffer;
  22945. other = other.buffer;
  22946. case arrayBufferTag:
  22947. if ((object.byteLength != other.byteLength) ||
  22948. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  22949. return false;
  22950. }
  22951. return true;
  22952. case boolTag:
  22953. case dateTag:
  22954. case numberTag:
  22955. // Coerce booleans to `1` or `0` and dates to milliseconds.
  22956. // Invalid dates are coerced to `NaN`.
  22957. return eq(+object, +other);
  22958. case errorTag:
  22959. return object.name == other.name && object.message == other.message;
  22960. case regexpTag:
  22961. case stringTag:
  22962. // Coerce regexes to strings and treat strings, primitives and objects,
  22963. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  22964. // for more details.
  22965. return object == (other + '');
  22966. case mapTag:
  22967. var convert = mapToArray;
  22968. case setTag:
  22969. var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
  22970. convert || (convert = setToArray);
  22971. if (object.size != other.size && !isPartial) {
  22972. return false;
  22973. }
  22974. // Assume cyclic values are equal.
  22975. var stacked = stack.get(object);
  22976. if (stacked) {
  22977. return stacked == other;
  22978. }
  22979. bitmask |= COMPARE_UNORDERED_FLAG;
  22980. // Recursively compare objects (susceptible to call stack limits).
  22981. stack.set(object, other);
  22982. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  22983. stack['delete'](object);
  22984. return result;
  22985. case symbolTag:
  22986. if (symbolValueOf) {
  22987. return symbolValueOf.call(object) == symbolValueOf.call(other);
  22988. }
  22989. }
  22990. return false;
  22991. }
  22992. /**
  22993. * A specialized version of `baseIsEqualDeep` for objects with support for
  22994. * partial deep comparisons.
  22995. *
  22996. * @private
  22997. * @param {Object} object The object to compare.
  22998. * @param {Object} other The other object to compare.
  22999. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  23000. * @param {Function} customizer The function to customize comparisons.
  23001. * @param {Function} equalFunc The function to determine equivalents of values.
  23002. * @param {Object} stack Tracks traversed `object` and `other` objects.
  23003. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  23004. */
  23005. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  23006. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  23007. objProps = getAllKeys(object),
  23008. objLength = objProps.length,
  23009. othProps = getAllKeys(other),
  23010. othLength = othProps.length;
  23011. if (objLength != othLength && !isPartial) {
  23012. return false;
  23013. }
  23014. var index = objLength;
  23015. while (index--) {
  23016. var key = objProps[index];
  23017. if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
  23018. return false;
  23019. }
  23020. }
  23021. // Assume cyclic values are equal.
  23022. var stacked = stack.get(object);
  23023. if (stacked && stack.get(other)) {
  23024. return stacked == other;
  23025. }
  23026. var result = true;
  23027. stack.set(object, other);
  23028. stack.set(other, object);
  23029. var skipCtor = isPartial;
  23030. while (++index < objLength) {
  23031. key = objProps[index];
  23032. var objValue = object[key],
  23033. othValue = other[key];
  23034. if (customizer) {
  23035. var compared = isPartial
  23036. ? customizer(othValue, objValue, key, other, object, stack)
  23037. : customizer(objValue, othValue, key, object, other, stack);
  23038. }
  23039. // Recursively compare objects (susceptible to call stack limits).
  23040. if (!(compared === undefined
  23041. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  23042. : compared
  23043. )) {
  23044. result = false;
  23045. break;
  23046. }
  23047. skipCtor || (skipCtor = key == 'constructor');
  23048. }
  23049. if (result && !skipCtor) {
  23050. var objCtor = object.constructor,
  23051. othCtor = other.constructor;
  23052. // Non `Object` object instances with different constructors are not equal.
  23053. if (objCtor != othCtor &&
  23054. ('constructor' in object && 'constructor' in other) &&
  23055. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  23056. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  23057. result = false;
  23058. }
  23059. }
  23060. stack['delete'](object);
  23061. stack['delete'](other);
  23062. return result;
  23063. }
  23064. /**
  23065. * A specialized version of `baseRest` which flattens the rest array.
  23066. *
  23067. * @private
  23068. * @param {Function} func The function to apply a rest parameter to.
  23069. * @returns {Function} Returns the new function.
  23070. */
  23071. function flatRest(func) {
  23072. return setToString(overRest(func, undefined, flatten), func + '');
  23073. }
  23074. /**
  23075. * Creates an array of own enumerable property names and symbols of `object`.
  23076. *
  23077. * @private
  23078. * @param {Object} object The object to query.
  23079. * @returns {Array} Returns the array of property names and symbols.
  23080. */
  23081. function getAllKeys(object) {
  23082. return baseGetAllKeys(object, keys, getSymbols);
  23083. }
  23084. /**
  23085. * Creates an array of own and inherited enumerable property names and
  23086. * symbols of `object`.
  23087. *
  23088. * @private
  23089. * @param {Object} object The object to query.
  23090. * @returns {Array} Returns the array of property names and symbols.
  23091. */
  23092. function getAllKeysIn(object) {
  23093. return baseGetAllKeys(object, keysIn, getSymbolsIn);
  23094. }
  23095. /**
  23096. * Gets metadata for `func`.
  23097. *
  23098. * @private
  23099. * @param {Function} func The function to query.
  23100. * @returns {*} Returns the metadata for `func`.
  23101. */
  23102. var getData = !metaMap ? noop : function(func) {
  23103. return metaMap.get(func);
  23104. };
  23105. /**
  23106. * Gets the name of `func`.
  23107. *
  23108. * @private
  23109. * @param {Function} func The function to query.
  23110. * @returns {string} Returns the function name.
  23111. */
  23112. function getFuncName(func) {
  23113. var result = (func.name + ''),
  23114. array = realNames[result],
  23115. length = hasOwnProperty.call(realNames, result) ? array.length : 0;
  23116. while (length--) {
  23117. var data = array[length],
  23118. otherFunc = data.func;
  23119. if (otherFunc == null || otherFunc == func) {
  23120. return data.name;
  23121. }
  23122. }
  23123. return result;
  23124. }
  23125. /**
  23126. * Gets the argument placeholder value for `func`.
  23127. *
  23128. * @private
  23129. * @param {Function} func The function to inspect.
  23130. * @returns {*} Returns the placeholder value.
  23131. */
  23132. function getHolder(func) {
  23133. var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func;
  23134. return object.placeholder;
  23135. }
  23136. /**
  23137. * Gets the appropriate "iteratee" function. If `_.iteratee` is customized,
  23138. * this function returns the custom method, otherwise it returns `baseIteratee`.
  23139. * If arguments are provided, the chosen function is invoked with them and
  23140. * its result is returned.
  23141. *
  23142. * @private
  23143. * @param {*} [value] The value to convert to an iteratee.
  23144. * @param {number} [arity] The arity of the created iteratee.
  23145. * @returns {Function} Returns the chosen function or its result.
  23146. */
  23147. function getIteratee() {
  23148. var result = lodash.iteratee || iteratee;
  23149. result = result === iteratee ? baseIteratee : result;
  23150. return arguments.length ? result(arguments[0], arguments[1]) : result;
  23151. }
  23152. /**
  23153. * Gets the data for `map`.
  23154. *
  23155. * @private
  23156. * @param {Object} map The map to query.
  23157. * @param {string} key The reference key.
  23158. * @returns {*} Returns the map data.
  23159. */
  23160. function getMapData(map, key) {
  23161. var data = map.__data__;
  23162. return isKeyable(key)
  23163. ? data[typeof key == 'string' ? 'string' : 'hash']
  23164. : data.map;
  23165. }
  23166. /**
  23167. * Gets the property names, values, and compare flags of `object`.
  23168. *
  23169. * @private
  23170. * @param {Object} object The object to query.
  23171. * @returns {Array} Returns the match data of `object`.
  23172. */
  23173. function getMatchData(object) {
  23174. var result = keys(object),
  23175. length = result.length;
  23176. while (length--) {
  23177. var key = result[length],
  23178. value = object[key];
  23179. result[length] = [key, value, isStrictComparable(value)];
  23180. }
  23181. return result;
  23182. }
  23183. /**
  23184. * Gets the native function at `key` of `object`.
  23185. *
  23186. * @private
  23187. * @param {Object} object The object to query.
  23188. * @param {string} key The key of the method to get.
  23189. * @returns {*} Returns the function if it's native, else `undefined`.
  23190. */
  23191. function getNative(object, key) {
  23192. var value = getValue(object, key);
  23193. return baseIsNative(value) ? value : undefined;
  23194. }
  23195. /**
  23196. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  23197. *
  23198. * @private
  23199. * @param {*} value The value to query.
  23200. * @returns {string} Returns the raw `toStringTag`.
  23201. */
  23202. function getRawTag(value) {
  23203. var isOwn = hasOwnProperty.call(value, symToStringTag),
  23204. tag = value[symToStringTag];
  23205. try {
  23206. value[symToStringTag] = undefined;
  23207. var unmasked = true;
  23208. } catch (e) {}
  23209. var result = nativeObjectToString.call(value);
  23210. if (unmasked) {
  23211. if (isOwn) {
  23212. value[symToStringTag] = tag;
  23213. } else {
  23214. delete value[symToStringTag];
  23215. }
  23216. }
  23217. return result;
  23218. }
  23219. /**
  23220. * Creates an array of the own enumerable symbols of `object`.
  23221. *
  23222. * @private
  23223. * @param {Object} object The object to query.
  23224. * @returns {Array} Returns the array of symbols.
  23225. */
  23226. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  23227. if (object == null) {
  23228. return [];
  23229. }
  23230. object = Object(object);
  23231. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  23232. return propertyIsEnumerable.call(object, symbol);
  23233. });
  23234. };
  23235. /**
  23236. * Creates an array of the own and inherited enumerable symbols of `object`.
  23237. *
  23238. * @private
  23239. * @param {Object} object The object to query.
  23240. * @returns {Array} Returns the array of symbols.
  23241. */
  23242. var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
  23243. var result = [];
  23244. while (object) {
  23245. arrayPush(result, getSymbols(object));
  23246. object = getPrototype(object);
  23247. }
  23248. return result;
  23249. };
  23250. /**
  23251. * Gets the `toStringTag` of `value`.
  23252. *
  23253. * @private
  23254. * @param {*} value The value to query.
  23255. * @returns {string} Returns the `toStringTag`.
  23256. */
  23257. var getTag = baseGetTag;
  23258. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  23259. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
  23260. (Map && getTag(new Map) != mapTag) ||
  23261. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  23262. (Set && getTag(new Set) != setTag) ||
  23263. (WeakMap && getTag(new WeakMap) != weakMapTag)) {
  23264. getTag = function(value) {
  23265. var result = baseGetTag(value),
  23266. Ctor = result == objectTag ? value.constructor : undefined,
  23267. ctorString = Ctor ? toSource(Ctor) : '';
  23268. if (ctorString) {
  23269. switch (ctorString) {
  23270. case dataViewCtorString: return dataViewTag;
  23271. case mapCtorString: return mapTag;
  23272. case promiseCtorString: return promiseTag;
  23273. case setCtorString: return setTag;
  23274. case weakMapCtorString: return weakMapTag;
  23275. }
  23276. }
  23277. return result;
  23278. };
  23279. }
  23280. /**
  23281. * Gets the view, applying any `transforms` to the `start` and `end` positions.
  23282. *
  23283. * @private
  23284. * @param {number} start The start of the view.
  23285. * @param {number} end The end of the view.
  23286. * @param {Array} transforms The transformations to apply to the view.
  23287. * @returns {Object} Returns an object containing the `start` and `end`
  23288. * positions of the view.
  23289. */
  23290. function getView(start, end, transforms) {
  23291. var index = -1,
  23292. length = transforms.length;
  23293. while (++index < length) {
  23294. var data = transforms[index],
  23295. size = data.size;
  23296. switch (data.type) {
  23297. case 'drop': start += size; break;
  23298. case 'dropRight': end -= size; break;
  23299. case 'take': end = nativeMin(end, start + size); break;
  23300. case 'takeRight': start = nativeMax(start, end - size); break;
  23301. }
  23302. }
  23303. return { 'start': start, 'end': end };
  23304. }
  23305. /**
  23306. * Extracts wrapper details from the `source` body comment.
  23307. *
  23308. * @private
  23309. * @param {string} source The source to inspect.
  23310. * @returns {Array} Returns the wrapper details.
  23311. */
  23312. function getWrapDetails(source) {
  23313. var match = source.match(reWrapDetails);
  23314. return match ? match[1].split(reSplitDetails) : [];
  23315. }
  23316. /**
  23317. * Checks if `path` exists on `object`.
  23318. *
  23319. * @private
  23320. * @param {Object} object The object to query.
  23321. * @param {Array|string} path The path to check.
  23322. * @param {Function} hasFunc The function to check properties.
  23323. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  23324. */
  23325. function hasPath(object, path, hasFunc) {
  23326. path = castPath(path, object);
  23327. var index = -1,
  23328. length = path.length,
  23329. result = false;
  23330. while (++index < length) {
  23331. var key = toKey(path[index]);
  23332. if (!(result = object != null && hasFunc(object, key))) {
  23333. break;
  23334. }
  23335. object = object[key];
  23336. }
  23337. if (result || ++index != length) {
  23338. return result;
  23339. }
  23340. length = object == null ? 0 : object.length;
  23341. return !!length && isLength(length) && isIndex(key, length) &&
  23342. (isArray(object) || isArguments(object));
  23343. }
  23344. /**
  23345. * Initializes an array clone.
  23346. *
  23347. * @private
  23348. * @param {Array} array The array to clone.
  23349. * @returns {Array} Returns the initialized clone.
  23350. */
  23351. function initCloneArray(array) {
  23352. var length = array.length,
  23353. result = new array.constructor(length);
  23354. // Add properties assigned by `RegExp#exec`.
  23355. if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
  23356. result.index = array.index;
  23357. result.input = array.input;
  23358. }
  23359. return result;
  23360. }
  23361. /**
  23362. * Initializes an object clone.
  23363. *
  23364. * @private
  23365. * @param {Object} object The object to clone.
  23366. * @returns {Object} Returns the initialized clone.
  23367. */
  23368. function initCloneObject(object) {
  23369. return (typeof object.constructor == 'function' && !isPrototype(object))
  23370. ? baseCreate(getPrototype(object))
  23371. : {};
  23372. }
  23373. /**
  23374. * Initializes an object clone based on its `toStringTag`.
  23375. *
  23376. * **Note:** This function only supports cloning values with tags of
  23377. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  23378. *
  23379. * @private
  23380. * @param {Object} object The object to clone.
  23381. * @param {string} tag The `toStringTag` of the object to clone.
  23382. * @param {boolean} [isDeep] Specify a deep clone.
  23383. * @returns {Object} Returns the initialized clone.
  23384. */
  23385. function initCloneByTag(object, tag, isDeep) {
  23386. var Ctor = object.constructor;
  23387. switch (tag) {
  23388. case arrayBufferTag:
  23389. return cloneArrayBuffer(object);
  23390. case boolTag:
  23391. case dateTag:
  23392. return new Ctor(+object);
  23393. case dataViewTag:
  23394. return cloneDataView(object, isDeep);
  23395. case float32Tag: case float64Tag:
  23396. case int8Tag: case int16Tag: case int32Tag:
  23397. case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
  23398. return cloneTypedArray(object, isDeep);
  23399. case mapTag:
  23400. return new Ctor;
  23401. case numberTag:
  23402. case stringTag:
  23403. return new Ctor(object);
  23404. case regexpTag:
  23405. return cloneRegExp(object);
  23406. case setTag:
  23407. return new Ctor;
  23408. case symbolTag:
  23409. return cloneSymbol(object);
  23410. }
  23411. }
  23412. /**
  23413. * Inserts wrapper `details` in a comment at the top of the `source` body.
  23414. *
  23415. * @private
  23416. * @param {string} source The source to modify.
  23417. * @returns {Array} details The details to insert.
  23418. * @returns {string} Returns the modified source.
  23419. */
  23420. function insertWrapDetails(source, details) {
  23421. var length = details.length;
  23422. if (!length) {
  23423. return source;
  23424. }
  23425. var lastIndex = length - 1;
  23426. details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
  23427. details = details.join(length > 2 ? ', ' : ' ');
  23428. return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
  23429. }
  23430. /**
  23431. * Checks if `value` is a flattenable `arguments` object or array.
  23432. *
  23433. * @private
  23434. * @param {*} value The value to check.
  23435. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  23436. */
  23437. function isFlattenable(value) {
  23438. return isArray(value) || isArguments(value) ||
  23439. !!(spreadableSymbol && value && value[spreadableSymbol]);
  23440. }
  23441. /**
  23442. * Checks if `value` is a valid array-like index.
  23443. *
  23444. * @private
  23445. * @param {*} value The value to check.
  23446. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  23447. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  23448. */
  23449. function isIndex(value, length) {
  23450. var type = typeof value;
  23451. length = length == null ? MAX_SAFE_INTEGER : length;
  23452. return !!length &&
  23453. (type == 'number' ||
  23454. (type != 'symbol' && reIsUint.test(value))) &&
  23455. (value > -1 && value % 1 == 0 && value < length);
  23456. }
  23457. /**
  23458. * Checks if the given arguments are from an iteratee call.
  23459. *
  23460. * @private
  23461. * @param {*} value The potential iteratee value argument.
  23462. * @param {*} index The potential iteratee index or key argument.
  23463. * @param {*} object The potential iteratee object argument.
  23464. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  23465. * else `false`.
  23466. */
  23467. function isIterateeCall(value, index, object) {
  23468. if (!isObject(object)) {
  23469. return false;
  23470. }
  23471. var type = typeof index;
  23472. if (type == 'number'
  23473. ? (isArrayLike(object) && isIndex(index, object.length))
  23474. : (type == 'string' && index in object)
  23475. ) {
  23476. return eq(object[index], value);
  23477. }
  23478. return false;
  23479. }
  23480. /**
  23481. * Checks if `value` is a property name and not a property path.
  23482. *
  23483. * @private
  23484. * @param {*} value The value to check.
  23485. * @param {Object} [object] The object to query keys on.
  23486. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  23487. */
  23488. function isKey(value, object) {
  23489. if (isArray(value)) {
  23490. return false;
  23491. }
  23492. var type = typeof value;
  23493. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  23494. value == null || isSymbol(value)) {
  23495. return true;
  23496. }
  23497. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  23498. (object != null && value in Object(object));
  23499. }
  23500. /**
  23501. * Checks if `value` is suitable for use as unique object key.
  23502. *
  23503. * @private
  23504. * @param {*} value The value to check.
  23505. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  23506. */
  23507. function isKeyable(value) {
  23508. var type = typeof value;
  23509. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  23510. ? (value !== '__proto__')
  23511. : (value === null);
  23512. }
  23513. /**
  23514. * Checks if `func` has a lazy counterpart.
  23515. *
  23516. * @private
  23517. * @param {Function} func The function to check.
  23518. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  23519. * else `false`.
  23520. */
  23521. function isLaziable(func) {
  23522. var funcName = getFuncName(func),
  23523. other = lodash[funcName];
  23524. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  23525. return false;
  23526. }
  23527. if (func === other) {
  23528. return true;
  23529. }
  23530. var data = getData(other);
  23531. return !!data && func === data[0];
  23532. }
  23533. /**
  23534. * Checks if `func` has its source masked.
  23535. *
  23536. * @private
  23537. * @param {Function} func The function to check.
  23538. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  23539. */
  23540. function isMasked(func) {
  23541. return !!maskSrcKey && (maskSrcKey in func);
  23542. }
  23543. /**
  23544. * Checks if `func` is capable of being masked.
  23545. *
  23546. * @private
  23547. * @param {*} value The value to check.
  23548. * @returns {boolean} Returns `true` if `func` is maskable, else `false`.
  23549. */
  23550. var isMaskable = coreJsData ? isFunction : stubFalse;
  23551. /**
  23552. * Checks if `value` is likely a prototype object.
  23553. *
  23554. * @private
  23555. * @param {*} value The value to check.
  23556. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  23557. */
  23558. function isPrototype(value) {
  23559. var Ctor = value && value.constructor,
  23560. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
  23561. return value === proto;
  23562. }
  23563. /**
  23564. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  23565. *
  23566. * @private
  23567. * @param {*} value The value to check.
  23568. * @returns {boolean} Returns `true` if `value` if suitable for strict
  23569. * equality comparisons, else `false`.
  23570. */
  23571. function isStrictComparable(value) {
  23572. return value === value && !isObject(value);
  23573. }
  23574. /**
  23575. * A specialized version of `matchesProperty` for source values suitable
  23576. * for strict equality comparisons, i.e. `===`.
  23577. *
  23578. * @private
  23579. * @param {string} key The key of the property to get.
  23580. * @param {*} srcValue The value to match.
  23581. * @returns {Function} Returns the new spec function.
  23582. */
  23583. function matchesStrictComparable(key, srcValue) {
  23584. return function(object) {
  23585. if (object == null) {
  23586. return false;
  23587. }
  23588. return object[key] === srcValue &&
  23589. (srcValue !== undefined || (key in Object(object)));
  23590. };
  23591. }
  23592. /**
  23593. * A specialized version of `_.memoize` which clears the memoized function's
  23594. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  23595. *
  23596. * @private
  23597. * @param {Function} func The function to have its output memoized.
  23598. * @returns {Function} Returns the new memoized function.
  23599. */
  23600. function memoizeCapped(func) {
  23601. var result = memoize(func, function(key) {
  23602. if (cache.size === MAX_MEMOIZE_SIZE) {
  23603. cache.clear();
  23604. }
  23605. return key;
  23606. });
  23607. var cache = result.cache;
  23608. return result;
  23609. }
  23610. /**
  23611. * Merges the function metadata of `source` into `data`.
  23612. *
  23613. * Merging metadata reduces the number of wrappers used to invoke a function.
  23614. * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
  23615. * may be applied regardless of execution order. Methods like `_.ary` and
  23616. * `_.rearg` modify function arguments, making the order in which they are
  23617. * executed important, preventing the merging of metadata. However, we make
  23618. * an exception for a safe combined case where curried functions have `_.ary`
  23619. * and or `_.rearg` applied.
  23620. *
  23621. * @private
  23622. * @param {Array} data The destination metadata.
  23623. * @param {Array} source The source metadata.
  23624. * @returns {Array} Returns `data`.
  23625. */
  23626. function mergeData(data, source) {
  23627. var bitmask = data[1],
  23628. srcBitmask = source[1],
  23629. newBitmask = bitmask | srcBitmask,
  23630. isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
  23631. var isCombo =
  23632. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
  23633. ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
  23634. ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
  23635. // Exit early if metadata can't be merged.
  23636. if (!(isCommon || isCombo)) {
  23637. return data;
  23638. }
  23639. // Use source `thisArg` if available.
  23640. if (srcBitmask & WRAP_BIND_FLAG) {
  23641. data[2] = source[2];
  23642. // Set when currying a bound function.
  23643. newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
  23644. }
  23645. // Compose partial arguments.
  23646. var value = source[3];
  23647. if (value) {
  23648. var partials = data[3];
  23649. data[3] = partials ? composeArgs(partials, value, source[4]) : value;
  23650. data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
  23651. }
  23652. // Compose partial right arguments.
  23653. value = source[5];
  23654. if (value) {
  23655. partials = data[5];
  23656. data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
  23657. data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
  23658. }
  23659. // Use source `argPos` if available.
  23660. value = source[7];
  23661. if (value) {
  23662. data[7] = value;
  23663. }
  23664. // Use source `ary` if it's smaller.
  23665. if (srcBitmask & WRAP_ARY_FLAG) {
  23666. data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
  23667. }
  23668. // Use source `arity` if one is not provided.
  23669. if (data[9] == null) {
  23670. data[9] = source[9];
  23671. }
  23672. // Use source `func` and merge bitmasks.
  23673. data[0] = source[0];
  23674. data[1] = newBitmask;
  23675. return data;
  23676. }
  23677. /**
  23678. * This function is like
  23679. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  23680. * except that it includes inherited enumerable properties.
  23681. *
  23682. * @private
  23683. * @param {Object} object The object to query.
  23684. * @returns {Array} Returns the array of property names.
  23685. */
  23686. function nativeKeysIn(object) {
  23687. var result = [];
  23688. if (object != null) {
  23689. for (var key in Object(object)) {
  23690. result.push(key);
  23691. }
  23692. }
  23693. return result;
  23694. }
  23695. /**
  23696. * Converts `value` to a string using `Object.prototype.toString`.
  23697. *
  23698. * @private
  23699. * @param {*} value The value to convert.
  23700. * @returns {string} Returns the converted string.
  23701. */
  23702. function objectToString(value) {
  23703. return nativeObjectToString.call(value);
  23704. }
  23705. /**
  23706. * A specialized version of `baseRest` which transforms the rest array.
  23707. *
  23708. * @private
  23709. * @param {Function} func The function to apply a rest parameter to.
  23710. * @param {number} [start=func.length-1] The start position of the rest parameter.
  23711. * @param {Function} transform The rest array transform.
  23712. * @returns {Function} Returns the new function.
  23713. */
  23714. function overRest(func, start, transform) {
  23715. start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
  23716. return function() {
  23717. var args = arguments,
  23718. index = -1,
  23719. length = nativeMax(args.length - start, 0),
  23720. array = Array(length);
  23721. while (++index < length) {
  23722. array[index] = args[start + index];
  23723. }
  23724. index = -1;
  23725. var otherArgs = Array(start + 1);
  23726. while (++index < start) {
  23727. otherArgs[index] = args[index];
  23728. }
  23729. otherArgs[start] = transform(array);
  23730. return apply(func, this, otherArgs);
  23731. };
  23732. }
  23733. /**
  23734. * Gets the parent value at `path` of `object`.
  23735. *
  23736. * @private
  23737. * @param {Object} object The object to query.
  23738. * @param {Array} path The path to get the parent value of.
  23739. * @returns {*} Returns the parent value.
  23740. */
  23741. function parent(object, path) {
  23742. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  23743. }
  23744. /**
  23745. * Reorder `array` according to the specified indexes where the element at
  23746. * the first index is assigned as the first element, the element at
  23747. * the second index is assigned as the second element, and so on.
  23748. *
  23749. * @private
  23750. * @param {Array} array The array to reorder.
  23751. * @param {Array} indexes The arranged array indexes.
  23752. * @returns {Array} Returns `array`.
  23753. */
  23754. function reorder(array, indexes) {
  23755. var arrLength = array.length,
  23756. length = nativeMin(indexes.length, arrLength),
  23757. oldArray = copyArray(array);
  23758. while (length--) {
  23759. var index = indexes[length];
  23760. array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
  23761. }
  23762. return array;
  23763. }
  23764. /**
  23765. * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
  23766. *
  23767. * @private
  23768. * @param {Object} object The object to query.
  23769. * @param {string} key The key of the property to get.
  23770. * @returns {*} Returns the property value.
  23771. */
  23772. function safeGet(object, key) {
  23773. if (key === 'constructor' && typeof object[key] === 'function') {
  23774. return;
  23775. }
  23776. if (key == '__proto__') {
  23777. return;
  23778. }
  23779. return object[key];
  23780. }
  23781. /**
  23782. * Sets metadata for `func`.
  23783. *
  23784. * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
  23785. * period of time, it will trip its breaker and transition to an identity
  23786. * function to avoid garbage collection pauses in V8. See
  23787. * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
  23788. * for more details.
  23789. *
  23790. * @private
  23791. * @param {Function} func The function to associate metadata with.
  23792. * @param {*} data The metadata.
  23793. * @returns {Function} Returns `func`.
  23794. */
  23795. var setData = shortOut(baseSetData);
  23796. /**
  23797. * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
  23798. *
  23799. * @private
  23800. * @param {Function} func The function to delay.
  23801. * @param {number} wait The number of milliseconds to delay invocation.
  23802. * @returns {number|Object} Returns the timer id or timeout object.
  23803. */
  23804. var setTimeout = ctxSetTimeout || function(func, wait) {
  23805. return root.setTimeout(func, wait);
  23806. };
  23807. /**
  23808. * Sets the `toString` method of `func` to return `string`.
  23809. *
  23810. * @private
  23811. * @param {Function} func The function to modify.
  23812. * @param {Function} string The `toString` result.
  23813. * @returns {Function} Returns `func`.
  23814. */
  23815. var setToString = shortOut(baseSetToString);
  23816. /**
  23817. * Sets the `toString` method of `wrapper` to mimic the source of `reference`
  23818. * with wrapper details in a comment at the top of the source body.
  23819. *
  23820. * @private
  23821. * @param {Function} wrapper The function to modify.
  23822. * @param {Function} reference The reference function.
  23823. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23824. * @returns {Function} Returns `wrapper`.
  23825. */
  23826. function setWrapToString(wrapper, reference, bitmask) {
  23827. var source = (reference + '');
  23828. return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
  23829. }
  23830. /**
  23831. * Creates a function that'll short out and invoke `identity` instead
  23832. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  23833. * milliseconds.
  23834. *
  23835. * @private
  23836. * @param {Function} func The function to restrict.
  23837. * @returns {Function} Returns the new shortable function.
  23838. */
  23839. function shortOut(func) {
  23840. var count = 0,
  23841. lastCalled = 0;
  23842. return function() {
  23843. var stamp = nativeNow(),
  23844. remaining = HOT_SPAN - (stamp - lastCalled);
  23845. lastCalled = stamp;
  23846. if (remaining > 0) {
  23847. if (++count >= HOT_COUNT) {
  23848. return arguments[0];
  23849. }
  23850. } else {
  23851. count = 0;
  23852. }
  23853. return func.apply(undefined, arguments);
  23854. };
  23855. }
  23856. /**
  23857. * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
  23858. *
  23859. * @private
  23860. * @param {Array} array The array to shuffle.
  23861. * @param {number} [size=array.length] The size of `array`.
  23862. * @returns {Array} Returns `array`.
  23863. */
  23864. function shuffleSelf(array, size) {
  23865. var index = -1,
  23866. length = array.length,
  23867. lastIndex = length - 1;
  23868. size = size === undefined ? length : size;
  23869. while (++index < size) {
  23870. var rand = baseRandom(index, lastIndex),
  23871. value = array[rand];
  23872. array[rand] = array[index];
  23873. array[index] = value;
  23874. }
  23875. array.length = size;
  23876. return array;
  23877. }
  23878. /**
  23879. * Converts `string` to a property path array.
  23880. *
  23881. * @private
  23882. * @param {string} string The string to convert.
  23883. * @returns {Array} Returns the property path array.
  23884. */
  23885. var stringToPath = memoizeCapped(function(string) {
  23886. var result = [];
  23887. if (string.charCodeAt(0) === 46 /* . */) {
  23888. result.push('');
  23889. }
  23890. string.replace(rePropName, function(match, number, quote, subString) {
  23891. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  23892. });
  23893. return result;
  23894. });
  23895. /**
  23896. * Converts `value` to a string key if it's not a string or symbol.
  23897. *
  23898. * @private
  23899. * @param {*} value The value to inspect.
  23900. * @returns {string|symbol} Returns the key.
  23901. */
  23902. function toKey(value) {
  23903. if (typeof value == 'string' || isSymbol(value)) {
  23904. return value;
  23905. }
  23906. var result = (value + '');
  23907. return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
  23908. }
  23909. /**
  23910. * Converts `func` to its source code.
  23911. *
  23912. * @private
  23913. * @param {Function} func The function to convert.
  23914. * @returns {string} Returns the source code.
  23915. */
  23916. function toSource(func) {
  23917. if (func != null) {
  23918. try {
  23919. return funcToString.call(func);
  23920. } catch (e) {}
  23921. try {
  23922. return (func + '');
  23923. } catch (e) {}
  23924. }
  23925. return '';
  23926. }
  23927. /**
  23928. * Updates wrapper `details` based on `bitmask` flags.
  23929. *
  23930. * @private
  23931. * @returns {Array} details The details to modify.
  23932. * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
  23933. * @returns {Array} Returns `details`.
  23934. */
  23935. function updateWrapDetails(details, bitmask) {
  23936. arrayEach(wrapFlags, function(pair) {
  23937. var value = '_.' + pair[0];
  23938. if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
  23939. details.push(value);
  23940. }
  23941. });
  23942. return details.sort();
  23943. }
  23944. /**
  23945. * Creates a clone of `wrapper`.
  23946. *
  23947. * @private
  23948. * @param {Object} wrapper The wrapper to clone.
  23949. * @returns {Object} Returns the cloned wrapper.
  23950. */
  23951. function wrapperClone(wrapper) {
  23952. if (wrapper instanceof LazyWrapper) {
  23953. return wrapper.clone();
  23954. }
  23955. var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
  23956. result.__actions__ = copyArray(wrapper.__actions__);
  23957. result.__index__ = wrapper.__index__;
  23958. result.__values__ = wrapper.__values__;
  23959. return result;
  23960. }
  23961. /*------------------------------------------------------------------------*/
  23962. /**
  23963. * Creates an array of elements split into groups the length of `size`.
  23964. * If `array` can't be split evenly, the final chunk will be the remaining
  23965. * elements.
  23966. *
  23967. * @static
  23968. * @memberOf _
  23969. * @since 3.0.0
  23970. * @category Array
  23971. * @param {Array} array The array to process.
  23972. * @param {number} [size=1] The length of each chunk
  23973. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  23974. * @returns {Array} Returns the new array of chunks.
  23975. * @example
  23976. *
  23977. * _.chunk(['a', 'b', 'c', 'd'], 2);
  23978. * // => [['a', 'b'], ['c', 'd']]
  23979. *
  23980. * _.chunk(['a', 'b', 'c', 'd'], 3);
  23981. * // => [['a', 'b', 'c'], ['d']]
  23982. */
  23983. function chunk(array, size, guard) {
  23984. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  23985. size = 1;
  23986. } else {
  23987. size = nativeMax(toInteger(size), 0);
  23988. }
  23989. var length = array == null ? 0 : array.length;
  23990. if (!length || size < 1) {
  23991. return [];
  23992. }
  23993. var index = 0,
  23994. resIndex = 0,
  23995. result = Array(nativeCeil(length / size));
  23996. while (index < length) {
  23997. result[resIndex++] = baseSlice(array, index, (index += size));
  23998. }
  23999. return result;
  24000. }
  24001. /**
  24002. * Creates an array with all falsey values removed. The values `false`, `null`,
  24003. * `0`, `""`, `undefined`, and `NaN` are falsey.
  24004. *
  24005. * @static
  24006. * @memberOf _
  24007. * @since 0.1.0
  24008. * @category Array
  24009. * @param {Array} array The array to compact.
  24010. * @returns {Array} Returns the new array of filtered values.
  24011. * @example
  24012. *
  24013. * _.compact([0, 1, false, 2, '', 3]);
  24014. * // => [1, 2, 3]
  24015. */
  24016. function compact(array) {
  24017. var index = -1,
  24018. length = array == null ? 0 : array.length,
  24019. resIndex = 0,
  24020. result = [];
  24021. while (++index < length) {
  24022. var value = array[index];
  24023. if (value) {
  24024. result[resIndex++] = value;
  24025. }
  24026. }
  24027. return result;
  24028. }
  24029. /**
  24030. * Creates a new array concatenating `array` with any additional arrays
  24031. * and/or values.
  24032. *
  24033. * @static
  24034. * @memberOf _
  24035. * @since 4.0.0
  24036. * @category Array
  24037. * @param {Array} array The array to concatenate.
  24038. * @param {...*} [values] The values to concatenate.
  24039. * @returns {Array} Returns the new concatenated array.
  24040. * @example
  24041. *
  24042. * var array = [1];
  24043. * var other = _.concat(array, 2, [3], [[4]]);
  24044. *
  24045. * console.log(other);
  24046. * // => [1, 2, 3, [4]]
  24047. *
  24048. * console.log(array);
  24049. * // => [1]
  24050. */
  24051. function concat() {
  24052. var length = arguments.length;
  24053. if (!length) {
  24054. return [];
  24055. }
  24056. var args = Array(length - 1),
  24057. array = arguments[0],
  24058. index = length;
  24059. while (index--) {
  24060. args[index - 1] = arguments[index];
  24061. }
  24062. return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
  24063. }
  24064. /**
  24065. * Creates an array of `array` values not included in the other given arrays
  24066. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24067. * for equality comparisons. The order and references of result values are
  24068. * determined by the first array.
  24069. *
  24070. * **Note:** Unlike `_.pullAll`, this method returns a new array.
  24071. *
  24072. * @static
  24073. * @memberOf _
  24074. * @since 0.1.0
  24075. * @category Array
  24076. * @param {Array} array The array to inspect.
  24077. * @param {...Array} [values] The values to exclude.
  24078. * @returns {Array} Returns the new array of filtered values.
  24079. * @see _.without, _.xor
  24080. * @example
  24081. *
  24082. * _.difference([2, 1], [2, 3]);
  24083. * // => [1]
  24084. */
  24085. var difference = baseRest(function(array, values) {
  24086. return isArrayLikeObject(array)
  24087. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
  24088. : [];
  24089. });
  24090. /**
  24091. * This method is like `_.difference` except that it accepts `iteratee` which
  24092. * is invoked for each element of `array` and `values` to generate the criterion
  24093. * by which they're compared. The order and references of result values are
  24094. * determined by the first array. The iteratee is invoked with one argument:
  24095. * (value).
  24096. *
  24097. * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
  24098. *
  24099. * @static
  24100. * @memberOf _
  24101. * @since 4.0.0
  24102. * @category Array
  24103. * @param {Array} array The array to inspect.
  24104. * @param {...Array} [values] The values to exclude.
  24105. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24106. * @returns {Array} Returns the new array of filtered values.
  24107. * @example
  24108. *
  24109. * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24110. * // => [1.2]
  24111. *
  24112. * // The `_.property` iteratee shorthand.
  24113. * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
  24114. * // => [{ 'x': 2 }]
  24115. */
  24116. var differenceBy = baseRest(function(array, values) {
  24117. var iteratee = last(values);
  24118. if (isArrayLikeObject(iteratee)) {
  24119. iteratee = undefined;
  24120. }
  24121. return isArrayLikeObject(array)
  24122. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
  24123. : [];
  24124. });
  24125. /**
  24126. * This method is like `_.difference` except that it accepts `comparator`
  24127. * which is invoked to compare elements of `array` to `values`. The order and
  24128. * references of result values are determined by the first array. The comparator
  24129. * is invoked with two arguments: (arrVal, othVal).
  24130. *
  24131. * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
  24132. *
  24133. * @static
  24134. * @memberOf _
  24135. * @since 4.0.0
  24136. * @category Array
  24137. * @param {Array} array The array to inspect.
  24138. * @param {...Array} [values] The values to exclude.
  24139. * @param {Function} [comparator] The comparator invoked per element.
  24140. * @returns {Array} Returns the new array of filtered values.
  24141. * @example
  24142. *
  24143. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24144. *
  24145. * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
  24146. * // => [{ 'x': 2, 'y': 1 }]
  24147. */
  24148. var differenceWith = baseRest(function(array, values) {
  24149. var comparator = last(values);
  24150. if (isArrayLikeObject(comparator)) {
  24151. comparator = undefined;
  24152. }
  24153. return isArrayLikeObject(array)
  24154. ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator)
  24155. : [];
  24156. });
  24157. /**
  24158. * Creates a slice of `array` with `n` elements dropped from the beginning.
  24159. *
  24160. * @static
  24161. * @memberOf _
  24162. * @since 0.5.0
  24163. * @category Array
  24164. * @param {Array} array The array to query.
  24165. * @param {number} [n=1] The number of elements to drop.
  24166. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24167. * @returns {Array} Returns the slice of `array`.
  24168. * @example
  24169. *
  24170. * _.drop([1, 2, 3]);
  24171. * // => [2, 3]
  24172. *
  24173. * _.drop([1, 2, 3], 2);
  24174. * // => [3]
  24175. *
  24176. * _.drop([1, 2, 3], 5);
  24177. * // => []
  24178. *
  24179. * _.drop([1, 2, 3], 0);
  24180. * // => [1, 2, 3]
  24181. */
  24182. function drop(array, n, guard) {
  24183. var length = array == null ? 0 : array.length;
  24184. if (!length) {
  24185. return [];
  24186. }
  24187. n = (guard || n === undefined) ? 1 : toInteger(n);
  24188. return baseSlice(array, n < 0 ? 0 : n, length);
  24189. }
  24190. /**
  24191. * Creates a slice of `array` with `n` elements dropped from the end.
  24192. *
  24193. * @static
  24194. * @memberOf _
  24195. * @since 3.0.0
  24196. * @category Array
  24197. * @param {Array} array The array to query.
  24198. * @param {number} [n=1] The number of elements to drop.
  24199. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  24200. * @returns {Array} Returns the slice of `array`.
  24201. * @example
  24202. *
  24203. * _.dropRight([1, 2, 3]);
  24204. * // => [1, 2]
  24205. *
  24206. * _.dropRight([1, 2, 3], 2);
  24207. * // => [1]
  24208. *
  24209. * _.dropRight([1, 2, 3], 5);
  24210. * // => []
  24211. *
  24212. * _.dropRight([1, 2, 3], 0);
  24213. * // => [1, 2, 3]
  24214. */
  24215. function dropRight(array, n, guard) {
  24216. var length = array == null ? 0 : array.length;
  24217. if (!length) {
  24218. return [];
  24219. }
  24220. n = (guard || n === undefined) ? 1 : toInteger(n);
  24221. n = length - n;
  24222. return baseSlice(array, 0, n < 0 ? 0 : n);
  24223. }
  24224. /**
  24225. * Creates a slice of `array` excluding elements dropped from the end.
  24226. * Elements are dropped until `predicate` returns falsey. The predicate is
  24227. * invoked with three arguments: (value, index, array).
  24228. *
  24229. * @static
  24230. * @memberOf _
  24231. * @since 3.0.0
  24232. * @category Array
  24233. * @param {Array} array The array to query.
  24234. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24235. * @returns {Array} Returns the slice of `array`.
  24236. * @example
  24237. *
  24238. * var users = [
  24239. * { 'user': 'barney', 'active': true },
  24240. * { 'user': 'fred', 'active': false },
  24241. * { 'user': 'pebbles', 'active': false }
  24242. * ];
  24243. *
  24244. * _.dropRightWhile(users, function(o) { return !o.active; });
  24245. * // => objects for ['barney']
  24246. *
  24247. * // The `_.matches` iteratee shorthand.
  24248. * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
  24249. * // => objects for ['barney', 'fred']
  24250. *
  24251. * // The `_.matchesProperty` iteratee shorthand.
  24252. * _.dropRightWhile(users, ['active', false]);
  24253. * // => objects for ['barney']
  24254. *
  24255. * // The `_.property` iteratee shorthand.
  24256. * _.dropRightWhile(users, 'active');
  24257. * // => objects for ['barney', 'fred', 'pebbles']
  24258. */
  24259. function dropRightWhile(array, predicate) {
  24260. return (array && array.length)
  24261. ? baseWhile(array, getIteratee(predicate, 3), true, true)
  24262. : [];
  24263. }
  24264. /**
  24265. * Creates a slice of `array` excluding elements dropped from the beginning.
  24266. * Elements are dropped until `predicate` returns falsey. The predicate is
  24267. * invoked with three arguments: (value, index, array).
  24268. *
  24269. * @static
  24270. * @memberOf _
  24271. * @since 3.0.0
  24272. * @category Array
  24273. * @param {Array} array The array to query.
  24274. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24275. * @returns {Array} Returns the slice of `array`.
  24276. * @example
  24277. *
  24278. * var users = [
  24279. * { 'user': 'barney', 'active': false },
  24280. * { 'user': 'fred', 'active': false },
  24281. * { 'user': 'pebbles', 'active': true }
  24282. * ];
  24283. *
  24284. * _.dropWhile(users, function(o) { return !o.active; });
  24285. * // => objects for ['pebbles']
  24286. *
  24287. * // The `_.matches` iteratee shorthand.
  24288. * _.dropWhile(users, { 'user': 'barney', 'active': false });
  24289. * // => objects for ['fred', 'pebbles']
  24290. *
  24291. * // The `_.matchesProperty` iteratee shorthand.
  24292. * _.dropWhile(users, ['active', false]);
  24293. * // => objects for ['pebbles']
  24294. *
  24295. * // The `_.property` iteratee shorthand.
  24296. * _.dropWhile(users, 'active');
  24297. * // => objects for ['barney', 'fred', 'pebbles']
  24298. */
  24299. function dropWhile(array, predicate) {
  24300. return (array && array.length)
  24301. ? baseWhile(array, getIteratee(predicate, 3), true)
  24302. : [];
  24303. }
  24304. /**
  24305. * Fills elements of `array` with `value` from `start` up to, but not
  24306. * including, `end`.
  24307. *
  24308. * **Note:** This method mutates `array`.
  24309. *
  24310. * @static
  24311. * @memberOf _
  24312. * @since 3.2.0
  24313. * @category Array
  24314. * @param {Array} array The array to fill.
  24315. * @param {*} value The value to fill `array` with.
  24316. * @param {number} [start=0] The start position.
  24317. * @param {number} [end=array.length] The end position.
  24318. * @returns {Array} Returns `array`.
  24319. * @example
  24320. *
  24321. * var array = [1, 2, 3];
  24322. *
  24323. * _.fill(array, 'a');
  24324. * console.log(array);
  24325. * // => ['a', 'a', 'a']
  24326. *
  24327. * _.fill(Array(3), 2);
  24328. * // => [2, 2, 2]
  24329. *
  24330. * _.fill([4, 6, 8, 10], '*', 1, 3);
  24331. * // => [4, '*', '*', 10]
  24332. */
  24333. function fill(array, value, start, end) {
  24334. var length = array == null ? 0 : array.length;
  24335. if (!length) {
  24336. return [];
  24337. }
  24338. if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
  24339. start = 0;
  24340. end = length;
  24341. }
  24342. return baseFill(array, value, start, end);
  24343. }
  24344. /**
  24345. * This method is like `_.find` except that it returns the index of the first
  24346. * element `predicate` returns truthy for instead of the element itself.
  24347. *
  24348. * @static
  24349. * @memberOf _
  24350. * @since 1.1.0
  24351. * @category Array
  24352. * @param {Array} array The array to inspect.
  24353. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24354. * @param {number} [fromIndex=0] The index to search from.
  24355. * @returns {number} Returns the index of the found element, else `-1`.
  24356. * @example
  24357. *
  24358. * var users = [
  24359. * { 'user': 'barney', 'active': false },
  24360. * { 'user': 'fred', 'active': false },
  24361. * { 'user': 'pebbles', 'active': true }
  24362. * ];
  24363. *
  24364. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  24365. * // => 0
  24366. *
  24367. * // The `_.matches` iteratee shorthand.
  24368. * _.findIndex(users, { 'user': 'fred', 'active': false });
  24369. * // => 1
  24370. *
  24371. * // The `_.matchesProperty` iteratee shorthand.
  24372. * _.findIndex(users, ['active', false]);
  24373. * // => 0
  24374. *
  24375. * // The `_.property` iteratee shorthand.
  24376. * _.findIndex(users, 'active');
  24377. * // => 2
  24378. */
  24379. function findIndex(array, predicate, fromIndex) {
  24380. var length = array == null ? 0 : array.length;
  24381. if (!length) {
  24382. return -1;
  24383. }
  24384. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  24385. if (index < 0) {
  24386. index = nativeMax(length + index, 0);
  24387. }
  24388. return baseFindIndex(array, getIteratee(predicate, 3), index);
  24389. }
  24390. /**
  24391. * This method is like `_.findIndex` except that it iterates over elements
  24392. * of `collection` from right to left.
  24393. *
  24394. * @static
  24395. * @memberOf _
  24396. * @since 2.0.0
  24397. * @category Array
  24398. * @param {Array} array The array to inspect.
  24399. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24400. * @param {number} [fromIndex=array.length-1] The index to search from.
  24401. * @returns {number} Returns the index of the found element, else `-1`.
  24402. * @example
  24403. *
  24404. * var users = [
  24405. * { 'user': 'barney', 'active': true },
  24406. * { 'user': 'fred', 'active': false },
  24407. * { 'user': 'pebbles', 'active': false }
  24408. * ];
  24409. *
  24410. * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
  24411. * // => 2
  24412. *
  24413. * // The `_.matches` iteratee shorthand.
  24414. * _.findLastIndex(users, { 'user': 'barney', 'active': true });
  24415. * // => 0
  24416. *
  24417. * // The `_.matchesProperty` iteratee shorthand.
  24418. * _.findLastIndex(users, ['active', false]);
  24419. * // => 2
  24420. *
  24421. * // The `_.property` iteratee shorthand.
  24422. * _.findLastIndex(users, 'active');
  24423. * // => 0
  24424. */
  24425. function findLastIndex(array, predicate, fromIndex) {
  24426. var length = array == null ? 0 : array.length;
  24427. if (!length) {
  24428. return -1;
  24429. }
  24430. var index = length - 1;
  24431. if (fromIndex !== undefined) {
  24432. index = toInteger(fromIndex);
  24433. index = fromIndex < 0
  24434. ? nativeMax(length + index, 0)
  24435. : nativeMin(index, length - 1);
  24436. }
  24437. return baseFindIndex(array, getIteratee(predicate, 3), index, true);
  24438. }
  24439. /**
  24440. * Flattens `array` a single level deep.
  24441. *
  24442. * @static
  24443. * @memberOf _
  24444. * @since 0.1.0
  24445. * @category Array
  24446. * @param {Array} array The array to flatten.
  24447. * @returns {Array} Returns the new flattened array.
  24448. * @example
  24449. *
  24450. * _.flatten([1, [2, [3, [4]], 5]]);
  24451. * // => [1, 2, [3, [4]], 5]
  24452. */
  24453. function flatten(array) {
  24454. var length = array == null ? 0 : array.length;
  24455. return length ? baseFlatten(array, 1) : [];
  24456. }
  24457. /**
  24458. * Recursively flattens `array`.
  24459. *
  24460. * @static
  24461. * @memberOf _
  24462. * @since 3.0.0
  24463. * @category Array
  24464. * @param {Array} array The array to flatten.
  24465. * @returns {Array} Returns the new flattened array.
  24466. * @example
  24467. *
  24468. * _.flattenDeep([1, [2, [3, [4]], 5]]);
  24469. * // => [1, 2, 3, 4, 5]
  24470. */
  24471. function flattenDeep(array) {
  24472. var length = array == null ? 0 : array.length;
  24473. return length ? baseFlatten(array, INFINITY) : [];
  24474. }
  24475. /**
  24476. * Recursively flatten `array` up to `depth` times.
  24477. *
  24478. * @static
  24479. * @memberOf _
  24480. * @since 4.4.0
  24481. * @category Array
  24482. * @param {Array} array The array to flatten.
  24483. * @param {number} [depth=1] The maximum recursion depth.
  24484. * @returns {Array} Returns the new flattened array.
  24485. * @example
  24486. *
  24487. * var array = [1, [2, [3, [4]], 5]];
  24488. *
  24489. * _.flattenDepth(array, 1);
  24490. * // => [1, 2, [3, [4]], 5]
  24491. *
  24492. * _.flattenDepth(array, 2);
  24493. * // => [1, 2, 3, [4], 5]
  24494. */
  24495. function flattenDepth(array, depth) {
  24496. var length = array == null ? 0 : array.length;
  24497. if (!length) {
  24498. return [];
  24499. }
  24500. depth = depth === undefined ? 1 : toInteger(depth);
  24501. return baseFlatten(array, depth);
  24502. }
  24503. /**
  24504. * The inverse of `_.toPairs`; this method returns an object composed
  24505. * from key-value `pairs`.
  24506. *
  24507. * @static
  24508. * @memberOf _
  24509. * @since 4.0.0
  24510. * @category Array
  24511. * @param {Array} pairs The key-value pairs.
  24512. * @returns {Object} Returns the new object.
  24513. * @example
  24514. *
  24515. * _.fromPairs([['a', 1], ['b', 2]]);
  24516. * // => { 'a': 1, 'b': 2 }
  24517. */
  24518. function fromPairs(pairs) {
  24519. var index = -1,
  24520. length = pairs == null ? 0 : pairs.length,
  24521. result = {};
  24522. while (++index < length) {
  24523. var pair = pairs[index];
  24524. result[pair[0]] = pair[1];
  24525. }
  24526. return result;
  24527. }
  24528. /**
  24529. * Gets the first element of `array`.
  24530. *
  24531. * @static
  24532. * @memberOf _
  24533. * @since 0.1.0
  24534. * @alias first
  24535. * @category Array
  24536. * @param {Array} array The array to query.
  24537. * @returns {*} Returns the first element of `array`.
  24538. * @example
  24539. *
  24540. * _.head([1, 2, 3]);
  24541. * // => 1
  24542. *
  24543. * _.head([]);
  24544. * // => undefined
  24545. */
  24546. function head(array) {
  24547. return (array && array.length) ? array[0] : undefined;
  24548. }
  24549. /**
  24550. * Gets the index at which the first occurrence of `value` is found in `array`
  24551. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24552. * for equality comparisons. If `fromIndex` is negative, it's used as the
  24553. * offset from the end of `array`.
  24554. *
  24555. * @static
  24556. * @memberOf _
  24557. * @since 0.1.0
  24558. * @category Array
  24559. * @param {Array} array The array to inspect.
  24560. * @param {*} value The value to search for.
  24561. * @param {number} [fromIndex=0] The index to search from.
  24562. * @returns {number} Returns the index of the matched value, else `-1`.
  24563. * @example
  24564. *
  24565. * _.indexOf([1, 2, 1, 2], 2);
  24566. * // => 1
  24567. *
  24568. * // Search from the `fromIndex`.
  24569. * _.indexOf([1, 2, 1, 2], 2, 2);
  24570. * // => 3
  24571. */
  24572. function indexOf(array, value, fromIndex) {
  24573. var length = array == null ? 0 : array.length;
  24574. if (!length) {
  24575. return -1;
  24576. }
  24577. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  24578. if (index < 0) {
  24579. index = nativeMax(length + index, 0);
  24580. }
  24581. return baseIndexOf(array, value, index);
  24582. }
  24583. /**
  24584. * Gets all but the last element of `array`.
  24585. *
  24586. * @static
  24587. * @memberOf _
  24588. * @since 0.1.0
  24589. * @category Array
  24590. * @param {Array} array The array to query.
  24591. * @returns {Array} Returns the slice of `array`.
  24592. * @example
  24593. *
  24594. * _.initial([1, 2, 3]);
  24595. * // => [1, 2]
  24596. */
  24597. function initial(array) {
  24598. var length = array == null ? 0 : array.length;
  24599. return length ? baseSlice(array, 0, -1) : [];
  24600. }
  24601. /**
  24602. * Creates an array of unique values that are included in all given arrays
  24603. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24604. * for equality comparisons. The order and references of result values are
  24605. * determined by the first array.
  24606. *
  24607. * @static
  24608. * @memberOf _
  24609. * @since 0.1.0
  24610. * @category Array
  24611. * @param {...Array} [arrays] The arrays to inspect.
  24612. * @returns {Array} Returns the new array of intersecting values.
  24613. * @example
  24614. *
  24615. * _.intersection([2, 1], [2, 3]);
  24616. * // => [2]
  24617. */
  24618. var intersection = baseRest(function(arrays) {
  24619. var mapped = arrayMap(arrays, castArrayLikeObject);
  24620. return (mapped.length && mapped[0] === arrays[0])
  24621. ? baseIntersection(mapped)
  24622. : [];
  24623. });
  24624. /**
  24625. * This method is like `_.intersection` except that it accepts `iteratee`
  24626. * which is invoked for each element of each `arrays` to generate the criterion
  24627. * by which they're compared. The order and references of result values are
  24628. * determined by the first array. The iteratee is invoked with one argument:
  24629. * (value).
  24630. *
  24631. * @static
  24632. * @memberOf _
  24633. * @since 4.0.0
  24634. * @category Array
  24635. * @param {...Array} [arrays] The arrays to inspect.
  24636. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24637. * @returns {Array} Returns the new array of intersecting values.
  24638. * @example
  24639. *
  24640. * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  24641. * // => [2.1]
  24642. *
  24643. * // The `_.property` iteratee shorthand.
  24644. * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  24645. * // => [{ 'x': 1 }]
  24646. */
  24647. var intersectionBy = baseRest(function(arrays) {
  24648. var iteratee = last(arrays),
  24649. mapped = arrayMap(arrays, castArrayLikeObject);
  24650. if (iteratee === last(mapped)) {
  24651. iteratee = undefined;
  24652. } else {
  24653. mapped.pop();
  24654. }
  24655. return (mapped.length && mapped[0] === arrays[0])
  24656. ? baseIntersection(mapped, getIteratee(iteratee, 2))
  24657. : [];
  24658. });
  24659. /**
  24660. * This method is like `_.intersection` except that it accepts `comparator`
  24661. * which is invoked to compare elements of `arrays`. The order and references
  24662. * of result values are determined by the first array. The comparator is
  24663. * invoked with two arguments: (arrVal, othVal).
  24664. *
  24665. * @static
  24666. * @memberOf _
  24667. * @since 4.0.0
  24668. * @category Array
  24669. * @param {...Array} [arrays] The arrays to inspect.
  24670. * @param {Function} [comparator] The comparator invoked per element.
  24671. * @returns {Array} Returns the new array of intersecting values.
  24672. * @example
  24673. *
  24674. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  24675. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  24676. *
  24677. * _.intersectionWith(objects, others, _.isEqual);
  24678. * // => [{ 'x': 1, 'y': 2 }]
  24679. */
  24680. var intersectionWith = baseRest(function(arrays) {
  24681. var comparator = last(arrays),
  24682. mapped = arrayMap(arrays, castArrayLikeObject);
  24683. comparator = typeof comparator == 'function' ? comparator : undefined;
  24684. if (comparator) {
  24685. mapped.pop();
  24686. }
  24687. return (mapped.length && mapped[0] === arrays[0])
  24688. ? baseIntersection(mapped, undefined, comparator)
  24689. : [];
  24690. });
  24691. /**
  24692. * Converts all elements in `array` into a string separated by `separator`.
  24693. *
  24694. * @static
  24695. * @memberOf _
  24696. * @since 4.0.0
  24697. * @category Array
  24698. * @param {Array} array The array to convert.
  24699. * @param {string} [separator=','] The element separator.
  24700. * @returns {string} Returns the joined string.
  24701. * @example
  24702. *
  24703. * _.join(['a', 'b', 'c'], '~');
  24704. * // => 'a~b~c'
  24705. */
  24706. function join(array, separator) {
  24707. return array == null ? '' : nativeJoin.call(array, separator);
  24708. }
  24709. /**
  24710. * Gets the last element of `array`.
  24711. *
  24712. * @static
  24713. * @memberOf _
  24714. * @since 0.1.0
  24715. * @category Array
  24716. * @param {Array} array The array to query.
  24717. * @returns {*} Returns the last element of `array`.
  24718. * @example
  24719. *
  24720. * _.last([1, 2, 3]);
  24721. * // => 3
  24722. */
  24723. function last(array) {
  24724. var length = array == null ? 0 : array.length;
  24725. return length ? array[length - 1] : undefined;
  24726. }
  24727. /**
  24728. * This method is like `_.indexOf` except that it iterates over elements of
  24729. * `array` from right to left.
  24730. *
  24731. * @static
  24732. * @memberOf _
  24733. * @since 0.1.0
  24734. * @category Array
  24735. * @param {Array} array The array to inspect.
  24736. * @param {*} value The value to search for.
  24737. * @param {number} [fromIndex=array.length-1] The index to search from.
  24738. * @returns {number} Returns the index of the matched value, else `-1`.
  24739. * @example
  24740. *
  24741. * _.lastIndexOf([1, 2, 1, 2], 2);
  24742. * // => 3
  24743. *
  24744. * // Search from the `fromIndex`.
  24745. * _.lastIndexOf([1, 2, 1, 2], 2, 2);
  24746. * // => 1
  24747. */
  24748. function lastIndexOf(array, value, fromIndex) {
  24749. var length = array == null ? 0 : array.length;
  24750. if (!length) {
  24751. return -1;
  24752. }
  24753. var index = length;
  24754. if (fromIndex !== undefined) {
  24755. index = toInteger(fromIndex);
  24756. index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
  24757. }
  24758. return value === value
  24759. ? strictLastIndexOf(array, value, index)
  24760. : baseFindIndex(array, baseIsNaN, index, true);
  24761. }
  24762. /**
  24763. * Gets the element at index `n` of `array`. If `n` is negative, the nth
  24764. * element from the end is returned.
  24765. *
  24766. * @static
  24767. * @memberOf _
  24768. * @since 4.11.0
  24769. * @category Array
  24770. * @param {Array} array The array to query.
  24771. * @param {number} [n=0] The index of the element to return.
  24772. * @returns {*} Returns the nth element of `array`.
  24773. * @example
  24774. *
  24775. * var array = ['a', 'b', 'c', 'd'];
  24776. *
  24777. * _.nth(array, 1);
  24778. * // => 'b'
  24779. *
  24780. * _.nth(array, -2);
  24781. * // => 'c';
  24782. */
  24783. function nth(array, n) {
  24784. return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
  24785. }
  24786. /**
  24787. * Removes all given values from `array` using
  24788. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  24789. * for equality comparisons.
  24790. *
  24791. * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
  24792. * to remove elements from an array by predicate.
  24793. *
  24794. * @static
  24795. * @memberOf _
  24796. * @since 2.0.0
  24797. * @category Array
  24798. * @param {Array} array The array to modify.
  24799. * @param {...*} [values] The values to remove.
  24800. * @returns {Array} Returns `array`.
  24801. * @example
  24802. *
  24803. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  24804. *
  24805. * _.pull(array, 'a', 'c');
  24806. * console.log(array);
  24807. * // => ['b', 'b']
  24808. */
  24809. var pull = baseRest(pullAll);
  24810. /**
  24811. * This method is like `_.pull` except that it accepts an array of values to remove.
  24812. *
  24813. * **Note:** Unlike `_.difference`, this method mutates `array`.
  24814. *
  24815. * @static
  24816. * @memberOf _
  24817. * @since 4.0.0
  24818. * @category Array
  24819. * @param {Array} array The array to modify.
  24820. * @param {Array} values The values to remove.
  24821. * @returns {Array} Returns `array`.
  24822. * @example
  24823. *
  24824. * var array = ['a', 'b', 'c', 'a', 'b', 'c'];
  24825. *
  24826. * _.pullAll(array, ['a', 'c']);
  24827. * console.log(array);
  24828. * // => ['b', 'b']
  24829. */
  24830. function pullAll(array, values) {
  24831. return (array && array.length && values && values.length)
  24832. ? basePullAll(array, values)
  24833. : array;
  24834. }
  24835. /**
  24836. * This method is like `_.pullAll` except that it accepts `iteratee` which is
  24837. * invoked for each element of `array` and `values` to generate the criterion
  24838. * by which they're compared. The iteratee is invoked with one argument: (value).
  24839. *
  24840. * **Note:** Unlike `_.differenceBy`, this method mutates `array`.
  24841. *
  24842. * @static
  24843. * @memberOf _
  24844. * @since 4.0.0
  24845. * @category Array
  24846. * @param {Array} array The array to modify.
  24847. * @param {Array} values The values to remove.
  24848. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  24849. * @returns {Array} Returns `array`.
  24850. * @example
  24851. *
  24852. * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
  24853. *
  24854. * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
  24855. * console.log(array);
  24856. * // => [{ 'x': 2 }]
  24857. */
  24858. function pullAllBy(array, values, iteratee) {
  24859. return (array && array.length && values && values.length)
  24860. ? basePullAll(array, values, getIteratee(iteratee, 2))
  24861. : array;
  24862. }
  24863. /**
  24864. * This method is like `_.pullAll` except that it accepts `comparator` which
  24865. * is invoked to compare elements of `array` to `values`. The comparator is
  24866. * invoked with two arguments: (arrVal, othVal).
  24867. *
  24868. * **Note:** Unlike `_.differenceWith`, this method mutates `array`.
  24869. *
  24870. * @static
  24871. * @memberOf _
  24872. * @since 4.6.0
  24873. * @category Array
  24874. * @param {Array} array The array to modify.
  24875. * @param {Array} values The values to remove.
  24876. * @param {Function} [comparator] The comparator invoked per element.
  24877. * @returns {Array} Returns `array`.
  24878. * @example
  24879. *
  24880. * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
  24881. *
  24882. * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual);
  24883. * console.log(array);
  24884. * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
  24885. */
  24886. function pullAllWith(array, values, comparator) {
  24887. return (array && array.length && values && values.length)
  24888. ? basePullAll(array, values, undefined, comparator)
  24889. : array;
  24890. }
  24891. /**
  24892. * Removes elements from `array` corresponding to `indexes` and returns an
  24893. * array of removed elements.
  24894. *
  24895. * **Note:** Unlike `_.at`, this method mutates `array`.
  24896. *
  24897. * @static
  24898. * @memberOf _
  24899. * @since 3.0.0
  24900. * @category Array
  24901. * @param {Array} array The array to modify.
  24902. * @param {...(number|number[])} [indexes] The indexes of elements to remove.
  24903. * @returns {Array} Returns the new array of removed elements.
  24904. * @example
  24905. *
  24906. * var array = ['a', 'b', 'c', 'd'];
  24907. * var pulled = _.pullAt(array, [1, 3]);
  24908. *
  24909. * console.log(array);
  24910. * // => ['a', 'c']
  24911. *
  24912. * console.log(pulled);
  24913. * // => ['b', 'd']
  24914. */
  24915. var pullAt = flatRest(function(array, indexes) {
  24916. var length = array == null ? 0 : array.length,
  24917. result = baseAt(array, indexes);
  24918. basePullAt(array, arrayMap(indexes, function(index) {
  24919. return isIndex(index, length) ? +index : index;
  24920. }).sort(compareAscending));
  24921. return result;
  24922. });
  24923. /**
  24924. * Removes all elements from `array` that `predicate` returns truthy for
  24925. * and returns an array of the removed elements. The predicate is invoked
  24926. * with three arguments: (value, index, array).
  24927. *
  24928. * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull`
  24929. * to pull elements from an array by value.
  24930. *
  24931. * @static
  24932. * @memberOf _
  24933. * @since 2.0.0
  24934. * @category Array
  24935. * @param {Array} array The array to modify.
  24936. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  24937. * @returns {Array} Returns the new array of removed elements.
  24938. * @example
  24939. *
  24940. * var array = [1, 2, 3, 4];
  24941. * var evens = _.remove(array, function(n) {
  24942. * return n % 2 == 0;
  24943. * });
  24944. *
  24945. * console.log(array);
  24946. * // => [1, 3]
  24947. *
  24948. * console.log(evens);
  24949. * // => [2, 4]
  24950. */
  24951. function remove(array, predicate) {
  24952. var result = [];
  24953. if (!(array && array.length)) {
  24954. return result;
  24955. }
  24956. var index = -1,
  24957. indexes = [],
  24958. length = array.length;
  24959. predicate = getIteratee(predicate, 3);
  24960. while (++index < length) {
  24961. var value = array[index];
  24962. if (predicate(value, index, array)) {
  24963. result.push(value);
  24964. indexes.push(index);
  24965. }
  24966. }
  24967. basePullAt(array, indexes);
  24968. return result;
  24969. }
  24970. /**
  24971. * Reverses `array` so that the first element becomes the last, the second
  24972. * element becomes the second to last, and so on.
  24973. *
  24974. * **Note:** This method mutates `array` and is based on
  24975. * [`Array#reverse`](https://mdn.io/Array/reverse).
  24976. *
  24977. * @static
  24978. * @memberOf _
  24979. * @since 4.0.0
  24980. * @category Array
  24981. * @param {Array} array The array to modify.
  24982. * @returns {Array} Returns `array`.
  24983. * @example
  24984. *
  24985. * var array = [1, 2, 3];
  24986. *
  24987. * _.reverse(array);
  24988. * // => [3, 2, 1]
  24989. *
  24990. * console.log(array);
  24991. * // => [3, 2, 1]
  24992. */
  24993. function reverse(array) {
  24994. return array == null ? array : nativeReverse.call(array);
  24995. }
  24996. /**
  24997. * Creates a slice of `array` from `start` up to, but not including, `end`.
  24998. *
  24999. * **Note:** This method is used instead of
  25000. * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are
  25001. * returned.
  25002. *
  25003. * @static
  25004. * @memberOf _
  25005. * @since 3.0.0
  25006. * @category Array
  25007. * @param {Array} array The array to slice.
  25008. * @param {number} [start=0] The start position.
  25009. * @param {number} [end=array.length] The end position.
  25010. * @returns {Array} Returns the slice of `array`.
  25011. */
  25012. function slice(array, start, end) {
  25013. var length = array == null ? 0 : array.length;
  25014. if (!length) {
  25015. return [];
  25016. }
  25017. if (end && typeof end != 'number' && isIterateeCall(array, start, end)) {
  25018. start = 0;
  25019. end = length;
  25020. }
  25021. else {
  25022. start = start == null ? 0 : toInteger(start);
  25023. end = end === undefined ? length : toInteger(end);
  25024. }
  25025. return baseSlice(array, start, end);
  25026. }
  25027. /**
  25028. * Uses a binary search to determine the lowest index at which `value`
  25029. * should be inserted into `array` in order to maintain its sort order.
  25030. *
  25031. * @static
  25032. * @memberOf _
  25033. * @since 0.1.0
  25034. * @category Array
  25035. * @param {Array} array The sorted array to inspect.
  25036. * @param {*} value The value to evaluate.
  25037. * @returns {number} Returns the index at which `value` should be inserted
  25038. * into `array`.
  25039. * @example
  25040. *
  25041. * _.sortedIndex([30, 50], 40);
  25042. * // => 1
  25043. */
  25044. function sortedIndex(array, value) {
  25045. return baseSortedIndex(array, value);
  25046. }
  25047. /**
  25048. * This method is like `_.sortedIndex` except that it accepts `iteratee`
  25049. * which is invoked for `value` and each element of `array` to compute their
  25050. * sort ranking. The iteratee is invoked with one argument: (value).
  25051. *
  25052. * @static
  25053. * @memberOf _
  25054. * @since 4.0.0
  25055. * @category Array
  25056. * @param {Array} array The sorted array to inspect.
  25057. * @param {*} value The value to evaluate.
  25058. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25059. * @returns {number} Returns the index at which `value` should be inserted
  25060. * into `array`.
  25061. * @example
  25062. *
  25063. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  25064. *
  25065. * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  25066. * // => 0
  25067. *
  25068. * // The `_.property` iteratee shorthand.
  25069. * _.sortedIndexBy(objects, { 'x': 4 }, 'x');
  25070. * // => 0
  25071. */
  25072. function sortedIndexBy(array, value, iteratee) {
  25073. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
  25074. }
  25075. /**
  25076. * This method is like `_.indexOf` except that it performs a binary
  25077. * search on a sorted `array`.
  25078. *
  25079. * @static
  25080. * @memberOf _
  25081. * @since 4.0.0
  25082. * @category Array
  25083. * @param {Array} array The array to inspect.
  25084. * @param {*} value The value to search for.
  25085. * @returns {number} Returns the index of the matched value, else `-1`.
  25086. * @example
  25087. *
  25088. * _.sortedIndexOf([4, 5, 5, 5, 6], 5);
  25089. * // => 1
  25090. */
  25091. function sortedIndexOf(array, value) {
  25092. var length = array == null ? 0 : array.length;
  25093. if (length) {
  25094. var index = baseSortedIndex(array, value);
  25095. if (index < length && eq(array[index], value)) {
  25096. return index;
  25097. }
  25098. }
  25099. return -1;
  25100. }
  25101. /**
  25102. * This method is like `_.sortedIndex` except that it returns the highest
  25103. * index at which `value` should be inserted into `array` in order to
  25104. * maintain its sort order.
  25105. *
  25106. * @static
  25107. * @memberOf _
  25108. * @since 3.0.0
  25109. * @category Array
  25110. * @param {Array} array The sorted array to inspect.
  25111. * @param {*} value The value to evaluate.
  25112. * @returns {number} Returns the index at which `value` should be inserted
  25113. * into `array`.
  25114. * @example
  25115. *
  25116. * _.sortedLastIndex([4, 5, 5, 5, 6], 5);
  25117. * // => 4
  25118. */
  25119. function sortedLastIndex(array, value) {
  25120. return baseSortedIndex(array, value, true);
  25121. }
  25122. /**
  25123. * This method is like `_.sortedLastIndex` except that it accepts `iteratee`
  25124. * which is invoked for `value` and each element of `array` to compute their
  25125. * sort ranking. The iteratee is invoked with one argument: (value).
  25126. *
  25127. * @static
  25128. * @memberOf _
  25129. * @since 4.0.0
  25130. * @category Array
  25131. * @param {Array} array The sorted array to inspect.
  25132. * @param {*} value The value to evaluate.
  25133. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25134. * @returns {number} Returns the index at which `value` should be inserted
  25135. * into `array`.
  25136. * @example
  25137. *
  25138. * var objects = [{ 'x': 4 }, { 'x': 5 }];
  25139. *
  25140. * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
  25141. * // => 1
  25142. *
  25143. * // The `_.property` iteratee shorthand.
  25144. * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x');
  25145. * // => 1
  25146. */
  25147. function sortedLastIndexBy(array, value, iteratee) {
  25148. return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
  25149. }
  25150. /**
  25151. * This method is like `_.lastIndexOf` except that it performs a binary
  25152. * search on a sorted `array`.
  25153. *
  25154. * @static
  25155. * @memberOf _
  25156. * @since 4.0.0
  25157. * @category Array
  25158. * @param {Array} array The array to inspect.
  25159. * @param {*} value The value to search for.
  25160. * @returns {number} Returns the index of the matched value, else `-1`.
  25161. * @example
  25162. *
  25163. * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5);
  25164. * // => 3
  25165. */
  25166. function sortedLastIndexOf(array, value) {
  25167. var length = array == null ? 0 : array.length;
  25168. if (length) {
  25169. var index = baseSortedIndex(array, value, true) - 1;
  25170. if (eq(array[index], value)) {
  25171. return index;
  25172. }
  25173. }
  25174. return -1;
  25175. }
  25176. /**
  25177. * This method is like `_.uniq` except that it's designed and optimized
  25178. * for sorted arrays.
  25179. *
  25180. * @static
  25181. * @memberOf _
  25182. * @since 4.0.0
  25183. * @category Array
  25184. * @param {Array} array The array to inspect.
  25185. * @returns {Array} Returns the new duplicate free array.
  25186. * @example
  25187. *
  25188. * _.sortedUniq([1, 1, 2]);
  25189. * // => [1, 2]
  25190. */
  25191. function sortedUniq(array) {
  25192. return (array && array.length)
  25193. ? baseSortedUniq(array)
  25194. : [];
  25195. }
  25196. /**
  25197. * This method is like `_.uniqBy` except that it's designed and optimized
  25198. * for sorted arrays.
  25199. *
  25200. * @static
  25201. * @memberOf _
  25202. * @since 4.0.0
  25203. * @category Array
  25204. * @param {Array} array The array to inspect.
  25205. * @param {Function} [iteratee] The iteratee invoked per element.
  25206. * @returns {Array} Returns the new duplicate free array.
  25207. * @example
  25208. *
  25209. * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
  25210. * // => [1.1, 2.3]
  25211. */
  25212. function sortedUniqBy(array, iteratee) {
  25213. return (array && array.length)
  25214. ? baseSortedUniq(array, getIteratee(iteratee, 2))
  25215. : [];
  25216. }
  25217. /**
  25218. * Gets all but the first element of `array`.
  25219. *
  25220. * @static
  25221. * @memberOf _
  25222. * @since 4.0.0
  25223. * @category Array
  25224. * @param {Array} array The array to query.
  25225. * @returns {Array} Returns the slice of `array`.
  25226. * @example
  25227. *
  25228. * _.tail([1, 2, 3]);
  25229. * // => [2, 3]
  25230. */
  25231. function tail(array) {
  25232. var length = array == null ? 0 : array.length;
  25233. return length ? baseSlice(array, 1, length) : [];
  25234. }
  25235. /**
  25236. * Creates a slice of `array` with `n` elements taken from the beginning.
  25237. *
  25238. * @static
  25239. * @memberOf _
  25240. * @since 0.1.0
  25241. * @category Array
  25242. * @param {Array} array The array to query.
  25243. * @param {number} [n=1] The number of elements to take.
  25244. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25245. * @returns {Array} Returns the slice of `array`.
  25246. * @example
  25247. *
  25248. * _.take([1, 2, 3]);
  25249. * // => [1]
  25250. *
  25251. * _.take([1, 2, 3], 2);
  25252. * // => [1, 2]
  25253. *
  25254. * _.take([1, 2, 3], 5);
  25255. * // => [1, 2, 3]
  25256. *
  25257. * _.take([1, 2, 3], 0);
  25258. * // => []
  25259. */
  25260. function take(array, n, guard) {
  25261. if (!(array && array.length)) {
  25262. return [];
  25263. }
  25264. n = (guard || n === undefined) ? 1 : toInteger(n);
  25265. return baseSlice(array, 0, n < 0 ? 0 : n);
  25266. }
  25267. /**
  25268. * Creates a slice of `array` with `n` elements taken from the end.
  25269. *
  25270. * @static
  25271. * @memberOf _
  25272. * @since 3.0.0
  25273. * @category Array
  25274. * @param {Array} array The array to query.
  25275. * @param {number} [n=1] The number of elements to take.
  25276. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  25277. * @returns {Array} Returns the slice of `array`.
  25278. * @example
  25279. *
  25280. * _.takeRight([1, 2, 3]);
  25281. * // => [3]
  25282. *
  25283. * _.takeRight([1, 2, 3], 2);
  25284. * // => [2, 3]
  25285. *
  25286. * _.takeRight([1, 2, 3], 5);
  25287. * // => [1, 2, 3]
  25288. *
  25289. * _.takeRight([1, 2, 3], 0);
  25290. * // => []
  25291. */
  25292. function takeRight(array, n, guard) {
  25293. var length = array == null ? 0 : array.length;
  25294. if (!length) {
  25295. return [];
  25296. }
  25297. n = (guard || n === undefined) ? 1 : toInteger(n);
  25298. n = length - n;
  25299. return baseSlice(array, n < 0 ? 0 : n, length);
  25300. }
  25301. /**
  25302. * Creates a slice of `array` with elements taken from the end. Elements are
  25303. * taken until `predicate` returns falsey. The predicate is invoked with
  25304. * three arguments: (value, index, array).
  25305. *
  25306. * @static
  25307. * @memberOf _
  25308. * @since 3.0.0
  25309. * @category Array
  25310. * @param {Array} array The array to query.
  25311. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25312. * @returns {Array} Returns the slice of `array`.
  25313. * @example
  25314. *
  25315. * var users = [
  25316. * { 'user': 'barney', 'active': true },
  25317. * { 'user': 'fred', 'active': false },
  25318. * { 'user': 'pebbles', 'active': false }
  25319. * ];
  25320. *
  25321. * _.takeRightWhile(users, function(o) { return !o.active; });
  25322. * // => objects for ['fred', 'pebbles']
  25323. *
  25324. * // The `_.matches` iteratee shorthand.
  25325. * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
  25326. * // => objects for ['pebbles']
  25327. *
  25328. * // The `_.matchesProperty` iteratee shorthand.
  25329. * _.takeRightWhile(users, ['active', false]);
  25330. * // => objects for ['fred', 'pebbles']
  25331. *
  25332. * // The `_.property` iteratee shorthand.
  25333. * _.takeRightWhile(users, 'active');
  25334. * // => []
  25335. */
  25336. function takeRightWhile(array, predicate) {
  25337. return (array && array.length)
  25338. ? baseWhile(array, getIteratee(predicate, 3), false, true)
  25339. : [];
  25340. }
  25341. /**
  25342. * Creates a slice of `array` with elements taken from the beginning. Elements
  25343. * are taken until `predicate` returns falsey. The predicate is invoked with
  25344. * three arguments: (value, index, array).
  25345. *
  25346. * @static
  25347. * @memberOf _
  25348. * @since 3.0.0
  25349. * @category Array
  25350. * @param {Array} array The array to query.
  25351. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  25352. * @returns {Array} Returns the slice of `array`.
  25353. * @example
  25354. *
  25355. * var users = [
  25356. * { 'user': 'barney', 'active': false },
  25357. * { 'user': 'fred', 'active': false },
  25358. * { 'user': 'pebbles', 'active': true }
  25359. * ];
  25360. *
  25361. * _.takeWhile(users, function(o) { return !o.active; });
  25362. * // => objects for ['barney', 'fred']
  25363. *
  25364. * // The `_.matches` iteratee shorthand.
  25365. * _.takeWhile(users, { 'user': 'barney', 'active': false });
  25366. * // => objects for ['barney']
  25367. *
  25368. * // The `_.matchesProperty` iteratee shorthand.
  25369. * _.takeWhile(users, ['active', false]);
  25370. * // => objects for ['barney', 'fred']
  25371. *
  25372. * // The `_.property` iteratee shorthand.
  25373. * _.takeWhile(users, 'active');
  25374. * // => []
  25375. */
  25376. function takeWhile(array, predicate) {
  25377. return (array && array.length)
  25378. ? baseWhile(array, getIteratee(predicate, 3))
  25379. : [];
  25380. }
  25381. /**
  25382. * Creates an array of unique values, in order, from all given arrays using
  25383. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25384. * for equality comparisons.
  25385. *
  25386. * @static
  25387. * @memberOf _
  25388. * @since 0.1.0
  25389. * @category Array
  25390. * @param {...Array} [arrays] The arrays to inspect.
  25391. * @returns {Array} Returns the new array of combined values.
  25392. * @example
  25393. *
  25394. * _.union([2], [1, 2]);
  25395. * // => [2, 1]
  25396. */
  25397. var union = baseRest(function(arrays) {
  25398. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
  25399. });
  25400. /**
  25401. * This method is like `_.union` except that it accepts `iteratee` which is
  25402. * invoked for each element of each `arrays` to generate the criterion by
  25403. * which uniqueness is computed. Result values are chosen from the first
  25404. * array in which the value occurs. The iteratee is invoked with one argument:
  25405. * (value).
  25406. *
  25407. * @static
  25408. * @memberOf _
  25409. * @since 4.0.0
  25410. * @category Array
  25411. * @param {...Array} [arrays] The arrays to inspect.
  25412. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25413. * @returns {Array} Returns the new array of combined values.
  25414. * @example
  25415. *
  25416. * _.unionBy([2.1], [1.2, 2.3], Math.floor);
  25417. * // => [2.1, 1.2]
  25418. *
  25419. * // The `_.property` iteratee shorthand.
  25420. * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  25421. * // => [{ 'x': 1 }, { 'x': 2 }]
  25422. */
  25423. var unionBy = baseRest(function(arrays) {
  25424. var iteratee = last(arrays);
  25425. if (isArrayLikeObject(iteratee)) {
  25426. iteratee = undefined;
  25427. }
  25428. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
  25429. });
  25430. /**
  25431. * This method is like `_.union` except that it accepts `comparator` which
  25432. * is invoked to compare elements of `arrays`. Result values are chosen from
  25433. * the first array in which the value occurs. The comparator is invoked
  25434. * with two arguments: (arrVal, othVal).
  25435. *
  25436. * @static
  25437. * @memberOf _
  25438. * @since 4.0.0
  25439. * @category Array
  25440. * @param {...Array} [arrays] The arrays to inspect.
  25441. * @param {Function} [comparator] The comparator invoked per element.
  25442. * @returns {Array} Returns the new array of combined values.
  25443. * @example
  25444. *
  25445. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  25446. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25447. *
  25448. * _.unionWith(objects, others, _.isEqual);
  25449. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  25450. */
  25451. var unionWith = baseRest(function(arrays) {
  25452. var comparator = last(arrays);
  25453. comparator = typeof comparator == 'function' ? comparator : undefined;
  25454. return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
  25455. });
  25456. /**
  25457. * Creates a duplicate-free version of an array, using
  25458. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25459. * for equality comparisons, in which only the first occurrence of each element
  25460. * is kept. The order of result values is determined by the order they occur
  25461. * in the array.
  25462. *
  25463. * @static
  25464. * @memberOf _
  25465. * @since 0.1.0
  25466. * @category Array
  25467. * @param {Array} array The array to inspect.
  25468. * @returns {Array} Returns the new duplicate free array.
  25469. * @example
  25470. *
  25471. * _.uniq([2, 1, 2]);
  25472. * // => [2, 1]
  25473. */
  25474. function uniq(array) {
  25475. return (array && array.length) ? baseUniq(array) : [];
  25476. }
  25477. /**
  25478. * This method is like `_.uniq` except that it accepts `iteratee` which is
  25479. * invoked for each element in `array` to generate the criterion by which
  25480. * uniqueness is computed. The order of result values is determined by the
  25481. * order they occur in the array. The iteratee is invoked with one argument:
  25482. * (value).
  25483. *
  25484. * @static
  25485. * @memberOf _
  25486. * @since 4.0.0
  25487. * @category Array
  25488. * @param {Array} array The array to inspect.
  25489. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25490. * @returns {Array} Returns the new duplicate free array.
  25491. * @example
  25492. *
  25493. * _.uniqBy([2.1, 1.2, 2.3], Math.floor);
  25494. * // => [2.1, 1.2]
  25495. *
  25496. * // The `_.property` iteratee shorthand.
  25497. * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
  25498. * // => [{ 'x': 1 }, { 'x': 2 }]
  25499. */
  25500. function uniqBy(array, iteratee) {
  25501. return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
  25502. }
  25503. /**
  25504. * This method is like `_.uniq` except that it accepts `comparator` which
  25505. * is invoked to compare elements of `array`. The order of result values is
  25506. * determined by the order they occur in the array.The comparator is invoked
  25507. * with two arguments: (arrVal, othVal).
  25508. *
  25509. * @static
  25510. * @memberOf _
  25511. * @since 4.0.0
  25512. * @category Array
  25513. * @param {Array} array The array to inspect.
  25514. * @param {Function} [comparator] The comparator invoked per element.
  25515. * @returns {Array} Returns the new duplicate free array.
  25516. * @example
  25517. *
  25518. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25519. *
  25520. * _.uniqWith(objects, _.isEqual);
  25521. * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
  25522. */
  25523. function uniqWith(array, comparator) {
  25524. comparator = typeof comparator == 'function' ? comparator : undefined;
  25525. return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
  25526. }
  25527. /**
  25528. * This method is like `_.zip` except that it accepts an array of grouped
  25529. * elements and creates an array regrouping the elements to their pre-zip
  25530. * configuration.
  25531. *
  25532. * @static
  25533. * @memberOf _
  25534. * @since 1.2.0
  25535. * @category Array
  25536. * @param {Array} array The array of grouped elements to process.
  25537. * @returns {Array} Returns the new array of regrouped elements.
  25538. * @example
  25539. *
  25540. * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
  25541. * // => [['a', 1, true], ['b', 2, false]]
  25542. *
  25543. * _.unzip(zipped);
  25544. * // => [['a', 'b'], [1, 2], [true, false]]
  25545. */
  25546. function unzip(array) {
  25547. if (!(array && array.length)) {
  25548. return [];
  25549. }
  25550. var length = 0;
  25551. array = arrayFilter(array, function(group) {
  25552. if (isArrayLikeObject(group)) {
  25553. length = nativeMax(group.length, length);
  25554. return true;
  25555. }
  25556. });
  25557. return baseTimes(length, function(index) {
  25558. return arrayMap(array, baseProperty(index));
  25559. });
  25560. }
  25561. /**
  25562. * This method is like `_.unzip` except that it accepts `iteratee` to specify
  25563. * how regrouped values should be combined. The iteratee is invoked with the
  25564. * elements of each group: (...group).
  25565. *
  25566. * @static
  25567. * @memberOf _
  25568. * @since 3.8.0
  25569. * @category Array
  25570. * @param {Array} array The array of grouped elements to process.
  25571. * @param {Function} [iteratee=_.identity] The function to combine
  25572. * regrouped values.
  25573. * @returns {Array} Returns the new array of regrouped elements.
  25574. * @example
  25575. *
  25576. * var zipped = _.zip([1, 2], [10, 20], [100, 200]);
  25577. * // => [[1, 10, 100], [2, 20, 200]]
  25578. *
  25579. * _.unzipWith(zipped, _.add);
  25580. * // => [3, 30, 300]
  25581. */
  25582. function unzipWith(array, iteratee) {
  25583. if (!(array && array.length)) {
  25584. return [];
  25585. }
  25586. var result = unzip(array);
  25587. if (iteratee == null) {
  25588. return result;
  25589. }
  25590. return arrayMap(result, function(group) {
  25591. return apply(iteratee, undefined, group);
  25592. });
  25593. }
  25594. /**
  25595. * Creates an array excluding all given values using
  25596. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  25597. * for equality comparisons.
  25598. *
  25599. * **Note:** Unlike `_.pull`, this method returns a new array.
  25600. *
  25601. * @static
  25602. * @memberOf _
  25603. * @since 0.1.0
  25604. * @category Array
  25605. * @param {Array} array The array to inspect.
  25606. * @param {...*} [values] The values to exclude.
  25607. * @returns {Array} Returns the new array of filtered values.
  25608. * @see _.difference, _.xor
  25609. * @example
  25610. *
  25611. * _.without([2, 1, 2, 3], 1, 2);
  25612. * // => [3]
  25613. */
  25614. var without = baseRest(function(array, values) {
  25615. return isArrayLikeObject(array)
  25616. ? baseDifference(array, values)
  25617. : [];
  25618. });
  25619. /**
  25620. * Creates an array of unique values that is the
  25621. * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
  25622. * of the given arrays. The order of result values is determined by the order
  25623. * they occur in the arrays.
  25624. *
  25625. * @static
  25626. * @memberOf _
  25627. * @since 2.4.0
  25628. * @category Array
  25629. * @param {...Array} [arrays] The arrays to inspect.
  25630. * @returns {Array} Returns the new array of filtered values.
  25631. * @see _.difference, _.without
  25632. * @example
  25633. *
  25634. * _.xor([2, 1], [2, 3]);
  25635. * // => [1, 3]
  25636. */
  25637. var xor = baseRest(function(arrays) {
  25638. return baseXor(arrayFilter(arrays, isArrayLikeObject));
  25639. });
  25640. /**
  25641. * This method is like `_.xor` except that it accepts `iteratee` which is
  25642. * invoked for each element of each `arrays` to generate the criterion by
  25643. * which by which they're compared. The order of result values is determined
  25644. * by the order they occur in the arrays. The iteratee is invoked with one
  25645. * argument: (value).
  25646. *
  25647. * @static
  25648. * @memberOf _
  25649. * @since 4.0.0
  25650. * @category Array
  25651. * @param {...Array} [arrays] The arrays to inspect.
  25652. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  25653. * @returns {Array} Returns the new array of filtered values.
  25654. * @example
  25655. *
  25656. * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor);
  25657. * // => [1.2, 3.4]
  25658. *
  25659. * // The `_.property` iteratee shorthand.
  25660. * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
  25661. * // => [{ 'x': 2 }]
  25662. */
  25663. var xorBy = baseRest(function(arrays) {
  25664. var iteratee = last(arrays);
  25665. if (isArrayLikeObject(iteratee)) {
  25666. iteratee = undefined;
  25667. }
  25668. return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
  25669. });
  25670. /**
  25671. * This method is like `_.xor` except that it accepts `comparator` which is
  25672. * invoked to compare elements of `arrays`. The order of result values is
  25673. * determined by the order they occur in the arrays. The comparator is invoked
  25674. * with two arguments: (arrVal, othVal).
  25675. *
  25676. * @static
  25677. * @memberOf _
  25678. * @since 4.0.0
  25679. * @category Array
  25680. * @param {...Array} [arrays] The arrays to inspect.
  25681. * @param {Function} [comparator] The comparator invoked per element.
  25682. * @returns {Array} Returns the new array of filtered values.
  25683. * @example
  25684. *
  25685. * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
  25686. * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
  25687. *
  25688. * _.xorWith(objects, others, _.isEqual);
  25689. * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  25690. */
  25691. var xorWith = baseRest(function(arrays) {
  25692. var comparator = last(arrays);
  25693. comparator = typeof comparator == 'function' ? comparator : undefined;
  25694. return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
  25695. });
  25696. /**
  25697. * Creates an array of grouped elements, the first of which contains the
  25698. * first elements of the given arrays, the second of which contains the
  25699. * second elements of the given arrays, and so on.
  25700. *
  25701. * @static
  25702. * @memberOf _
  25703. * @since 0.1.0
  25704. * @category Array
  25705. * @param {...Array} [arrays] The arrays to process.
  25706. * @returns {Array} Returns the new array of grouped elements.
  25707. * @example
  25708. *
  25709. * _.zip(['a', 'b'], [1, 2], [true, false]);
  25710. * // => [['a', 1, true], ['b', 2, false]]
  25711. */
  25712. var zip = baseRest(unzip);
  25713. /**
  25714. * This method is like `_.fromPairs` except that it accepts two arrays,
  25715. * one of property identifiers and one of corresponding values.
  25716. *
  25717. * @static
  25718. * @memberOf _
  25719. * @since 0.4.0
  25720. * @category Array
  25721. * @param {Array} [props=[]] The property identifiers.
  25722. * @param {Array} [values=[]] The property values.
  25723. * @returns {Object} Returns the new object.
  25724. * @example
  25725. *
  25726. * _.zipObject(['a', 'b'], [1, 2]);
  25727. * // => { 'a': 1, 'b': 2 }
  25728. */
  25729. function zipObject(props, values) {
  25730. return baseZipObject(props || [], values || [], assignValue);
  25731. }
  25732. /**
  25733. * This method is like `_.zipObject` except that it supports property paths.
  25734. *
  25735. * @static
  25736. * @memberOf _
  25737. * @since 4.1.0
  25738. * @category Array
  25739. * @param {Array} [props=[]] The property identifiers.
  25740. * @param {Array} [values=[]] The property values.
  25741. * @returns {Object} Returns the new object.
  25742. * @example
  25743. *
  25744. * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
  25745. * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
  25746. */
  25747. function zipObjectDeep(props, values) {
  25748. return baseZipObject(props || [], values || [], baseSet);
  25749. }
  25750. /**
  25751. * This method is like `_.zip` except that it accepts `iteratee` to specify
  25752. * how grouped values should be combined. The iteratee is invoked with the
  25753. * elements of each group: (...group).
  25754. *
  25755. * @static
  25756. * @memberOf _
  25757. * @since 3.8.0
  25758. * @category Array
  25759. * @param {...Array} [arrays] The arrays to process.
  25760. * @param {Function} [iteratee=_.identity] The function to combine
  25761. * grouped values.
  25762. * @returns {Array} Returns the new array of grouped elements.
  25763. * @example
  25764. *
  25765. * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) {
  25766. * return a + b + c;
  25767. * });
  25768. * // => [111, 222]
  25769. */
  25770. var zipWith = baseRest(function(arrays) {
  25771. var length = arrays.length,
  25772. iteratee = length > 1 ? arrays[length - 1] : undefined;
  25773. iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
  25774. return unzipWith(arrays, iteratee);
  25775. });
  25776. /*------------------------------------------------------------------------*/
  25777. /**
  25778. * Creates a `lodash` wrapper instance that wraps `value` with explicit method
  25779. * chain sequences enabled. The result of such sequences must be unwrapped
  25780. * with `_#value`.
  25781. *
  25782. * @static
  25783. * @memberOf _
  25784. * @since 1.3.0
  25785. * @category Seq
  25786. * @param {*} value The value to wrap.
  25787. * @returns {Object} Returns the new `lodash` wrapper instance.
  25788. * @example
  25789. *
  25790. * var users = [
  25791. * { 'user': 'barney', 'age': 36 },
  25792. * { 'user': 'fred', 'age': 40 },
  25793. * { 'user': 'pebbles', 'age': 1 }
  25794. * ];
  25795. *
  25796. * var youngest = _
  25797. * .chain(users)
  25798. * .sortBy('age')
  25799. * .map(function(o) {
  25800. * return o.user + ' is ' + o.age;
  25801. * })
  25802. * .head()
  25803. * .value();
  25804. * // => 'pebbles is 1'
  25805. */
  25806. function chain(value) {
  25807. var result = lodash(value);
  25808. result.__chain__ = true;
  25809. return result;
  25810. }
  25811. /**
  25812. * This method invokes `interceptor` and returns `value`. The interceptor
  25813. * is invoked with one argument; (value). The purpose of this method is to
  25814. * "tap into" a method chain sequence in order to modify intermediate results.
  25815. *
  25816. * @static
  25817. * @memberOf _
  25818. * @since 0.1.0
  25819. * @category Seq
  25820. * @param {*} value The value to provide to `interceptor`.
  25821. * @param {Function} interceptor The function to invoke.
  25822. * @returns {*} Returns `value`.
  25823. * @example
  25824. *
  25825. * _([1, 2, 3])
  25826. * .tap(function(array) {
  25827. * // Mutate input array.
  25828. * array.pop();
  25829. * })
  25830. * .reverse()
  25831. * .value();
  25832. * // => [2, 1]
  25833. */
  25834. function tap(value, interceptor) {
  25835. interceptor(value);
  25836. return value;
  25837. }
  25838. /**
  25839. * This method is like `_.tap` except that it returns the result of `interceptor`.
  25840. * The purpose of this method is to "pass thru" values replacing intermediate
  25841. * results in a method chain sequence.
  25842. *
  25843. * @static
  25844. * @memberOf _
  25845. * @since 3.0.0
  25846. * @category Seq
  25847. * @param {*} value The value to provide to `interceptor`.
  25848. * @param {Function} interceptor The function to invoke.
  25849. * @returns {*} Returns the result of `interceptor`.
  25850. * @example
  25851. *
  25852. * _(' abc ')
  25853. * .chain()
  25854. * .trim()
  25855. * .thru(function(value) {
  25856. * return [value];
  25857. * })
  25858. * .value();
  25859. * // => ['abc']
  25860. */
  25861. function thru(value, interceptor) {
  25862. return interceptor(value);
  25863. }
  25864. /**
  25865. * This method is the wrapper version of `_.at`.
  25866. *
  25867. * @name at
  25868. * @memberOf _
  25869. * @since 1.0.0
  25870. * @category Seq
  25871. * @param {...(string|string[])} [paths] The property paths to pick.
  25872. * @returns {Object} Returns the new `lodash` wrapper instance.
  25873. * @example
  25874. *
  25875. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  25876. *
  25877. * _(object).at(['a[0].b.c', 'a[1]']).value();
  25878. * // => [3, 4]
  25879. */
  25880. var wrapperAt = flatRest(function(paths) {
  25881. var length = paths.length,
  25882. start = length ? paths[0] : 0,
  25883. value = this.__wrapped__,
  25884. interceptor = function(object) { return baseAt(object, paths); };
  25885. if (length > 1 || this.__actions__.length ||
  25886. !(value instanceof LazyWrapper) || !isIndex(start)) {
  25887. return this.thru(interceptor);
  25888. }
  25889. value = value.slice(start, +start + (length ? 1 : 0));
  25890. value.__actions__.push({
  25891. 'func': thru,
  25892. 'args': [interceptor],
  25893. 'thisArg': undefined
  25894. });
  25895. return new LodashWrapper(value, this.__chain__).thru(function(array) {
  25896. if (length && !array.length) {
  25897. array.push(undefined);
  25898. }
  25899. return array;
  25900. });
  25901. });
  25902. /**
  25903. * Creates a `lodash` wrapper instance with explicit method chain sequences enabled.
  25904. *
  25905. * @name chain
  25906. * @memberOf _
  25907. * @since 0.1.0
  25908. * @category Seq
  25909. * @returns {Object} Returns the new `lodash` wrapper instance.
  25910. * @example
  25911. *
  25912. * var users = [
  25913. * { 'user': 'barney', 'age': 36 },
  25914. * { 'user': 'fred', 'age': 40 }
  25915. * ];
  25916. *
  25917. * // A sequence without explicit chaining.
  25918. * _(users).head();
  25919. * // => { 'user': 'barney', 'age': 36 }
  25920. *
  25921. * // A sequence with explicit chaining.
  25922. * _(users)
  25923. * .chain()
  25924. * .head()
  25925. * .pick('user')
  25926. * .value();
  25927. * // => { 'user': 'barney' }
  25928. */
  25929. function wrapperChain() {
  25930. return chain(this);
  25931. }
  25932. /**
  25933. * Executes the chain sequence and returns the wrapped result.
  25934. *
  25935. * @name commit
  25936. * @memberOf _
  25937. * @since 3.2.0
  25938. * @category Seq
  25939. * @returns {Object} Returns the new `lodash` wrapper instance.
  25940. * @example
  25941. *
  25942. * var array = [1, 2];
  25943. * var wrapped = _(array).push(3);
  25944. *
  25945. * console.log(array);
  25946. * // => [1, 2]
  25947. *
  25948. * wrapped = wrapped.commit();
  25949. * console.log(array);
  25950. * // => [1, 2, 3]
  25951. *
  25952. * wrapped.last();
  25953. * // => 3
  25954. *
  25955. * console.log(array);
  25956. * // => [1, 2, 3]
  25957. */
  25958. function wrapperCommit() {
  25959. return new LodashWrapper(this.value(), this.__chain__);
  25960. }
  25961. /**
  25962. * Gets the next value on a wrapped object following the
  25963. * [iterator protocol](https://mdn.io/iteration_protocols#iterator).
  25964. *
  25965. * @name next
  25966. * @memberOf _
  25967. * @since 4.0.0
  25968. * @category Seq
  25969. * @returns {Object} Returns the next iterator value.
  25970. * @example
  25971. *
  25972. * var wrapped = _([1, 2]);
  25973. *
  25974. * wrapped.next();
  25975. * // => { 'done': false, 'value': 1 }
  25976. *
  25977. * wrapped.next();
  25978. * // => { 'done': false, 'value': 2 }
  25979. *
  25980. * wrapped.next();
  25981. * // => { 'done': true, 'value': undefined }
  25982. */
  25983. function wrapperNext() {
  25984. if (this.__values__ === undefined) {
  25985. this.__values__ = toArray(this.value());
  25986. }
  25987. var done = this.__index__ >= this.__values__.length,
  25988. value = done ? undefined : this.__values__[this.__index__++];
  25989. return { 'done': done, 'value': value };
  25990. }
  25991. /**
  25992. * Enables the wrapper to be iterable.
  25993. *
  25994. * @name Symbol.iterator
  25995. * @memberOf _
  25996. * @since 4.0.0
  25997. * @category Seq
  25998. * @returns {Object} Returns the wrapper object.
  25999. * @example
  26000. *
  26001. * var wrapped = _([1, 2]);
  26002. *
  26003. * wrapped[Symbol.iterator]() === wrapped;
  26004. * // => true
  26005. *
  26006. * Array.from(wrapped);
  26007. * // => [1, 2]
  26008. */
  26009. function wrapperToIterator() {
  26010. return this;
  26011. }
  26012. /**
  26013. * Creates a clone of the chain sequence planting `value` as the wrapped value.
  26014. *
  26015. * @name plant
  26016. * @memberOf _
  26017. * @since 3.2.0
  26018. * @category Seq
  26019. * @param {*} value The value to plant.
  26020. * @returns {Object} Returns the new `lodash` wrapper instance.
  26021. * @example
  26022. *
  26023. * function square(n) {
  26024. * return n * n;
  26025. * }
  26026. *
  26027. * var wrapped = _([1, 2]).map(square);
  26028. * var other = wrapped.plant([3, 4]);
  26029. *
  26030. * other.value();
  26031. * // => [9, 16]
  26032. *
  26033. * wrapped.value();
  26034. * // => [1, 4]
  26035. */
  26036. function wrapperPlant(value) {
  26037. var result,
  26038. parent = this;
  26039. while (parent instanceof baseLodash) {
  26040. var clone = wrapperClone(parent);
  26041. clone.__index__ = 0;
  26042. clone.__values__ = undefined;
  26043. if (result) {
  26044. previous.__wrapped__ = clone;
  26045. } else {
  26046. result = clone;
  26047. }
  26048. var previous = clone;
  26049. parent = parent.__wrapped__;
  26050. }
  26051. previous.__wrapped__ = value;
  26052. return result;
  26053. }
  26054. /**
  26055. * This method is the wrapper version of `_.reverse`.
  26056. *
  26057. * **Note:** This method mutates the wrapped array.
  26058. *
  26059. * @name reverse
  26060. * @memberOf _
  26061. * @since 0.1.0
  26062. * @category Seq
  26063. * @returns {Object} Returns the new `lodash` wrapper instance.
  26064. * @example
  26065. *
  26066. * var array = [1, 2, 3];
  26067. *
  26068. * _(array).reverse().value()
  26069. * // => [3, 2, 1]
  26070. *
  26071. * console.log(array);
  26072. * // => [3, 2, 1]
  26073. */
  26074. function wrapperReverse() {
  26075. var value = this.__wrapped__;
  26076. if (value instanceof LazyWrapper) {
  26077. var wrapped = value;
  26078. if (this.__actions__.length) {
  26079. wrapped = new LazyWrapper(this);
  26080. }
  26081. wrapped = wrapped.reverse();
  26082. wrapped.__actions__.push({
  26083. 'func': thru,
  26084. 'args': [reverse],
  26085. 'thisArg': undefined
  26086. });
  26087. return new LodashWrapper(wrapped, this.__chain__);
  26088. }
  26089. return this.thru(reverse);
  26090. }
  26091. /**
  26092. * Executes the chain sequence to resolve the unwrapped value.
  26093. *
  26094. * @name value
  26095. * @memberOf _
  26096. * @since 0.1.0
  26097. * @alias toJSON, valueOf
  26098. * @category Seq
  26099. * @returns {*} Returns the resolved unwrapped value.
  26100. * @example
  26101. *
  26102. * _([1, 2, 3]).value();
  26103. * // => [1, 2, 3]
  26104. */
  26105. function wrapperValue() {
  26106. return baseWrapperValue(this.__wrapped__, this.__actions__);
  26107. }
  26108. /*------------------------------------------------------------------------*/
  26109. /**
  26110. * Creates an object composed of keys generated from the results of running
  26111. * each element of `collection` thru `iteratee`. The corresponding value of
  26112. * each key is the number of times the key was returned by `iteratee`. The
  26113. * iteratee is invoked with one argument: (value).
  26114. *
  26115. * @static
  26116. * @memberOf _
  26117. * @since 0.5.0
  26118. * @category Collection
  26119. * @param {Array|Object} collection The collection to iterate over.
  26120. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26121. * @returns {Object} Returns the composed aggregate object.
  26122. * @example
  26123. *
  26124. * _.countBy([6.1, 4.2, 6.3], Math.floor);
  26125. * // => { '4': 1, '6': 2 }
  26126. *
  26127. * // The `_.property` iteratee shorthand.
  26128. * _.countBy(['one', 'two', 'three'], 'length');
  26129. * // => { '3': 2, '5': 1 }
  26130. */
  26131. var countBy = createAggregator(function(result, value, key) {
  26132. if (hasOwnProperty.call(result, key)) {
  26133. ++result[key];
  26134. } else {
  26135. baseAssignValue(result, key, 1);
  26136. }
  26137. });
  26138. /**
  26139. * Checks if `predicate` returns truthy for **all** elements of `collection`.
  26140. * Iteration is stopped once `predicate` returns falsey. The predicate is
  26141. * invoked with three arguments: (value, index|key, collection).
  26142. *
  26143. * **Note:** This method returns `true` for
  26144. * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
  26145. * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
  26146. * elements of empty collections.
  26147. *
  26148. * @static
  26149. * @memberOf _
  26150. * @since 0.1.0
  26151. * @category Collection
  26152. * @param {Array|Object} collection The collection to iterate over.
  26153. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26154. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26155. * @returns {boolean} Returns `true` if all elements pass the predicate check,
  26156. * else `false`.
  26157. * @example
  26158. *
  26159. * _.every([true, 1, null, 'yes'], Boolean);
  26160. * // => false
  26161. *
  26162. * var users = [
  26163. * { 'user': 'barney', 'age': 36, 'active': false },
  26164. * { 'user': 'fred', 'age': 40, 'active': false }
  26165. * ];
  26166. *
  26167. * // The `_.matches` iteratee shorthand.
  26168. * _.every(users, { 'user': 'barney', 'active': false });
  26169. * // => false
  26170. *
  26171. * // The `_.matchesProperty` iteratee shorthand.
  26172. * _.every(users, ['active', false]);
  26173. * // => true
  26174. *
  26175. * // The `_.property` iteratee shorthand.
  26176. * _.every(users, 'active');
  26177. * // => false
  26178. */
  26179. function every(collection, predicate, guard) {
  26180. var func = isArray(collection) ? arrayEvery : baseEvery;
  26181. if (guard && isIterateeCall(collection, predicate, guard)) {
  26182. predicate = undefined;
  26183. }
  26184. return func(collection, getIteratee(predicate, 3));
  26185. }
  26186. /**
  26187. * Iterates over elements of `collection`, returning an array of all elements
  26188. * `predicate` returns truthy for. The predicate is invoked with three
  26189. * arguments: (value, index|key, collection).
  26190. *
  26191. * **Note:** Unlike `_.remove`, this method returns a new array.
  26192. *
  26193. * @static
  26194. * @memberOf _
  26195. * @since 0.1.0
  26196. * @category Collection
  26197. * @param {Array|Object} collection The collection to iterate over.
  26198. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26199. * @returns {Array} Returns the new filtered array.
  26200. * @see _.reject
  26201. * @example
  26202. *
  26203. * var users = [
  26204. * { 'user': 'barney', 'age': 36, 'active': true },
  26205. * { 'user': 'fred', 'age': 40, 'active': false }
  26206. * ];
  26207. *
  26208. * _.filter(users, function(o) { return !o.active; });
  26209. * // => objects for ['fred']
  26210. *
  26211. * // The `_.matches` iteratee shorthand.
  26212. * _.filter(users, { 'age': 36, 'active': true });
  26213. * // => objects for ['barney']
  26214. *
  26215. * // The `_.matchesProperty` iteratee shorthand.
  26216. * _.filter(users, ['active', false]);
  26217. * // => objects for ['fred']
  26218. *
  26219. * // The `_.property` iteratee shorthand.
  26220. * _.filter(users, 'active');
  26221. * // => objects for ['barney']
  26222. */
  26223. function filter(collection, predicate) {
  26224. var func = isArray(collection) ? arrayFilter : baseFilter;
  26225. return func(collection, getIteratee(predicate, 3));
  26226. }
  26227. /**
  26228. * Iterates over elements of `collection`, returning the first element
  26229. * `predicate` returns truthy for. The predicate is invoked with three
  26230. * arguments: (value, index|key, collection).
  26231. *
  26232. * @static
  26233. * @memberOf _
  26234. * @since 0.1.0
  26235. * @category Collection
  26236. * @param {Array|Object} collection The collection to inspect.
  26237. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26238. * @param {number} [fromIndex=0] The index to search from.
  26239. * @returns {*} Returns the matched element, else `undefined`.
  26240. * @example
  26241. *
  26242. * var users = [
  26243. * { 'user': 'barney', 'age': 36, 'active': true },
  26244. * { 'user': 'fred', 'age': 40, 'active': false },
  26245. * { 'user': 'pebbles', 'age': 1, 'active': true }
  26246. * ];
  26247. *
  26248. * _.find(users, function(o) { return o.age < 40; });
  26249. * // => object for 'barney'
  26250. *
  26251. * // The `_.matches` iteratee shorthand.
  26252. * _.find(users, { 'age': 1, 'active': true });
  26253. * // => object for 'pebbles'
  26254. *
  26255. * // The `_.matchesProperty` iteratee shorthand.
  26256. * _.find(users, ['active', false]);
  26257. * // => object for 'fred'
  26258. *
  26259. * // The `_.property` iteratee shorthand.
  26260. * _.find(users, 'active');
  26261. * // => object for 'barney'
  26262. */
  26263. var find = createFind(findIndex);
  26264. /**
  26265. * This method is like `_.find` except that it iterates over elements of
  26266. * `collection` from right to left.
  26267. *
  26268. * @static
  26269. * @memberOf _
  26270. * @since 2.0.0
  26271. * @category Collection
  26272. * @param {Array|Object} collection The collection to inspect.
  26273. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26274. * @param {number} [fromIndex=collection.length-1] The index to search from.
  26275. * @returns {*} Returns the matched element, else `undefined`.
  26276. * @example
  26277. *
  26278. * _.findLast([1, 2, 3, 4], function(n) {
  26279. * return n % 2 == 1;
  26280. * });
  26281. * // => 3
  26282. */
  26283. var findLast = createFind(findLastIndex);
  26284. /**
  26285. * Creates a flattened array of values by running each element in `collection`
  26286. * thru `iteratee` and flattening the mapped results. The iteratee is invoked
  26287. * with three arguments: (value, index|key, collection).
  26288. *
  26289. * @static
  26290. * @memberOf _
  26291. * @since 4.0.0
  26292. * @category Collection
  26293. * @param {Array|Object} collection The collection to iterate over.
  26294. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26295. * @returns {Array} Returns the new flattened array.
  26296. * @example
  26297. *
  26298. * function duplicate(n) {
  26299. * return [n, n];
  26300. * }
  26301. *
  26302. * _.flatMap([1, 2], duplicate);
  26303. * // => [1, 1, 2, 2]
  26304. */
  26305. function flatMap(collection, iteratee) {
  26306. return baseFlatten(map(collection, iteratee), 1);
  26307. }
  26308. /**
  26309. * This method is like `_.flatMap` except that it recursively flattens the
  26310. * mapped results.
  26311. *
  26312. * @static
  26313. * @memberOf _
  26314. * @since 4.7.0
  26315. * @category Collection
  26316. * @param {Array|Object} collection The collection to iterate over.
  26317. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26318. * @returns {Array} Returns the new flattened array.
  26319. * @example
  26320. *
  26321. * function duplicate(n) {
  26322. * return [[[n, n]]];
  26323. * }
  26324. *
  26325. * _.flatMapDeep([1, 2], duplicate);
  26326. * // => [1, 1, 2, 2]
  26327. */
  26328. function flatMapDeep(collection, iteratee) {
  26329. return baseFlatten(map(collection, iteratee), INFINITY);
  26330. }
  26331. /**
  26332. * This method is like `_.flatMap` except that it recursively flattens the
  26333. * mapped results up to `depth` times.
  26334. *
  26335. * @static
  26336. * @memberOf _
  26337. * @since 4.7.0
  26338. * @category Collection
  26339. * @param {Array|Object} collection The collection to iterate over.
  26340. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26341. * @param {number} [depth=1] The maximum recursion depth.
  26342. * @returns {Array} Returns the new flattened array.
  26343. * @example
  26344. *
  26345. * function duplicate(n) {
  26346. * return [[[n, n]]];
  26347. * }
  26348. *
  26349. * _.flatMapDepth([1, 2], duplicate, 2);
  26350. * // => [[1, 1], [2, 2]]
  26351. */
  26352. function flatMapDepth(collection, iteratee, depth) {
  26353. depth = depth === undefined ? 1 : toInteger(depth);
  26354. return baseFlatten(map(collection, iteratee), depth);
  26355. }
  26356. /**
  26357. * Iterates over elements of `collection` and invokes `iteratee` for each element.
  26358. * The iteratee is invoked with three arguments: (value, index|key, collection).
  26359. * Iteratee functions may exit iteration early by explicitly returning `false`.
  26360. *
  26361. * **Note:** As with other "Collections" methods, objects with a "length"
  26362. * property are iterated like arrays. To avoid this behavior use `_.forIn`
  26363. * or `_.forOwn` for object iteration.
  26364. *
  26365. * @static
  26366. * @memberOf _
  26367. * @since 0.1.0
  26368. * @alias each
  26369. * @category Collection
  26370. * @param {Array|Object} collection The collection to iterate over.
  26371. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26372. * @returns {Array|Object} Returns `collection`.
  26373. * @see _.forEachRight
  26374. * @example
  26375. *
  26376. * _.forEach([1, 2], function(value) {
  26377. * console.log(value);
  26378. * });
  26379. * // => Logs `1` then `2`.
  26380. *
  26381. * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
  26382. * console.log(key);
  26383. * });
  26384. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  26385. */
  26386. function forEach(collection, iteratee) {
  26387. var func = isArray(collection) ? arrayEach : baseEach;
  26388. return func(collection, getIteratee(iteratee, 3));
  26389. }
  26390. /**
  26391. * This method is like `_.forEach` except that it iterates over elements of
  26392. * `collection` from right to left.
  26393. *
  26394. * @static
  26395. * @memberOf _
  26396. * @since 2.0.0
  26397. * @alias eachRight
  26398. * @category Collection
  26399. * @param {Array|Object} collection The collection to iterate over.
  26400. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26401. * @returns {Array|Object} Returns `collection`.
  26402. * @see _.forEach
  26403. * @example
  26404. *
  26405. * _.forEachRight([1, 2], function(value) {
  26406. * console.log(value);
  26407. * });
  26408. * // => Logs `2` then `1`.
  26409. */
  26410. function forEachRight(collection, iteratee) {
  26411. var func = isArray(collection) ? arrayEachRight : baseEachRight;
  26412. return func(collection, getIteratee(iteratee, 3));
  26413. }
  26414. /**
  26415. * Creates an object composed of keys generated from the results of running
  26416. * each element of `collection` thru `iteratee`. The order of grouped values
  26417. * is determined by the order they occur in `collection`. The corresponding
  26418. * value of each key is an array of elements responsible for generating the
  26419. * key. The iteratee is invoked with one argument: (value).
  26420. *
  26421. * @static
  26422. * @memberOf _
  26423. * @since 0.1.0
  26424. * @category Collection
  26425. * @param {Array|Object} collection The collection to iterate over.
  26426. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26427. * @returns {Object} Returns the composed aggregate object.
  26428. * @example
  26429. *
  26430. * _.groupBy([6.1, 4.2, 6.3], Math.floor);
  26431. * // => { '4': [4.2], '6': [6.1, 6.3] }
  26432. *
  26433. * // The `_.property` iteratee shorthand.
  26434. * _.groupBy(['one', 'two', 'three'], 'length');
  26435. * // => { '3': ['one', 'two'], '5': ['three'] }
  26436. */
  26437. var groupBy = createAggregator(function(result, value, key) {
  26438. if (hasOwnProperty.call(result, key)) {
  26439. result[key].push(value);
  26440. } else {
  26441. baseAssignValue(result, key, [value]);
  26442. }
  26443. });
  26444. /**
  26445. * Checks if `value` is in `collection`. If `collection` is a string, it's
  26446. * checked for a substring of `value`, otherwise
  26447. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  26448. * is used for equality comparisons. If `fromIndex` is negative, it's used as
  26449. * the offset from the end of `collection`.
  26450. *
  26451. * @static
  26452. * @memberOf _
  26453. * @since 0.1.0
  26454. * @category Collection
  26455. * @param {Array|Object|string} collection The collection to inspect.
  26456. * @param {*} value The value to search for.
  26457. * @param {number} [fromIndex=0] The index to search from.
  26458. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  26459. * @returns {boolean} Returns `true` if `value` is found, else `false`.
  26460. * @example
  26461. *
  26462. * _.includes([1, 2, 3], 1);
  26463. * // => true
  26464. *
  26465. * _.includes([1, 2, 3], 1, 2);
  26466. * // => false
  26467. *
  26468. * _.includes({ 'a': 1, 'b': 2 }, 1);
  26469. * // => true
  26470. *
  26471. * _.includes('abcd', 'bc');
  26472. * // => true
  26473. */
  26474. function includes(collection, value, fromIndex, guard) {
  26475. collection = isArrayLike(collection) ? collection : values(collection);
  26476. fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0;
  26477. var length = collection.length;
  26478. if (fromIndex < 0) {
  26479. fromIndex = nativeMax(length + fromIndex, 0);
  26480. }
  26481. return isString(collection)
  26482. ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1)
  26483. : (!!length && baseIndexOf(collection, value, fromIndex) > -1);
  26484. }
  26485. /**
  26486. * Invokes the method at `path` of each element in `collection`, returning
  26487. * an array of the results of each invoked method. Any additional arguments
  26488. * are provided to each invoked method. If `path` is a function, it's invoked
  26489. * for, and `this` bound to, each element in `collection`.
  26490. *
  26491. * @static
  26492. * @memberOf _
  26493. * @since 4.0.0
  26494. * @category Collection
  26495. * @param {Array|Object} collection The collection to iterate over.
  26496. * @param {Array|Function|string} path The path of the method to invoke or
  26497. * the function invoked per iteration.
  26498. * @param {...*} [args] The arguments to invoke each method with.
  26499. * @returns {Array} Returns the array of results.
  26500. * @example
  26501. *
  26502. * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort');
  26503. * // => [[1, 5, 7], [1, 2, 3]]
  26504. *
  26505. * _.invokeMap([123, 456], String.prototype.split, '');
  26506. * // => [['1', '2', '3'], ['4', '5', '6']]
  26507. */
  26508. var invokeMap = baseRest(function(collection, path, args) {
  26509. var index = -1,
  26510. isFunc = typeof path == 'function',
  26511. result = isArrayLike(collection) ? Array(collection.length) : [];
  26512. baseEach(collection, function(value) {
  26513. result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
  26514. });
  26515. return result;
  26516. });
  26517. /**
  26518. * Creates an object composed of keys generated from the results of running
  26519. * each element of `collection` thru `iteratee`. The corresponding value of
  26520. * each key is the last element responsible for generating the key. The
  26521. * iteratee is invoked with one argument: (value).
  26522. *
  26523. * @static
  26524. * @memberOf _
  26525. * @since 4.0.0
  26526. * @category Collection
  26527. * @param {Array|Object} collection The collection to iterate over.
  26528. * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
  26529. * @returns {Object} Returns the composed aggregate object.
  26530. * @example
  26531. *
  26532. * var array = [
  26533. * { 'dir': 'left', 'code': 97 },
  26534. * { 'dir': 'right', 'code': 100 }
  26535. * ];
  26536. *
  26537. * _.keyBy(array, function(o) {
  26538. * return String.fromCharCode(o.code);
  26539. * });
  26540. * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  26541. *
  26542. * _.keyBy(array, 'dir');
  26543. * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  26544. */
  26545. var keyBy = createAggregator(function(result, value, key) {
  26546. baseAssignValue(result, key, value);
  26547. });
  26548. /**
  26549. * Creates an array of values by running each element in `collection` thru
  26550. * `iteratee`. The iteratee is invoked with three arguments:
  26551. * (value, index|key, collection).
  26552. *
  26553. * Many lodash methods are guarded to work as iteratees for methods like
  26554. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
  26555. *
  26556. * The guarded methods are:
  26557. * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
  26558. * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
  26559. * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
  26560. * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
  26561. *
  26562. * @static
  26563. * @memberOf _
  26564. * @since 0.1.0
  26565. * @category Collection
  26566. * @param {Array|Object} collection The collection to iterate over.
  26567. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26568. * @returns {Array} Returns the new mapped array.
  26569. * @example
  26570. *
  26571. * function square(n) {
  26572. * return n * n;
  26573. * }
  26574. *
  26575. * _.map([4, 8], square);
  26576. * // => [16, 64]
  26577. *
  26578. * _.map({ 'a': 4, 'b': 8 }, square);
  26579. * // => [16, 64] (iteration order is not guaranteed)
  26580. *
  26581. * var users = [
  26582. * { 'user': 'barney' },
  26583. * { 'user': 'fred' }
  26584. * ];
  26585. *
  26586. * // The `_.property` iteratee shorthand.
  26587. * _.map(users, 'user');
  26588. * // => ['barney', 'fred']
  26589. */
  26590. function map(collection, iteratee) {
  26591. var func = isArray(collection) ? arrayMap : baseMap;
  26592. return func(collection, getIteratee(iteratee, 3));
  26593. }
  26594. /**
  26595. * This method is like `_.sortBy` except that it allows specifying the sort
  26596. * orders of the iteratees to sort by. If `orders` is unspecified, all values
  26597. * are sorted in ascending order. Otherwise, specify an order of "desc" for
  26598. * descending or "asc" for ascending sort order of corresponding values.
  26599. *
  26600. * @static
  26601. * @memberOf _
  26602. * @since 4.0.0
  26603. * @category Collection
  26604. * @param {Array|Object} collection The collection to iterate over.
  26605. * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]]
  26606. * The iteratees to sort by.
  26607. * @param {string[]} [orders] The sort orders of `iteratees`.
  26608. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
  26609. * @returns {Array} Returns the new sorted array.
  26610. * @example
  26611. *
  26612. * var users = [
  26613. * { 'user': 'fred', 'age': 48 },
  26614. * { 'user': 'barney', 'age': 34 },
  26615. * { 'user': 'fred', 'age': 40 },
  26616. * { 'user': 'barney', 'age': 36 }
  26617. * ];
  26618. *
  26619. * // Sort by `user` in ascending order and by `age` in descending order.
  26620. * _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
  26621. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26622. */
  26623. function orderBy(collection, iteratees, orders, guard) {
  26624. if (collection == null) {
  26625. return [];
  26626. }
  26627. if (!isArray(iteratees)) {
  26628. iteratees = iteratees == null ? [] : [iteratees];
  26629. }
  26630. orders = guard ? undefined : orders;
  26631. if (!isArray(orders)) {
  26632. orders = orders == null ? [] : [orders];
  26633. }
  26634. return baseOrderBy(collection, iteratees, orders);
  26635. }
  26636. /**
  26637. * Creates an array of elements split into two groups, the first of which
  26638. * contains elements `predicate` returns truthy for, the second of which
  26639. * contains elements `predicate` returns falsey for. The predicate is
  26640. * invoked with one argument: (value).
  26641. *
  26642. * @static
  26643. * @memberOf _
  26644. * @since 3.0.0
  26645. * @category Collection
  26646. * @param {Array|Object} collection The collection to iterate over.
  26647. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26648. * @returns {Array} Returns the array of grouped elements.
  26649. * @example
  26650. *
  26651. * var users = [
  26652. * { 'user': 'barney', 'age': 36, 'active': false },
  26653. * { 'user': 'fred', 'age': 40, 'active': true },
  26654. * { 'user': 'pebbles', 'age': 1, 'active': false }
  26655. * ];
  26656. *
  26657. * _.partition(users, function(o) { return o.active; });
  26658. * // => objects for [['fred'], ['barney', 'pebbles']]
  26659. *
  26660. * // The `_.matches` iteratee shorthand.
  26661. * _.partition(users, { 'age': 1, 'active': false });
  26662. * // => objects for [['pebbles'], ['barney', 'fred']]
  26663. *
  26664. * // The `_.matchesProperty` iteratee shorthand.
  26665. * _.partition(users, ['active', false]);
  26666. * // => objects for [['barney', 'pebbles'], ['fred']]
  26667. *
  26668. * // The `_.property` iteratee shorthand.
  26669. * _.partition(users, 'active');
  26670. * // => objects for [['fred'], ['barney', 'pebbles']]
  26671. */
  26672. var partition = createAggregator(function(result, value, key) {
  26673. result[key ? 0 : 1].push(value);
  26674. }, function() { return [[], []]; });
  26675. /**
  26676. * Reduces `collection` to a value which is the accumulated result of running
  26677. * each element in `collection` thru `iteratee`, where each successive
  26678. * invocation is supplied the return value of the previous. If `accumulator`
  26679. * is not given, the first element of `collection` is used as the initial
  26680. * value. The iteratee is invoked with four arguments:
  26681. * (accumulator, value, index|key, collection).
  26682. *
  26683. * Many lodash methods are guarded to work as iteratees for methods like
  26684. * `_.reduce`, `_.reduceRight`, and `_.transform`.
  26685. *
  26686. * The guarded methods are:
  26687. * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`,
  26688. * and `sortBy`
  26689. *
  26690. * @static
  26691. * @memberOf _
  26692. * @since 0.1.0
  26693. * @category Collection
  26694. * @param {Array|Object} collection The collection to iterate over.
  26695. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26696. * @param {*} [accumulator] The initial value.
  26697. * @returns {*} Returns the accumulated value.
  26698. * @see _.reduceRight
  26699. * @example
  26700. *
  26701. * _.reduce([1, 2], function(sum, n) {
  26702. * return sum + n;
  26703. * }, 0);
  26704. * // => 3
  26705. *
  26706. * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  26707. * (result[value] || (result[value] = [])).push(key);
  26708. * return result;
  26709. * }, {});
  26710. * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
  26711. */
  26712. function reduce(collection, iteratee, accumulator) {
  26713. var func = isArray(collection) ? arrayReduce : baseReduce,
  26714. initAccum = arguments.length < 3;
  26715. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
  26716. }
  26717. /**
  26718. * This method is like `_.reduce` except that it iterates over elements of
  26719. * `collection` from right to left.
  26720. *
  26721. * @static
  26722. * @memberOf _
  26723. * @since 0.1.0
  26724. * @category Collection
  26725. * @param {Array|Object} collection The collection to iterate over.
  26726. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  26727. * @param {*} [accumulator] The initial value.
  26728. * @returns {*} Returns the accumulated value.
  26729. * @see _.reduce
  26730. * @example
  26731. *
  26732. * var array = [[0, 1], [2, 3], [4, 5]];
  26733. *
  26734. * _.reduceRight(array, function(flattened, other) {
  26735. * return flattened.concat(other);
  26736. * }, []);
  26737. * // => [4, 5, 2, 3, 0, 1]
  26738. */
  26739. function reduceRight(collection, iteratee, accumulator) {
  26740. var func = isArray(collection) ? arrayReduceRight : baseReduce,
  26741. initAccum = arguments.length < 3;
  26742. return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
  26743. }
  26744. /**
  26745. * The opposite of `_.filter`; this method returns the elements of `collection`
  26746. * that `predicate` does **not** return truthy for.
  26747. *
  26748. * @static
  26749. * @memberOf _
  26750. * @since 0.1.0
  26751. * @category Collection
  26752. * @param {Array|Object} collection The collection to iterate over.
  26753. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26754. * @returns {Array} Returns the new filtered array.
  26755. * @see _.filter
  26756. * @example
  26757. *
  26758. * var users = [
  26759. * { 'user': 'barney', 'age': 36, 'active': false },
  26760. * { 'user': 'fred', 'age': 40, 'active': true }
  26761. * ];
  26762. *
  26763. * _.reject(users, function(o) { return !o.active; });
  26764. * // => objects for ['fred']
  26765. *
  26766. * // The `_.matches` iteratee shorthand.
  26767. * _.reject(users, { 'age': 40, 'active': true });
  26768. * // => objects for ['barney']
  26769. *
  26770. * // The `_.matchesProperty` iteratee shorthand.
  26771. * _.reject(users, ['active', false]);
  26772. * // => objects for ['fred']
  26773. *
  26774. * // The `_.property` iteratee shorthand.
  26775. * _.reject(users, 'active');
  26776. * // => objects for ['barney']
  26777. */
  26778. function reject(collection, predicate) {
  26779. var func = isArray(collection) ? arrayFilter : baseFilter;
  26780. return func(collection, negate(getIteratee(predicate, 3)));
  26781. }
  26782. /**
  26783. * Gets a random element from `collection`.
  26784. *
  26785. * @static
  26786. * @memberOf _
  26787. * @since 2.0.0
  26788. * @category Collection
  26789. * @param {Array|Object} collection The collection to sample.
  26790. * @returns {*} Returns the random element.
  26791. * @example
  26792. *
  26793. * _.sample([1, 2, 3, 4]);
  26794. * // => 2
  26795. */
  26796. function sample(collection) {
  26797. var func = isArray(collection) ? arraySample : baseSample;
  26798. return func(collection);
  26799. }
  26800. /**
  26801. * Gets `n` random elements at unique keys from `collection` up to the
  26802. * size of `collection`.
  26803. *
  26804. * @static
  26805. * @memberOf _
  26806. * @since 4.0.0
  26807. * @category Collection
  26808. * @param {Array|Object} collection The collection to sample.
  26809. * @param {number} [n=1] The number of elements to sample.
  26810. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26811. * @returns {Array} Returns the random elements.
  26812. * @example
  26813. *
  26814. * _.sampleSize([1, 2, 3], 2);
  26815. * // => [3, 1]
  26816. *
  26817. * _.sampleSize([1, 2, 3], 4);
  26818. * // => [2, 3, 1]
  26819. */
  26820. function sampleSize(collection, n, guard) {
  26821. if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
  26822. n = 1;
  26823. } else {
  26824. n = toInteger(n);
  26825. }
  26826. var func = isArray(collection) ? arraySampleSize : baseSampleSize;
  26827. return func(collection, n);
  26828. }
  26829. /**
  26830. * Creates an array of shuffled values, using a version of the
  26831. * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
  26832. *
  26833. * @static
  26834. * @memberOf _
  26835. * @since 0.1.0
  26836. * @category Collection
  26837. * @param {Array|Object} collection The collection to shuffle.
  26838. * @returns {Array} Returns the new shuffled array.
  26839. * @example
  26840. *
  26841. * _.shuffle([1, 2, 3, 4]);
  26842. * // => [4, 1, 3, 2]
  26843. */
  26844. function shuffle(collection) {
  26845. var func = isArray(collection) ? arrayShuffle : baseShuffle;
  26846. return func(collection);
  26847. }
  26848. /**
  26849. * Gets the size of `collection` by returning its length for array-like
  26850. * values or the number of own enumerable string keyed properties for objects.
  26851. *
  26852. * @static
  26853. * @memberOf _
  26854. * @since 0.1.0
  26855. * @category Collection
  26856. * @param {Array|Object|string} collection The collection to inspect.
  26857. * @returns {number} Returns the collection size.
  26858. * @example
  26859. *
  26860. * _.size([1, 2, 3]);
  26861. * // => 3
  26862. *
  26863. * _.size({ 'a': 1, 'b': 2 });
  26864. * // => 2
  26865. *
  26866. * _.size('pebbles');
  26867. * // => 7
  26868. */
  26869. function size(collection) {
  26870. if (collection == null) {
  26871. return 0;
  26872. }
  26873. if (isArrayLike(collection)) {
  26874. return isString(collection) ? stringSize(collection) : collection.length;
  26875. }
  26876. var tag = getTag(collection);
  26877. if (tag == mapTag || tag == setTag) {
  26878. return collection.size;
  26879. }
  26880. return baseKeys(collection).length;
  26881. }
  26882. /**
  26883. * Checks if `predicate` returns truthy for **any** element of `collection`.
  26884. * Iteration is stopped once `predicate` returns truthy. The predicate is
  26885. * invoked with three arguments: (value, index|key, collection).
  26886. *
  26887. * @static
  26888. * @memberOf _
  26889. * @since 0.1.0
  26890. * @category Collection
  26891. * @param {Array|Object} collection The collection to iterate over.
  26892. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  26893. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  26894. * @returns {boolean} Returns `true` if any element passes the predicate check,
  26895. * else `false`.
  26896. * @example
  26897. *
  26898. * _.some([null, 0, 'yes', false], Boolean);
  26899. * // => true
  26900. *
  26901. * var users = [
  26902. * { 'user': 'barney', 'active': true },
  26903. * { 'user': 'fred', 'active': false }
  26904. * ];
  26905. *
  26906. * // The `_.matches` iteratee shorthand.
  26907. * _.some(users, { 'user': 'barney', 'active': false });
  26908. * // => false
  26909. *
  26910. * // The `_.matchesProperty` iteratee shorthand.
  26911. * _.some(users, ['active', false]);
  26912. * // => true
  26913. *
  26914. * // The `_.property` iteratee shorthand.
  26915. * _.some(users, 'active');
  26916. * // => true
  26917. */
  26918. function some(collection, predicate, guard) {
  26919. var func = isArray(collection) ? arraySome : baseSome;
  26920. if (guard && isIterateeCall(collection, predicate, guard)) {
  26921. predicate = undefined;
  26922. }
  26923. return func(collection, getIteratee(predicate, 3));
  26924. }
  26925. /**
  26926. * Creates an array of elements, sorted in ascending order by the results of
  26927. * running each element in a collection thru each iteratee. This method
  26928. * performs a stable sort, that is, it preserves the original sort order of
  26929. * equal elements. The iteratees are invoked with one argument: (value).
  26930. *
  26931. * @static
  26932. * @memberOf _
  26933. * @since 0.1.0
  26934. * @category Collection
  26935. * @param {Array|Object} collection The collection to iterate over.
  26936. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  26937. * The iteratees to sort by.
  26938. * @returns {Array} Returns the new sorted array.
  26939. * @example
  26940. *
  26941. * var users = [
  26942. * { 'user': 'fred', 'age': 48 },
  26943. * { 'user': 'barney', 'age': 36 },
  26944. * { 'user': 'fred', 'age': 40 },
  26945. * { 'user': 'barney', 'age': 34 }
  26946. * ];
  26947. *
  26948. * _.sortBy(users, [function(o) { return o.user; }]);
  26949. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  26950. *
  26951. * _.sortBy(users, ['user', 'age']);
  26952. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  26953. */
  26954. var sortBy = baseRest(function(collection, iteratees) {
  26955. if (collection == null) {
  26956. return [];
  26957. }
  26958. var length = iteratees.length;
  26959. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  26960. iteratees = [];
  26961. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  26962. iteratees = [iteratees[0]];
  26963. }
  26964. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  26965. });
  26966. /*------------------------------------------------------------------------*/
  26967. /**
  26968. * Gets the timestamp of the number of milliseconds that have elapsed since
  26969. * the Unix epoch (1 January 1970 00:00:00 UTC).
  26970. *
  26971. * @static
  26972. * @memberOf _
  26973. * @since 2.4.0
  26974. * @category Date
  26975. * @returns {number} Returns the timestamp.
  26976. * @example
  26977. *
  26978. * _.defer(function(stamp) {
  26979. * console.log(_.now() - stamp);
  26980. * }, _.now());
  26981. * // => Logs the number of milliseconds it took for the deferred invocation.
  26982. */
  26983. var now = ctxNow || function() {
  26984. return root.Date.now();
  26985. };
  26986. /*------------------------------------------------------------------------*/
  26987. /**
  26988. * The opposite of `_.before`; this method creates a function that invokes
  26989. * `func` once it's called `n` or more times.
  26990. *
  26991. * @static
  26992. * @memberOf _
  26993. * @since 0.1.0
  26994. * @category Function
  26995. * @param {number} n The number of calls before `func` is invoked.
  26996. * @param {Function} func The function to restrict.
  26997. * @returns {Function} Returns the new restricted function.
  26998. * @example
  26999. *
  27000. * var saves = ['profile', 'settings'];
  27001. *
  27002. * var done = _.after(saves.length, function() {
  27003. * console.log('done saving!');
  27004. * });
  27005. *
  27006. * _.forEach(saves, function(type) {
  27007. * asyncSave({ 'type': type, 'complete': done });
  27008. * });
  27009. * // => Logs 'done saving!' after the two async saves have completed.
  27010. */
  27011. function after(n, func) {
  27012. if (typeof func != 'function') {
  27013. throw new TypeError(FUNC_ERROR_TEXT);
  27014. }
  27015. n = toInteger(n);
  27016. return function() {
  27017. if (--n < 1) {
  27018. return func.apply(this, arguments);
  27019. }
  27020. };
  27021. }
  27022. /**
  27023. * Creates a function that invokes `func`, with up to `n` arguments,
  27024. * ignoring any additional arguments.
  27025. *
  27026. * @static
  27027. * @memberOf _
  27028. * @since 3.0.0
  27029. * @category Function
  27030. * @param {Function} func The function to cap arguments for.
  27031. * @param {number} [n=func.length] The arity cap.
  27032. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27033. * @returns {Function} Returns the new capped function.
  27034. * @example
  27035. *
  27036. * _.map(['6', '8', '10'], _.ary(parseInt, 1));
  27037. * // => [6, 8, 10]
  27038. */
  27039. function ary(func, n, guard) {
  27040. n = guard ? undefined : n;
  27041. n = (func && n == null) ? func.length : n;
  27042. return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
  27043. }
  27044. /**
  27045. * Creates a function that invokes `func`, with the `this` binding and arguments
  27046. * of the created function, while it's called less than `n` times. Subsequent
  27047. * calls to the created function return the result of the last `func` invocation.
  27048. *
  27049. * @static
  27050. * @memberOf _
  27051. * @since 3.0.0
  27052. * @category Function
  27053. * @param {number} n The number of calls at which `func` is no longer invoked.
  27054. * @param {Function} func The function to restrict.
  27055. * @returns {Function} Returns the new restricted function.
  27056. * @example
  27057. *
  27058. * jQuery(element).on('click', _.before(5, addContactToList));
  27059. * // => Allows adding up to 4 contacts to the list.
  27060. */
  27061. function before(n, func) {
  27062. var result;
  27063. if (typeof func != 'function') {
  27064. throw new TypeError(FUNC_ERROR_TEXT);
  27065. }
  27066. n = toInteger(n);
  27067. return function() {
  27068. if (--n > 0) {
  27069. result = func.apply(this, arguments);
  27070. }
  27071. if (n <= 1) {
  27072. func = undefined;
  27073. }
  27074. return result;
  27075. };
  27076. }
  27077. /**
  27078. * Creates a function that invokes `func` with the `this` binding of `thisArg`
  27079. * and `partials` prepended to the arguments it receives.
  27080. *
  27081. * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
  27082. * may be used as a placeholder for partially applied arguments.
  27083. *
  27084. * **Note:** Unlike native `Function#bind`, this method doesn't set the "length"
  27085. * property of bound functions.
  27086. *
  27087. * @static
  27088. * @memberOf _
  27089. * @since 0.1.0
  27090. * @category Function
  27091. * @param {Function} func The function to bind.
  27092. * @param {*} thisArg The `this` binding of `func`.
  27093. * @param {...*} [partials] The arguments to be partially applied.
  27094. * @returns {Function} Returns the new bound function.
  27095. * @example
  27096. *
  27097. * function greet(greeting, punctuation) {
  27098. * return greeting + ' ' + this.user + punctuation;
  27099. * }
  27100. *
  27101. * var object = { 'user': 'fred' };
  27102. *
  27103. * var bound = _.bind(greet, object, 'hi');
  27104. * bound('!');
  27105. * // => 'hi fred!'
  27106. *
  27107. * // Bound with placeholders.
  27108. * var bound = _.bind(greet, object, _, '!');
  27109. * bound('hi');
  27110. * // => 'hi fred!'
  27111. */
  27112. var bind = baseRest(function(func, thisArg, partials) {
  27113. var bitmask = WRAP_BIND_FLAG;
  27114. if (partials.length) {
  27115. var holders = replaceHolders(partials, getHolder(bind));
  27116. bitmask |= WRAP_PARTIAL_FLAG;
  27117. }
  27118. return createWrap(func, bitmask, thisArg, partials, holders);
  27119. });
  27120. /**
  27121. * Creates a function that invokes the method at `object[key]` with `partials`
  27122. * prepended to the arguments it receives.
  27123. *
  27124. * This method differs from `_.bind` by allowing bound functions to reference
  27125. * methods that may be redefined or don't yet exist. See
  27126. * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
  27127. * for more details.
  27128. *
  27129. * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic
  27130. * builds, may be used as a placeholder for partially applied arguments.
  27131. *
  27132. * @static
  27133. * @memberOf _
  27134. * @since 0.10.0
  27135. * @category Function
  27136. * @param {Object} object The object to invoke the method on.
  27137. * @param {string} key The key of the method.
  27138. * @param {...*} [partials] The arguments to be partially applied.
  27139. * @returns {Function} Returns the new bound function.
  27140. * @example
  27141. *
  27142. * var object = {
  27143. * 'user': 'fred',
  27144. * 'greet': function(greeting, punctuation) {
  27145. * return greeting + ' ' + this.user + punctuation;
  27146. * }
  27147. * };
  27148. *
  27149. * var bound = _.bindKey(object, 'greet', 'hi');
  27150. * bound('!');
  27151. * // => 'hi fred!'
  27152. *
  27153. * object.greet = function(greeting, punctuation) {
  27154. * return greeting + 'ya ' + this.user + punctuation;
  27155. * };
  27156. *
  27157. * bound('!');
  27158. * // => 'hiya fred!'
  27159. *
  27160. * // Bound with placeholders.
  27161. * var bound = _.bindKey(object, 'greet', _, '!');
  27162. * bound('hi');
  27163. * // => 'hiya fred!'
  27164. */
  27165. var bindKey = baseRest(function(object, key, partials) {
  27166. var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
  27167. if (partials.length) {
  27168. var holders = replaceHolders(partials, getHolder(bindKey));
  27169. bitmask |= WRAP_PARTIAL_FLAG;
  27170. }
  27171. return createWrap(key, bitmask, object, partials, holders);
  27172. });
  27173. /**
  27174. * Creates a function that accepts arguments of `func` and either invokes
  27175. * `func` returning its result, if at least `arity` number of arguments have
  27176. * been provided, or returns a function that accepts the remaining `func`
  27177. * arguments, and so on. The arity of `func` may be specified if `func.length`
  27178. * is not sufficient.
  27179. *
  27180. * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
  27181. * may be used as a placeholder for provided arguments.
  27182. *
  27183. * **Note:** This method doesn't set the "length" property of curried functions.
  27184. *
  27185. * @static
  27186. * @memberOf _
  27187. * @since 2.0.0
  27188. * @category Function
  27189. * @param {Function} func The function to curry.
  27190. * @param {number} [arity=func.length] The arity of `func`.
  27191. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27192. * @returns {Function} Returns the new curried function.
  27193. * @example
  27194. *
  27195. * var abc = function(a, b, c) {
  27196. * return [a, b, c];
  27197. * };
  27198. *
  27199. * var curried = _.curry(abc);
  27200. *
  27201. * curried(1)(2)(3);
  27202. * // => [1, 2, 3]
  27203. *
  27204. * curried(1, 2)(3);
  27205. * // => [1, 2, 3]
  27206. *
  27207. * curried(1, 2, 3);
  27208. * // => [1, 2, 3]
  27209. *
  27210. * // Curried with placeholders.
  27211. * curried(1)(_, 3)(2);
  27212. * // => [1, 2, 3]
  27213. */
  27214. function curry(func, arity, guard) {
  27215. arity = guard ? undefined : arity;
  27216. var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  27217. result.placeholder = curry.placeholder;
  27218. return result;
  27219. }
  27220. /**
  27221. * This method is like `_.curry` except that arguments are applied to `func`
  27222. * in the manner of `_.partialRight` instead of `_.partial`.
  27223. *
  27224. * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic
  27225. * builds, may be used as a placeholder for provided arguments.
  27226. *
  27227. * **Note:** This method doesn't set the "length" property of curried functions.
  27228. *
  27229. * @static
  27230. * @memberOf _
  27231. * @since 3.0.0
  27232. * @category Function
  27233. * @param {Function} func The function to curry.
  27234. * @param {number} [arity=func.length] The arity of `func`.
  27235. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  27236. * @returns {Function} Returns the new curried function.
  27237. * @example
  27238. *
  27239. * var abc = function(a, b, c) {
  27240. * return [a, b, c];
  27241. * };
  27242. *
  27243. * var curried = _.curryRight(abc);
  27244. *
  27245. * curried(3)(2)(1);
  27246. * // => [1, 2, 3]
  27247. *
  27248. * curried(2, 3)(1);
  27249. * // => [1, 2, 3]
  27250. *
  27251. * curried(1, 2, 3);
  27252. * // => [1, 2, 3]
  27253. *
  27254. * // Curried with placeholders.
  27255. * curried(3)(1, _)(2);
  27256. * // => [1, 2, 3]
  27257. */
  27258. function curryRight(func, arity, guard) {
  27259. arity = guard ? undefined : arity;
  27260. var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
  27261. result.placeholder = curryRight.placeholder;
  27262. return result;
  27263. }
  27264. /**
  27265. * Creates a debounced function that delays invoking `func` until after `wait`
  27266. * milliseconds have elapsed since the last time the debounced function was
  27267. * invoked. The debounced function comes with a `cancel` method to cancel
  27268. * delayed `func` invocations and a `flush` method to immediately invoke them.
  27269. * Provide `options` to indicate whether `func` should be invoked on the
  27270. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  27271. * with the last arguments provided to the debounced function. Subsequent
  27272. * calls to the debounced function return the result of the last `func`
  27273. * invocation.
  27274. *
  27275. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  27276. * invoked on the trailing edge of the timeout only if the debounced function
  27277. * is invoked more than once during the `wait` timeout.
  27278. *
  27279. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  27280. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  27281. *
  27282. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  27283. * for details over the differences between `_.debounce` and `_.throttle`.
  27284. *
  27285. * @static
  27286. * @memberOf _
  27287. * @since 0.1.0
  27288. * @category Function
  27289. * @param {Function} func The function to debounce.
  27290. * @param {number} [wait=0] The number of milliseconds to delay.
  27291. * @param {Object} [options={}] The options object.
  27292. * @param {boolean} [options.leading=false]
  27293. * Specify invoking on the leading edge of the timeout.
  27294. * @param {number} [options.maxWait]
  27295. * The maximum time `func` is allowed to be delayed before it's invoked.
  27296. * @param {boolean} [options.trailing=true]
  27297. * Specify invoking on the trailing edge of the timeout.
  27298. * @returns {Function} Returns the new debounced function.
  27299. * @example
  27300. *
  27301. * // Avoid costly calculations while the window size is in flux.
  27302. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  27303. *
  27304. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  27305. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  27306. * 'leading': true,
  27307. * 'trailing': false
  27308. * }));
  27309. *
  27310. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  27311. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  27312. * var source = new EventSource('/stream');
  27313. * jQuery(source).on('message', debounced);
  27314. *
  27315. * // Cancel the trailing debounced invocation.
  27316. * jQuery(window).on('popstate', debounced.cancel);
  27317. */
  27318. function debounce(func, wait, options) {
  27319. var lastArgs,
  27320. lastThis,
  27321. maxWait,
  27322. result,
  27323. timerId,
  27324. lastCallTime,
  27325. lastInvokeTime = 0,
  27326. leading = false,
  27327. maxing = false,
  27328. trailing = true;
  27329. if (typeof func != 'function') {
  27330. throw new TypeError(FUNC_ERROR_TEXT);
  27331. }
  27332. wait = toNumber(wait) || 0;
  27333. if (isObject(options)) {
  27334. leading = !!options.leading;
  27335. maxing = 'maxWait' in options;
  27336. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  27337. trailing = 'trailing' in options ? !!options.trailing : trailing;
  27338. }
  27339. function invokeFunc(time) {
  27340. var args = lastArgs,
  27341. thisArg = lastThis;
  27342. lastArgs = lastThis = undefined;
  27343. lastInvokeTime = time;
  27344. result = func.apply(thisArg, args);
  27345. return result;
  27346. }
  27347. function leadingEdge(time) {
  27348. // Reset any `maxWait` timer.
  27349. lastInvokeTime = time;
  27350. // Start the timer for the trailing edge.
  27351. timerId = setTimeout(timerExpired, wait);
  27352. // Invoke the leading edge.
  27353. return leading ? invokeFunc(time) : result;
  27354. }
  27355. function remainingWait(time) {
  27356. var timeSinceLastCall = time - lastCallTime,
  27357. timeSinceLastInvoke = time - lastInvokeTime,
  27358. timeWaiting = wait - timeSinceLastCall;
  27359. return maxing
  27360. ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
  27361. : timeWaiting;
  27362. }
  27363. function shouldInvoke(time) {
  27364. var timeSinceLastCall = time - lastCallTime,
  27365. timeSinceLastInvoke = time - lastInvokeTime;
  27366. // Either this is the first call, activity has stopped and we're at the
  27367. // trailing edge, the system time has gone backwards and we're treating
  27368. // it as the trailing edge, or we've hit the `maxWait` limit.
  27369. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  27370. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  27371. }
  27372. function timerExpired() {
  27373. var time = now();
  27374. if (shouldInvoke(time)) {
  27375. return trailingEdge(time);
  27376. }
  27377. // Restart the timer.
  27378. timerId = setTimeout(timerExpired, remainingWait(time));
  27379. }
  27380. function trailingEdge(time) {
  27381. timerId = undefined;
  27382. // Only invoke if we have `lastArgs` which means `func` has been
  27383. // debounced at least once.
  27384. if (trailing && lastArgs) {
  27385. return invokeFunc(time);
  27386. }
  27387. lastArgs = lastThis = undefined;
  27388. return result;
  27389. }
  27390. function cancel() {
  27391. if (timerId !== undefined) {
  27392. clearTimeout(timerId);
  27393. }
  27394. lastInvokeTime = 0;
  27395. lastArgs = lastCallTime = lastThis = timerId = undefined;
  27396. }
  27397. function flush() {
  27398. return timerId === undefined ? result : trailingEdge(now());
  27399. }
  27400. function debounced() {
  27401. var time = now(),
  27402. isInvoking = shouldInvoke(time);
  27403. lastArgs = arguments;
  27404. lastThis = this;
  27405. lastCallTime = time;
  27406. if (isInvoking) {
  27407. if (timerId === undefined) {
  27408. return leadingEdge(lastCallTime);
  27409. }
  27410. if (maxing) {
  27411. // Handle invocations in a tight loop.
  27412. clearTimeout(timerId);
  27413. timerId = setTimeout(timerExpired, wait);
  27414. return invokeFunc(lastCallTime);
  27415. }
  27416. }
  27417. if (timerId === undefined) {
  27418. timerId = setTimeout(timerExpired, wait);
  27419. }
  27420. return result;
  27421. }
  27422. debounced.cancel = cancel;
  27423. debounced.flush = flush;
  27424. return debounced;
  27425. }
  27426. /**
  27427. * Defers invoking the `func` until the current call stack has cleared. Any
  27428. * additional arguments are provided to `func` when it's invoked.
  27429. *
  27430. * @static
  27431. * @memberOf _
  27432. * @since 0.1.0
  27433. * @category Function
  27434. * @param {Function} func The function to defer.
  27435. * @param {...*} [args] The arguments to invoke `func` with.
  27436. * @returns {number} Returns the timer id.
  27437. * @example
  27438. *
  27439. * _.defer(function(text) {
  27440. * console.log(text);
  27441. * }, 'deferred');
  27442. * // => Logs 'deferred' after one millisecond.
  27443. */
  27444. var defer = baseRest(function(func, args) {
  27445. return baseDelay(func, 1, args);
  27446. });
  27447. /**
  27448. * Invokes `func` after `wait` milliseconds. Any additional arguments are
  27449. * provided to `func` when it's invoked.
  27450. *
  27451. * @static
  27452. * @memberOf _
  27453. * @since 0.1.0
  27454. * @category Function
  27455. * @param {Function} func The function to delay.
  27456. * @param {number} wait The number of milliseconds to delay invocation.
  27457. * @param {...*} [args] The arguments to invoke `func` with.
  27458. * @returns {number} Returns the timer id.
  27459. * @example
  27460. *
  27461. * _.delay(function(text) {
  27462. * console.log(text);
  27463. * }, 1000, 'later');
  27464. * // => Logs 'later' after one second.
  27465. */
  27466. var delay = baseRest(function(func, wait, args) {
  27467. return baseDelay(func, toNumber(wait) || 0, args);
  27468. });
  27469. /**
  27470. * Creates a function that invokes `func` with arguments reversed.
  27471. *
  27472. * @static
  27473. * @memberOf _
  27474. * @since 4.0.0
  27475. * @category Function
  27476. * @param {Function} func The function to flip arguments for.
  27477. * @returns {Function} Returns the new flipped function.
  27478. * @example
  27479. *
  27480. * var flipped = _.flip(function() {
  27481. * return _.toArray(arguments);
  27482. * });
  27483. *
  27484. * flipped('a', 'b', 'c', 'd');
  27485. * // => ['d', 'c', 'b', 'a']
  27486. */
  27487. function flip(func) {
  27488. return createWrap(func, WRAP_FLIP_FLAG);
  27489. }
  27490. /**
  27491. * Creates a function that memoizes the result of `func`. If `resolver` is
  27492. * provided, it determines the cache key for storing the result based on the
  27493. * arguments provided to the memoized function. By default, the first argument
  27494. * provided to the memoized function is used as the map cache key. The `func`
  27495. * is invoked with the `this` binding of the memoized function.
  27496. *
  27497. * **Note:** The cache is exposed as the `cache` property on the memoized
  27498. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  27499. * constructor with one whose instances implement the
  27500. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  27501. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  27502. *
  27503. * @static
  27504. * @memberOf _
  27505. * @since 0.1.0
  27506. * @category Function
  27507. * @param {Function} func The function to have its output memoized.
  27508. * @param {Function} [resolver] The function to resolve the cache key.
  27509. * @returns {Function} Returns the new memoized function.
  27510. * @example
  27511. *
  27512. * var object = { 'a': 1, 'b': 2 };
  27513. * var other = { 'c': 3, 'd': 4 };
  27514. *
  27515. * var values = _.memoize(_.values);
  27516. * values(object);
  27517. * // => [1, 2]
  27518. *
  27519. * values(other);
  27520. * // => [3, 4]
  27521. *
  27522. * object.a = 2;
  27523. * values(object);
  27524. * // => [1, 2]
  27525. *
  27526. * // Modify the result cache.
  27527. * values.cache.set(object, ['a', 'b']);
  27528. * values(object);
  27529. * // => ['a', 'b']
  27530. *
  27531. * // Replace `_.memoize.Cache`.
  27532. * _.memoize.Cache = WeakMap;
  27533. */
  27534. function memoize(func, resolver) {
  27535. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  27536. throw new TypeError(FUNC_ERROR_TEXT);
  27537. }
  27538. var memoized = function() {
  27539. var args = arguments,
  27540. key = resolver ? resolver.apply(this, args) : args[0],
  27541. cache = memoized.cache;
  27542. if (cache.has(key)) {
  27543. return cache.get(key);
  27544. }
  27545. var result = func.apply(this, args);
  27546. memoized.cache = cache.set(key, result) || cache;
  27547. return result;
  27548. };
  27549. memoized.cache = new (memoize.Cache || MapCache);
  27550. return memoized;
  27551. }
  27552. // Expose `MapCache`.
  27553. memoize.Cache = MapCache;
  27554. /**
  27555. * Creates a function that negates the result of the predicate `func`. The
  27556. * `func` predicate is invoked with the `this` binding and arguments of the
  27557. * created function.
  27558. *
  27559. * @static
  27560. * @memberOf _
  27561. * @since 3.0.0
  27562. * @category Function
  27563. * @param {Function} predicate The predicate to negate.
  27564. * @returns {Function} Returns the new negated function.
  27565. * @example
  27566. *
  27567. * function isEven(n) {
  27568. * return n % 2 == 0;
  27569. * }
  27570. *
  27571. * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
  27572. * // => [1, 3, 5]
  27573. */
  27574. function negate(predicate) {
  27575. if (typeof predicate != 'function') {
  27576. throw new TypeError(FUNC_ERROR_TEXT);
  27577. }
  27578. return function() {
  27579. var args = arguments;
  27580. switch (args.length) {
  27581. case 0: return !predicate.call(this);
  27582. case 1: return !predicate.call(this, args[0]);
  27583. case 2: return !predicate.call(this, args[0], args[1]);
  27584. case 3: return !predicate.call(this, args[0], args[1], args[2]);
  27585. }
  27586. return !predicate.apply(this, args);
  27587. };
  27588. }
  27589. /**
  27590. * Creates a function that is restricted to invoking `func` once. Repeat calls
  27591. * to the function return the value of the first invocation. The `func` is
  27592. * invoked with the `this` binding and arguments of the created function.
  27593. *
  27594. * @static
  27595. * @memberOf _
  27596. * @since 0.1.0
  27597. * @category Function
  27598. * @param {Function} func The function to restrict.
  27599. * @returns {Function} Returns the new restricted function.
  27600. * @example
  27601. *
  27602. * var initialize = _.once(createApplication);
  27603. * initialize();
  27604. * initialize();
  27605. * // => `createApplication` is invoked once
  27606. */
  27607. function once(func) {
  27608. return before(2, func);
  27609. }
  27610. /**
  27611. * Creates a function that invokes `func` with its arguments transformed.
  27612. *
  27613. * @static
  27614. * @since 4.0.0
  27615. * @memberOf _
  27616. * @category Function
  27617. * @param {Function} func The function to wrap.
  27618. * @param {...(Function|Function[])} [transforms=[_.identity]]
  27619. * The argument transforms.
  27620. * @returns {Function} Returns the new function.
  27621. * @example
  27622. *
  27623. * function doubled(n) {
  27624. * return n * 2;
  27625. * }
  27626. *
  27627. * function square(n) {
  27628. * return n * n;
  27629. * }
  27630. *
  27631. * var func = _.overArgs(function(x, y) {
  27632. * return [x, y];
  27633. * }, [square, doubled]);
  27634. *
  27635. * func(9, 3);
  27636. * // => [81, 6]
  27637. *
  27638. * func(10, 5);
  27639. * // => [100, 10]
  27640. */
  27641. var overArgs = castRest(function(func, transforms) {
  27642. transforms = (transforms.length == 1 && isArray(transforms[0]))
  27643. ? arrayMap(transforms[0], baseUnary(getIteratee()))
  27644. : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
  27645. var funcsLength = transforms.length;
  27646. return baseRest(function(args) {
  27647. var index = -1,
  27648. length = nativeMin(args.length, funcsLength);
  27649. while (++index < length) {
  27650. args[index] = transforms[index].call(this, args[index]);
  27651. }
  27652. return apply(func, this, args);
  27653. });
  27654. });
  27655. /**
  27656. * Creates a function that invokes `func` with `partials` prepended to the
  27657. * arguments it receives. This method is like `_.bind` except it does **not**
  27658. * alter the `this` binding.
  27659. *
  27660. * The `_.partial.placeholder` value, which defaults to `_` in monolithic
  27661. * builds, may be used as a placeholder for partially applied arguments.
  27662. *
  27663. * **Note:** This method doesn't set the "length" property of partially
  27664. * applied functions.
  27665. *
  27666. * @static
  27667. * @memberOf _
  27668. * @since 0.2.0
  27669. * @category Function
  27670. * @param {Function} func The function to partially apply arguments to.
  27671. * @param {...*} [partials] The arguments to be partially applied.
  27672. * @returns {Function} Returns the new partially applied function.
  27673. * @example
  27674. *
  27675. * function greet(greeting, name) {
  27676. * return greeting + ' ' + name;
  27677. * }
  27678. *
  27679. * var sayHelloTo = _.partial(greet, 'hello');
  27680. * sayHelloTo('fred');
  27681. * // => 'hello fred'
  27682. *
  27683. * // Partially applied with placeholders.
  27684. * var greetFred = _.partial(greet, _, 'fred');
  27685. * greetFred('hi');
  27686. * // => 'hi fred'
  27687. */
  27688. var partial = baseRest(function(func, partials) {
  27689. var holders = replaceHolders(partials, getHolder(partial));
  27690. return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
  27691. });
  27692. /**
  27693. * This method is like `_.partial` except that partially applied arguments
  27694. * are appended to the arguments it receives.
  27695. *
  27696. * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic
  27697. * builds, may be used as a placeholder for partially applied arguments.
  27698. *
  27699. * **Note:** This method doesn't set the "length" property of partially
  27700. * applied functions.
  27701. *
  27702. * @static
  27703. * @memberOf _
  27704. * @since 1.0.0
  27705. * @category Function
  27706. * @param {Function} func The function to partially apply arguments to.
  27707. * @param {...*} [partials] The arguments to be partially applied.
  27708. * @returns {Function} Returns the new partially applied function.
  27709. * @example
  27710. *
  27711. * function greet(greeting, name) {
  27712. * return greeting + ' ' + name;
  27713. * }
  27714. *
  27715. * var greetFred = _.partialRight(greet, 'fred');
  27716. * greetFred('hi');
  27717. * // => 'hi fred'
  27718. *
  27719. * // Partially applied with placeholders.
  27720. * var sayHelloTo = _.partialRight(greet, 'hello', _);
  27721. * sayHelloTo('fred');
  27722. * // => 'hello fred'
  27723. */
  27724. var partialRight = baseRest(function(func, partials) {
  27725. var holders = replaceHolders(partials, getHolder(partialRight));
  27726. return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
  27727. });
  27728. /**
  27729. * Creates a function that invokes `func` with arguments arranged according
  27730. * to the specified `indexes` where the argument value at the first index is
  27731. * provided as the first argument, the argument value at the second index is
  27732. * provided as the second argument, and so on.
  27733. *
  27734. * @static
  27735. * @memberOf _
  27736. * @since 3.0.0
  27737. * @category Function
  27738. * @param {Function} func The function to rearrange arguments for.
  27739. * @param {...(number|number[])} indexes The arranged argument indexes.
  27740. * @returns {Function} Returns the new function.
  27741. * @example
  27742. *
  27743. * var rearged = _.rearg(function(a, b, c) {
  27744. * return [a, b, c];
  27745. * }, [2, 0, 1]);
  27746. *
  27747. * rearged('b', 'c', 'a')
  27748. * // => ['a', 'b', 'c']
  27749. */
  27750. var rearg = flatRest(function(func, indexes) {
  27751. return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
  27752. });
  27753. /**
  27754. * Creates a function that invokes `func` with the `this` binding of the
  27755. * created function and arguments from `start` and beyond provided as
  27756. * an array.
  27757. *
  27758. * **Note:** This method is based on the
  27759. * [rest parameter](https://mdn.io/rest_parameters).
  27760. *
  27761. * @static
  27762. * @memberOf _
  27763. * @since 4.0.0
  27764. * @category Function
  27765. * @param {Function} func The function to apply a rest parameter to.
  27766. * @param {number} [start=func.length-1] The start position of the rest parameter.
  27767. * @returns {Function} Returns the new function.
  27768. * @example
  27769. *
  27770. * var say = _.rest(function(what, names) {
  27771. * return what + ' ' + _.initial(names).join(', ') +
  27772. * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
  27773. * });
  27774. *
  27775. * say('hello', 'fred', 'barney', 'pebbles');
  27776. * // => 'hello fred, barney, & pebbles'
  27777. */
  27778. function rest(func, start) {
  27779. if (typeof func != 'function') {
  27780. throw new TypeError(FUNC_ERROR_TEXT);
  27781. }
  27782. start = start === undefined ? start : toInteger(start);
  27783. return baseRest(func, start);
  27784. }
  27785. /**
  27786. * Creates a function that invokes `func` with the `this` binding of the
  27787. * create function and an array of arguments much like
  27788. * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
  27789. *
  27790. * **Note:** This method is based on the
  27791. * [spread operator](https://mdn.io/spread_operator).
  27792. *
  27793. * @static
  27794. * @memberOf _
  27795. * @since 3.2.0
  27796. * @category Function
  27797. * @param {Function} func The function to spread arguments over.
  27798. * @param {number} [start=0] The start position of the spread.
  27799. * @returns {Function} Returns the new function.
  27800. * @example
  27801. *
  27802. * var say = _.spread(function(who, what) {
  27803. * return who + ' says ' + what;
  27804. * });
  27805. *
  27806. * say(['fred', 'hello']);
  27807. * // => 'fred says hello'
  27808. *
  27809. * var numbers = Promise.all([
  27810. * Promise.resolve(40),
  27811. * Promise.resolve(36)
  27812. * ]);
  27813. *
  27814. * numbers.then(_.spread(function(x, y) {
  27815. * return x + y;
  27816. * }));
  27817. * // => a Promise of 76
  27818. */
  27819. function spread(func, start) {
  27820. if (typeof func != 'function') {
  27821. throw new TypeError(FUNC_ERROR_TEXT);
  27822. }
  27823. start = start == null ? 0 : nativeMax(toInteger(start), 0);
  27824. return baseRest(function(args) {
  27825. var array = args[start],
  27826. otherArgs = castSlice(args, 0, start);
  27827. if (array) {
  27828. arrayPush(otherArgs, array);
  27829. }
  27830. return apply(func, this, otherArgs);
  27831. });
  27832. }
  27833. /**
  27834. * Creates a throttled function that only invokes `func` at most once per
  27835. * every `wait` milliseconds. The throttled function comes with a `cancel`
  27836. * method to cancel delayed `func` invocations and a `flush` method to
  27837. * immediately invoke them. Provide `options` to indicate whether `func`
  27838. * should be invoked on the leading and/or trailing edge of the `wait`
  27839. * timeout. The `func` is invoked with the last arguments provided to the
  27840. * throttled function. Subsequent calls to the throttled function return the
  27841. * result of the last `func` invocation.
  27842. *
  27843. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  27844. * invoked on the trailing edge of the timeout only if the throttled function
  27845. * is invoked more than once during the `wait` timeout.
  27846. *
  27847. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  27848. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  27849. *
  27850. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  27851. * for details over the differences between `_.throttle` and `_.debounce`.
  27852. *
  27853. * @static
  27854. * @memberOf _
  27855. * @since 0.1.0
  27856. * @category Function
  27857. * @param {Function} func The function to throttle.
  27858. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  27859. * @param {Object} [options={}] The options object.
  27860. * @param {boolean} [options.leading=true]
  27861. * Specify invoking on the leading edge of the timeout.
  27862. * @param {boolean} [options.trailing=true]
  27863. * Specify invoking on the trailing edge of the timeout.
  27864. * @returns {Function} Returns the new throttled function.
  27865. * @example
  27866. *
  27867. * // Avoid excessively updating the position while scrolling.
  27868. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  27869. *
  27870. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  27871. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  27872. * jQuery(element).on('click', throttled);
  27873. *
  27874. * // Cancel the trailing throttled invocation.
  27875. * jQuery(window).on('popstate', throttled.cancel);
  27876. */
  27877. function throttle(func, wait, options) {
  27878. var leading = true,
  27879. trailing = true;
  27880. if (typeof func != 'function') {
  27881. throw new TypeError(FUNC_ERROR_TEXT);
  27882. }
  27883. if (isObject(options)) {
  27884. leading = 'leading' in options ? !!options.leading : leading;
  27885. trailing = 'trailing' in options ? !!options.trailing : trailing;
  27886. }
  27887. return debounce(func, wait, {
  27888. 'leading': leading,
  27889. 'maxWait': wait,
  27890. 'trailing': trailing
  27891. });
  27892. }
  27893. /**
  27894. * Creates a function that accepts up to one argument, ignoring any
  27895. * additional arguments.
  27896. *
  27897. * @static
  27898. * @memberOf _
  27899. * @since 4.0.0
  27900. * @category Function
  27901. * @param {Function} func The function to cap arguments for.
  27902. * @returns {Function} Returns the new capped function.
  27903. * @example
  27904. *
  27905. * _.map(['6', '8', '10'], _.unary(parseInt));
  27906. * // => [6, 8, 10]
  27907. */
  27908. function unary(func) {
  27909. return ary(func, 1);
  27910. }
  27911. /**
  27912. * Creates a function that provides `value` to `wrapper` as its first
  27913. * argument. Any additional arguments provided to the function are appended
  27914. * to those provided to the `wrapper`. The wrapper is invoked with the `this`
  27915. * binding of the created function.
  27916. *
  27917. * @static
  27918. * @memberOf _
  27919. * @since 0.1.0
  27920. * @category Function
  27921. * @param {*} value The value to wrap.
  27922. * @param {Function} [wrapper=identity] The wrapper function.
  27923. * @returns {Function} Returns the new function.
  27924. * @example
  27925. *
  27926. * var p = _.wrap(_.escape, function(func, text) {
  27927. * return '<p>' + func(text) + '</p>';
  27928. * });
  27929. *
  27930. * p('fred, barney, & pebbles');
  27931. * // => '<p>fred, barney, &amp; pebbles</p>'
  27932. */
  27933. function wrap(value, wrapper) {
  27934. return partial(castFunction(wrapper), value);
  27935. }
  27936. /*------------------------------------------------------------------------*/
  27937. /**
  27938. * Casts `value` as an array if it's not one.
  27939. *
  27940. * @static
  27941. * @memberOf _
  27942. * @since 4.4.0
  27943. * @category Lang
  27944. * @param {*} value The value to inspect.
  27945. * @returns {Array} Returns the cast array.
  27946. * @example
  27947. *
  27948. * _.castArray(1);
  27949. * // => [1]
  27950. *
  27951. * _.castArray({ 'a': 1 });
  27952. * // => [{ 'a': 1 }]
  27953. *
  27954. * _.castArray('abc');
  27955. * // => ['abc']
  27956. *
  27957. * _.castArray(null);
  27958. * // => [null]
  27959. *
  27960. * _.castArray(undefined);
  27961. * // => [undefined]
  27962. *
  27963. * _.castArray();
  27964. * // => []
  27965. *
  27966. * var array = [1, 2, 3];
  27967. * console.log(_.castArray(array) === array);
  27968. * // => true
  27969. */
  27970. function castArray() {
  27971. if (!arguments.length) {
  27972. return [];
  27973. }
  27974. var value = arguments[0];
  27975. return isArray(value) ? value : [value];
  27976. }
  27977. /**
  27978. * Creates a shallow clone of `value`.
  27979. *
  27980. * **Note:** This method is loosely based on the
  27981. * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm)
  27982. * and supports cloning arrays, array buffers, booleans, date objects, maps,
  27983. * numbers, `Object` objects, regexes, sets, strings, symbols, and typed
  27984. * arrays. The own enumerable properties of `arguments` objects are cloned
  27985. * as plain objects. An empty object is returned for uncloneable values such
  27986. * as error objects, functions, DOM nodes, and WeakMaps.
  27987. *
  27988. * @static
  27989. * @memberOf _
  27990. * @since 0.1.0
  27991. * @category Lang
  27992. * @param {*} value The value to clone.
  27993. * @returns {*} Returns the cloned value.
  27994. * @see _.cloneDeep
  27995. * @example
  27996. *
  27997. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  27998. *
  27999. * var shallow = _.clone(objects);
  28000. * console.log(shallow[0] === objects[0]);
  28001. * // => true
  28002. */
  28003. function clone(value) {
  28004. return baseClone(value, CLONE_SYMBOLS_FLAG);
  28005. }
  28006. /**
  28007. * This method is like `_.clone` except that it accepts `customizer` which
  28008. * is invoked to produce the cloned value. If `customizer` returns `undefined`,
  28009. * cloning is handled by the method instead. The `customizer` is invoked with
  28010. * up to four arguments; (value [, index|key, object, stack]).
  28011. *
  28012. * @static
  28013. * @memberOf _
  28014. * @since 4.0.0
  28015. * @category Lang
  28016. * @param {*} value The value to clone.
  28017. * @param {Function} [customizer] The function to customize cloning.
  28018. * @returns {*} Returns the cloned value.
  28019. * @see _.cloneDeepWith
  28020. * @example
  28021. *
  28022. * function customizer(value) {
  28023. * if (_.isElement(value)) {
  28024. * return value.cloneNode(false);
  28025. * }
  28026. * }
  28027. *
  28028. * var el = _.cloneWith(document.body, customizer);
  28029. *
  28030. * console.log(el === document.body);
  28031. * // => false
  28032. * console.log(el.nodeName);
  28033. * // => 'BODY'
  28034. * console.log(el.childNodes.length);
  28035. * // => 0
  28036. */
  28037. function cloneWith(value, customizer) {
  28038. customizer = typeof customizer == 'function' ? customizer : undefined;
  28039. return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
  28040. }
  28041. /**
  28042. * This method is like `_.clone` except that it recursively clones `value`.
  28043. *
  28044. * @static
  28045. * @memberOf _
  28046. * @since 1.0.0
  28047. * @category Lang
  28048. * @param {*} value The value to recursively clone.
  28049. * @returns {*} Returns the deep cloned value.
  28050. * @see _.clone
  28051. * @example
  28052. *
  28053. * var objects = [{ 'a': 1 }, { 'b': 2 }];
  28054. *
  28055. * var deep = _.cloneDeep(objects);
  28056. * console.log(deep[0] === objects[0]);
  28057. * // => false
  28058. */
  28059. function cloneDeep(value) {
  28060. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
  28061. }
  28062. /**
  28063. * This method is like `_.cloneWith` except that it recursively clones `value`.
  28064. *
  28065. * @static
  28066. * @memberOf _
  28067. * @since 4.0.0
  28068. * @category Lang
  28069. * @param {*} value The value to recursively clone.
  28070. * @param {Function} [customizer] The function to customize cloning.
  28071. * @returns {*} Returns the deep cloned value.
  28072. * @see _.cloneWith
  28073. * @example
  28074. *
  28075. * function customizer(value) {
  28076. * if (_.isElement(value)) {
  28077. * return value.cloneNode(true);
  28078. * }
  28079. * }
  28080. *
  28081. * var el = _.cloneDeepWith(document.body, customizer);
  28082. *
  28083. * console.log(el === document.body);
  28084. * // => false
  28085. * console.log(el.nodeName);
  28086. * // => 'BODY'
  28087. * console.log(el.childNodes.length);
  28088. * // => 20
  28089. */
  28090. function cloneDeepWith(value, customizer) {
  28091. customizer = typeof customizer == 'function' ? customizer : undefined;
  28092. return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
  28093. }
  28094. /**
  28095. * Checks if `object` conforms to `source` by invoking the predicate
  28096. * properties of `source` with the corresponding property values of `object`.
  28097. *
  28098. * **Note:** This method is equivalent to `_.conforms` when `source` is
  28099. * partially applied.
  28100. *
  28101. * @static
  28102. * @memberOf _
  28103. * @since 4.14.0
  28104. * @category Lang
  28105. * @param {Object} object The object to inspect.
  28106. * @param {Object} source The object of property predicates to conform to.
  28107. * @returns {boolean} Returns `true` if `object` conforms, else `false`.
  28108. * @example
  28109. *
  28110. * var object = { 'a': 1, 'b': 2 };
  28111. *
  28112. * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
  28113. * // => true
  28114. *
  28115. * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
  28116. * // => false
  28117. */
  28118. function conformsTo(object, source) {
  28119. return source == null || baseConformsTo(object, source, keys(source));
  28120. }
  28121. /**
  28122. * Performs a
  28123. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  28124. * comparison between two values to determine if they are equivalent.
  28125. *
  28126. * @static
  28127. * @memberOf _
  28128. * @since 4.0.0
  28129. * @category Lang
  28130. * @param {*} value The value to compare.
  28131. * @param {*} other The other value to compare.
  28132. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28133. * @example
  28134. *
  28135. * var object = { 'a': 1 };
  28136. * var other = { 'a': 1 };
  28137. *
  28138. * _.eq(object, object);
  28139. * // => true
  28140. *
  28141. * _.eq(object, other);
  28142. * // => false
  28143. *
  28144. * _.eq('a', 'a');
  28145. * // => true
  28146. *
  28147. * _.eq('a', Object('a'));
  28148. * // => false
  28149. *
  28150. * _.eq(NaN, NaN);
  28151. * // => true
  28152. */
  28153. function eq(value, other) {
  28154. return value === other || (value !== value && other !== other);
  28155. }
  28156. /**
  28157. * Checks if `value` is greater than `other`.
  28158. *
  28159. * @static
  28160. * @memberOf _
  28161. * @since 3.9.0
  28162. * @category Lang
  28163. * @param {*} value The value to compare.
  28164. * @param {*} other The other value to compare.
  28165. * @returns {boolean} Returns `true` if `value` is greater than `other`,
  28166. * else `false`.
  28167. * @see _.lt
  28168. * @example
  28169. *
  28170. * _.gt(3, 1);
  28171. * // => true
  28172. *
  28173. * _.gt(3, 3);
  28174. * // => false
  28175. *
  28176. * _.gt(1, 3);
  28177. * // => false
  28178. */
  28179. var gt = createRelationalOperation(baseGt);
  28180. /**
  28181. * Checks if `value` is greater than or equal to `other`.
  28182. *
  28183. * @static
  28184. * @memberOf _
  28185. * @since 3.9.0
  28186. * @category Lang
  28187. * @param {*} value The value to compare.
  28188. * @param {*} other The other value to compare.
  28189. * @returns {boolean} Returns `true` if `value` is greater than or equal to
  28190. * `other`, else `false`.
  28191. * @see _.lte
  28192. * @example
  28193. *
  28194. * _.gte(3, 1);
  28195. * // => true
  28196. *
  28197. * _.gte(3, 3);
  28198. * // => true
  28199. *
  28200. * _.gte(1, 3);
  28201. * // => false
  28202. */
  28203. var gte = createRelationalOperation(function(value, other) {
  28204. return value >= other;
  28205. });
  28206. /**
  28207. * Checks if `value` is likely an `arguments` object.
  28208. *
  28209. * @static
  28210. * @memberOf _
  28211. * @since 0.1.0
  28212. * @category Lang
  28213. * @param {*} value The value to check.
  28214. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  28215. * else `false`.
  28216. * @example
  28217. *
  28218. * _.isArguments(function() { return arguments; }());
  28219. * // => true
  28220. *
  28221. * _.isArguments([1, 2, 3]);
  28222. * // => false
  28223. */
  28224. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  28225. return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
  28226. !propertyIsEnumerable.call(value, 'callee');
  28227. };
  28228. /**
  28229. * Checks if `value` is classified as an `Array` object.
  28230. *
  28231. * @static
  28232. * @memberOf _
  28233. * @since 0.1.0
  28234. * @category Lang
  28235. * @param {*} value The value to check.
  28236. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  28237. * @example
  28238. *
  28239. * _.isArray([1, 2, 3]);
  28240. * // => true
  28241. *
  28242. * _.isArray(document.body.children);
  28243. * // => false
  28244. *
  28245. * _.isArray('abc');
  28246. * // => false
  28247. *
  28248. * _.isArray(_.noop);
  28249. * // => false
  28250. */
  28251. var isArray = Array.isArray;
  28252. /**
  28253. * Checks if `value` is classified as an `ArrayBuffer` object.
  28254. *
  28255. * @static
  28256. * @memberOf _
  28257. * @since 4.3.0
  28258. * @category Lang
  28259. * @param {*} value The value to check.
  28260. * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
  28261. * @example
  28262. *
  28263. * _.isArrayBuffer(new ArrayBuffer(2));
  28264. * // => true
  28265. *
  28266. * _.isArrayBuffer(new Array(2));
  28267. * // => false
  28268. */
  28269. var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
  28270. /**
  28271. * Checks if `value` is array-like. A value is considered array-like if it's
  28272. * not a function and has a `value.length` that's an integer greater than or
  28273. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  28274. *
  28275. * @static
  28276. * @memberOf _
  28277. * @since 4.0.0
  28278. * @category Lang
  28279. * @param {*} value The value to check.
  28280. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  28281. * @example
  28282. *
  28283. * _.isArrayLike([1, 2, 3]);
  28284. * // => true
  28285. *
  28286. * _.isArrayLike(document.body.children);
  28287. * // => true
  28288. *
  28289. * _.isArrayLike('abc');
  28290. * // => true
  28291. *
  28292. * _.isArrayLike(_.noop);
  28293. * // => false
  28294. */
  28295. function isArrayLike(value) {
  28296. return value != null && isLength(value.length) && !isFunction(value);
  28297. }
  28298. /**
  28299. * This method is like `_.isArrayLike` except that it also checks if `value`
  28300. * is an object.
  28301. *
  28302. * @static
  28303. * @memberOf _
  28304. * @since 4.0.0
  28305. * @category Lang
  28306. * @param {*} value The value to check.
  28307. * @returns {boolean} Returns `true` if `value` is an array-like object,
  28308. * else `false`.
  28309. * @example
  28310. *
  28311. * _.isArrayLikeObject([1, 2, 3]);
  28312. * // => true
  28313. *
  28314. * _.isArrayLikeObject(document.body.children);
  28315. * // => true
  28316. *
  28317. * _.isArrayLikeObject('abc');
  28318. * // => false
  28319. *
  28320. * _.isArrayLikeObject(_.noop);
  28321. * // => false
  28322. */
  28323. function isArrayLikeObject(value) {
  28324. return isObjectLike(value) && isArrayLike(value);
  28325. }
  28326. /**
  28327. * Checks if `value` is classified as a boolean primitive or object.
  28328. *
  28329. * @static
  28330. * @memberOf _
  28331. * @since 0.1.0
  28332. * @category Lang
  28333. * @param {*} value The value to check.
  28334. * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
  28335. * @example
  28336. *
  28337. * _.isBoolean(false);
  28338. * // => true
  28339. *
  28340. * _.isBoolean(null);
  28341. * // => false
  28342. */
  28343. function isBoolean(value) {
  28344. return value === true || value === false ||
  28345. (isObjectLike(value) && baseGetTag(value) == boolTag);
  28346. }
  28347. /**
  28348. * Checks if `value` is a buffer.
  28349. *
  28350. * @static
  28351. * @memberOf _
  28352. * @since 4.3.0
  28353. * @category Lang
  28354. * @param {*} value The value to check.
  28355. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  28356. * @example
  28357. *
  28358. * _.isBuffer(new Buffer(2));
  28359. * // => true
  28360. *
  28361. * _.isBuffer(new Uint8Array(2));
  28362. * // => false
  28363. */
  28364. var isBuffer = nativeIsBuffer || stubFalse;
  28365. /**
  28366. * Checks if `value` is classified as a `Date` object.
  28367. *
  28368. * @static
  28369. * @memberOf _
  28370. * @since 0.1.0
  28371. * @category Lang
  28372. * @param {*} value The value to check.
  28373. * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
  28374. * @example
  28375. *
  28376. * _.isDate(new Date);
  28377. * // => true
  28378. *
  28379. * _.isDate('Mon April 23 2012');
  28380. * // => false
  28381. */
  28382. var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
  28383. /**
  28384. * Checks if `value` is likely a DOM element.
  28385. *
  28386. * @static
  28387. * @memberOf _
  28388. * @since 0.1.0
  28389. * @category Lang
  28390. * @param {*} value The value to check.
  28391. * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
  28392. * @example
  28393. *
  28394. * _.isElement(document.body);
  28395. * // => true
  28396. *
  28397. * _.isElement('<body>');
  28398. * // => false
  28399. */
  28400. function isElement(value) {
  28401. return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
  28402. }
  28403. /**
  28404. * Checks if `value` is an empty object, collection, map, or set.
  28405. *
  28406. * Objects are considered empty if they have no own enumerable string keyed
  28407. * properties.
  28408. *
  28409. * Array-like values such as `arguments` objects, arrays, buffers, strings, or
  28410. * jQuery-like collections are considered empty if they have a `length` of `0`.
  28411. * Similarly, maps and sets are considered empty if they have a `size` of `0`.
  28412. *
  28413. * @static
  28414. * @memberOf _
  28415. * @since 0.1.0
  28416. * @category Lang
  28417. * @param {*} value The value to check.
  28418. * @returns {boolean} Returns `true` if `value` is empty, else `false`.
  28419. * @example
  28420. *
  28421. * _.isEmpty(null);
  28422. * // => true
  28423. *
  28424. * _.isEmpty(true);
  28425. * // => true
  28426. *
  28427. * _.isEmpty(1);
  28428. * // => true
  28429. *
  28430. * _.isEmpty([1, 2, 3]);
  28431. * // => false
  28432. *
  28433. * _.isEmpty({ 'a': 1 });
  28434. * // => false
  28435. */
  28436. function isEmpty(value) {
  28437. if (value == null) {
  28438. return true;
  28439. }
  28440. if (isArrayLike(value) &&
  28441. (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
  28442. isBuffer(value) || isTypedArray(value) || isArguments(value))) {
  28443. return !value.length;
  28444. }
  28445. var tag = getTag(value);
  28446. if (tag == mapTag || tag == setTag) {
  28447. return !value.size;
  28448. }
  28449. if (isPrototype(value)) {
  28450. return !baseKeys(value).length;
  28451. }
  28452. for (var key in value) {
  28453. if (hasOwnProperty.call(value, key)) {
  28454. return false;
  28455. }
  28456. }
  28457. return true;
  28458. }
  28459. /**
  28460. * Performs a deep comparison between two values to determine if they are
  28461. * equivalent.
  28462. *
  28463. * **Note:** This method supports comparing arrays, array buffers, booleans,
  28464. * date objects, error objects, maps, numbers, `Object` objects, regexes,
  28465. * sets, strings, symbols, and typed arrays. `Object` objects are compared
  28466. * by their own, not inherited, enumerable properties. Functions and DOM
  28467. * nodes are compared by strict equality, i.e. `===`.
  28468. *
  28469. * @static
  28470. * @memberOf _
  28471. * @since 0.1.0
  28472. * @category Lang
  28473. * @param {*} value The value to compare.
  28474. * @param {*} other The other value to compare.
  28475. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28476. * @example
  28477. *
  28478. * var object = { 'a': 1 };
  28479. * var other = { 'a': 1 };
  28480. *
  28481. * _.isEqual(object, other);
  28482. * // => true
  28483. *
  28484. * object === other;
  28485. * // => false
  28486. */
  28487. function isEqual(value, other) {
  28488. return baseIsEqual(value, other);
  28489. }
  28490. /**
  28491. * This method is like `_.isEqual` except that it accepts `customizer` which
  28492. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  28493. * are handled by the method instead. The `customizer` is invoked with up to
  28494. * six arguments: (objValue, othValue [, index|key, object, other, stack]).
  28495. *
  28496. * @static
  28497. * @memberOf _
  28498. * @since 4.0.0
  28499. * @category Lang
  28500. * @param {*} value The value to compare.
  28501. * @param {*} other The other value to compare.
  28502. * @param {Function} [customizer] The function to customize comparisons.
  28503. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  28504. * @example
  28505. *
  28506. * function isGreeting(value) {
  28507. * return /^h(?:i|ello)$/.test(value);
  28508. * }
  28509. *
  28510. * function customizer(objValue, othValue) {
  28511. * if (isGreeting(objValue) && isGreeting(othValue)) {
  28512. * return true;
  28513. * }
  28514. * }
  28515. *
  28516. * var array = ['hello', 'goodbye'];
  28517. * var other = ['hi', 'goodbye'];
  28518. *
  28519. * _.isEqualWith(array, other, customizer);
  28520. * // => true
  28521. */
  28522. function isEqualWith(value, other, customizer) {
  28523. customizer = typeof customizer == 'function' ? customizer : undefined;
  28524. var result = customizer ? customizer(value, other) : undefined;
  28525. return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
  28526. }
  28527. /**
  28528. * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`,
  28529. * `SyntaxError`, `TypeError`, or `URIError` object.
  28530. *
  28531. * @static
  28532. * @memberOf _
  28533. * @since 3.0.0
  28534. * @category Lang
  28535. * @param {*} value The value to check.
  28536. * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
  28537. * @example
  28538. *
  28539. * _.isError(new Error);
  28540. * // => true
  28541. *
  28542. * _.isError(Error);
  28543. * // => false
  28544. */
  28545. function isError(value) {
  28546. if (!isObjectLike(value)) {
  28547. return false;
  28548. }
  28549. var tag = baseGetTag(value);
  28550. return tag == errorTag || tag == domExcTag ||
  28551. (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
  28552. }
  28553. /**
  28554. * Checks if `value` is a finite primitive number.
  28555. *
  28556. * **Note:** This method is based on
  28557. * [`Number.isFinite`](https://mdn.io/Number/isFinite).
  28558. *
  28559. * @static
  28560. * @memberOf _
  28561. * @since 0.1.0
  28562. * @category Lang
  28563. * @param {*} value The value to check.
  28564. * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
  28565. * @example
  28566. *
  28567. * _.isFinite(3);
  28568. * // => true
  28569. *
  28570. * _.isFinite(Number.MIN_VALUE);
  28571. * // => true
  28572. *
  28573. * _.isFinite(Infinity);
  28574. * // => false
  28575. *
  28576. * _.isFinite('3');
  28577. * // => false
  28578. */
  28579. function isFinite(value) {
  28580. return typeof value == 'number' && nativeIsFinite(value);
  28581. }
  28582. /**
  28583. * Checks if `value` is classified as a `Function` object.
  28584. *
  28585. * @static
  28586. * @memberOf _
  28587. * @since 0.1.0
  28588. * @category Lang
  28589. * @param {*} value The value to check.
  28590. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  28591. * @example
  28592. *
  28593. * _.isFunction(_);
  28594. * // => true
  28595. *
  28596. * _.isFunction(/abc/);
  28597. * // => false
  28598. */
  28599. function isFunction(value) {
  28600. if (!isObject(value)) {
  28601. return false;
  28602. }
  28603. // The use of `Object#toString` avoids issues with the `typeof` operator
  28604. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  28605. var tag = baseGetTag(value);
  28606. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  28607. }
  28608. /**
  28609. * Checks if `value` is an integer.
  28610. *
  28611. * **Note:** This method is based on
  28612. * [`Number.isInteger`](https://mdn.io/Number/isInteger).
  28613. *
  28614. * @static
  28615. * @memberOf _
  28616. * @since 4.0.0
  28617. * @category Lang
  28618. * @param {*} value The value to check.
  28619. * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
  28620. * @example
  28621. *
  28622. * _.isInteger(3);
  28623. * // => true
  28624. *
  28625. * _.isInteger(Number.MIN_VALUE);
  28626. * // => false
  28627. *
  28628. * _.isInteger(Infinity);
  28629. * // => false
  28630. *
  28631. * _.isInteger('3');
  28632. * // => false
  28633. */
  28634. function isInteger(value) {
  28635. return typeof value == 'number' && value == toInteger(value);
  28636. }
  28637. /**
  28638. * Checks if `value` is a valid array-like length.
  28639. *
  28640. * **Note:** This method is loosely based on
  28641. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  28642. *
  28643. * @static
  28644. * @memberOf _
  28645. * @since 4.0.0
  28646. * @category Lang
  28647. * @param {*} value The value to check.
  28648. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  28649. * @example
  28650. *
  28651. * _.isLength(3);
  28652. * // => true
  28653. *
  28654. * _.isLength(Number.MIN_VALUE);
  28655. * // => false
  28656. *
  28657. * _.isLength(Infinity);
  28658. * // => false
  28659. *
  28660. * _.isLength('3');
  28661. * // => false
  28662. */
  28663. function isLength(value) {
  28664. return typeof value == 'number' &&
  28665. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  28666. }
  28667. /**
  28668. * Checks if `value` is the
  28669. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  28670. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  28671. *
  28672. * @static
  28673. * @memberOf _
  28674. * @since 0.1.0
  28675. * @category Lang
  28676. * @param {*} value The value to check.
  28677. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  28678. * @example
  28679. *
  28680. * _.isObject({});
  28681. * // => true
  28682. *
  28683. * _.isObject([1, 2, 3]);
  28684. * // => true
  28685. *
  28686. * _.isObject(_.noop);
  28687. * // => true
  28688. *
  28689. * _.isObject(null);
  28690. * // => false
  28691. */
  28692. function isObject(value) {
  28693. var type = typeof value;
  28694. return value != null && (type == 'object' || type == 'function');
  28695. }
  28696. /**
  28697. * Checks if `value` is object-like. A value is object-like if it's not `null`
  28698. * and has a `typeof` result of "object".
  28699. *
  28700. * @static
  28701. * @memberOf _
  28702. * @since 4.0.0
  28703. * @category Lang
  28704. * @param {*} value The value to check.
  28705. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  28706. * @example
  28707. *
  28708. * _.isObjectLike({});
  28709. * // => true
  28710. *
  28711. * _.isObjectLike([1, 2, 3]);
  28712. * // => true
  28713. *
  28714. * _.isObjectLike(_.noop);
  28715. * // => false
  28716. *
  28717. * _.isObjectLike(null);
  28718. * // => false
  28719. */
  28720. function isObjectLike(value) {
  28721. return value != null && typeof value == 'object';
  28722. }
  28723. /**
  28724. * Checks if `value` is classified as a `Map` object.
  28725. *
  28726. * @static
  28727. * @memberOf _
  28728. * @since 4.3.0
  28729. * @category Lang
  28730. * @param {*} value The value to check.
  28731. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  28732. * @example
  28733. *
  28734. * _.isMap(new Map);
  28735. * // => true
  28736. *
  28737. * _.isMap(new WeakMap);
  28738. * // => false
  28739. */
  28740. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  28741. /**
  28742. * Performs a partial deep comparison between `object` and `source` to
  28743. * determine if `object` contains equivalent property values.
  28744. *
  28745. * **Note:** This method is equivalent to `_.matches` when `source` is
  28746. * partially applied.
  28747. *
  28748. * Partial comparisons will match empty array and empty object `source`
  28749. * values against any array or object value, respectively. See `_.isEqual`
  28750. * for a list of supported value comparisons.
  28751. *
  28752. * @static
  28753. * @memberOf _
  28754. * @since 3.0.0
  28755. * @category Lang
  28756. * @param {Object} object The object to inspect.
  28757. * @param {Object} source The object of property values to match.
  28758. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  28759. * @example
  28760. *
  28761. * var object = { 'a': 1, 'b': 2 };
  28762. *
  28763. * _.isMatch(object, { 'b': 2 });
  28764. * // => true
  28765. *
  28766. * _.isMatch(object, { 'b': 1 });
  28767. * // => false
  28768. */
  28769. function isMatch(object, source) {
  28770. return object === source || baseIsMatch(object, source, getMatchData(source));
  28771. }
  28772. /**
  28773. * This method is like `_.isMatch` except that it accepts `customizer` which
  28774. * is invoked to compare values. If `customizer` returns `undefined`, comparisons
  28775. * are handled by the method instead. The `customizer` is invoked with five
  28776. * arguments: (objValue, srcValue, index|key, object, source).
  28777. *
  28778. * @static
  28779. * @memberOf _
  28780. * @since 4.0.0
  28781. * @category Lang
  28782. * @param {Object} object The object to inspect.
  28783. * @param {Object} source The object of property values to match.
  28784. * @param {Function} [customizer] The function to customize comparisons.
  28785. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  28786. * @example
  28787. *
  28788. * function isGreeting(value) {
  28789. * return /^h(?:i|ello)$/.test(value);
  28790. * }
  28791. *
  28792. * function customizer(objValue, srcValue) {
  28793. * if (isGreeting(objValue) && isGreeting(srcValue)) {
  28794. * return true;
  28795. * }
  28796. * }
  28797. *
  28798. * var object = { 'greeting': 'hello' };
  28799. * var source = { 'greeting': 'hi' };
  28800. *
  28801. * _.isMatchWith(object, source, customizer);
  28802. * // => true
  28803. */
  28804. function isMatchWith(object, source, customizer) {
  28805. customizer = typeof customizer == 'function' ? customizer : undefined;
  28806. return baseIsMatch(object, source, getMatchData(source), customizer);
  28807. }
  28808. /**
  28809. * Checks if `value` is `NaN`.
  28810. *
  28811. * **Note:** This method is based on
  28812. * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as
  28813. * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for
  28814. * `undefined` and other non-number values.
  28815. *
  28816. * @static
  28817. * @memberOf _
  28818. * @since 0.1.0
  28819. * @category Lang
  28820. * @param {*} value The value to check.
  28821. * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
  28822. * @example
  28823. *
  28824. * _.isNaN(NaN);
  28825. * // => true
  28826. *
  28827. * _.isNaN(new Number(NaN));
  28828. * // => true
  28829. *
  28830. * isNaN(undefined);
  28831. * // => true
  28832. *
  28833. * _.isNaN(undefined);
  28834. * // => false
  28835. */
  28836. function isNaN(value) {
  28837. // An `NaN` primitive is the only value that is not equal to itself.
  28838. // Perform the `toStringTag` check first to avoid errors with some
  28839. // ActiveX objects in IE.
  28840. return isNumber(value) && value != +value;
  28841. }
  28842. /**
  28843. * Checks if `value` is a pristine native function.
  28844. *
  28845. * **Note:** This method can't reliably detect native functions in the presence
  28846. * of the core-js package because core-js circumvents this kind of detection.
  28847. * Despite multiple requests, the core-js maintainer has made it clear: any
  28848. * attempt to fix the detection will be obstructed. As a result, we're left
  28849. * with little choice but to throw an error. Unfortunately, this also affects
  28850. * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
  28851. * which rely on core-js.
  28852. *
  28853. * @static
  28854. * @memberOf _
  28855. * @since 3.0.0
  28856. * @category Lang
  28857. * @param {*} value The value to check.
  28858. * @returns {boolean} Returns `true` if `value` is a native function,
  28859. * else `false`.
  28860. * @example
  28861. *
  28862. * _.isNative(Array.prototype.push);
  28863. * // => true
  28864. *
  28865. * _.isNative(_);
  28866. * // => false
  28867. */
  28868. function isNative(value) {
  28869. if (isMaskable(value)) {
  28870. throw new Error(CORE_ERROR_TEXT);
  28871. }
  28872. return baseIsNative(value);
  28873. }
  28874. /**
  28875. * Checks if `value` is `null`.
  28876. *
  28877. * @static
  28878. * @memberOf _
  28879. * @since 0.1.0
  28880. * @category Lang
  28881. * @param {*} value The value to check.
  28882. * @returns {boolean} Returns `true` if `value` is `null`, else `false`.
  28883. * @example
  28884. *
  28885. * _.isNull(null);
  28886. * // => true
  28887. *
  28888. * _.isNull(void 0);
  28889. * // => false
  28890. */
  28891. function isNull(value) {
  28892. return value === null;
  28893. }
  28894. /**
  28895. * Checks if `value` is `null` or `undefined`.
  28896. *
  28897. * @static
  28898. * @memberOf _
  28899. * @since 4.0.0
  28900. * @category Lang
  28901. * @param {*} value The value to check.
  28902. * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
  28903. * @example
  28904. *
  28905. * _.isNil(null);
  28906. * // => true
  28907. *
  28908. * _.isNil(void 0);
  28909. * // => true
  28910. *
  28911. * _.isNil(NaN);
  28912. * // => false
  28913. */
  28914. function isNil(value) {
  28915. return value == null;
  28916. }
  28917. /**
  28918. * Checks if `value` is classified as a `Number` primitive or object.
  28919. *
  28920. * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
  28921. * classified as numbers, use the `_.isFinite` method.
  28922. *
  28923. * @static
  28924. * @memberOf _
  28925. * @since 0.1.0
  28926. * @category Lang
  28927. * @param {*} value The value to check.
  28928. * @returns {boolean} Returns `true` if `value` is a number, else `false`.
  28929. * @example
  28930. *
  28931. * _.isNumber(3);
  28932. * // => true
  28933. *
  28934. * _.isNumber(Number.MIN_VALUE);
  28935. * // => true
  28936. *
  28937. * _.isNumber(Infinity);
  28938. * // => true
  28939. *
  28940. * _.isNumber('3');
  28941. * // => false
  28942. */
  28943. function isNumber(value) {
  28944. return typeof value == 'number' ||
  28945. (isObjectLike(value) && baseGetTag(value) == numberTag);
  28946. }
  28947. /**
  28948. * Checks if `value` is a plain object, that is, an object created by the
  28949. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  28950. *
  28951. * @static
  28952. * @memberOf _
  28953. * @since 0.8.0
  28954. * @category Lang
  28955. * @param {*} value The value to check.
  28956. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  28957. * @example
  28958. *
  28959. * function Foo() {
  28960. * this.a = 1;
  28961. * }
  28962. *
  28963. * _.isPlainObject(new Foo);
  28964. * // => false
  28965. *
  28966. * _.isPlainObject([1, 2, 3]);
  28967. * // => false
  28968. *
  28969. * _.isPlainObject({ 'x': 0, 'y': 0 });
  28970. * // => true
  28971. *
  28972. * _.isPlainObject(Object.create(null));
  28973. * // => true
  28974. */
  28975. function isPlainObject(value) {
  28976. if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
  28977. return false;
  28978. }
  28979. var proto = getPrototype(value);
  28980. if (proto === null) {
  28981. return true;
  28982. }
  28983. var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
  28984. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  28985. funcToString.call(Ctor) == objectCtorString;
  28986. }
  28987. /**
  28988. * Checks if `value` is classified as a `RegExp` object.
  28989. *
  28990. * @static
  28991. * @memberOf _
  28992. * @since 0.1.0
  28993. * @category Lang
  28994. * @param {*} value The value to check.
  28995. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
  28996. * @example
  28997. *
  28998. * _.isRegExp(/abc/);
  28999. * // => true
  29000. *
  29001. * _.isRegExp('/abc/');
  29002. * // => false
  29003. */
  29004. var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
  29005. /**
  29006. * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
  29007. * double precision number which isn't the result of a rounded unsafe integer.
  29008. *
  29009. * **Note:** This method is based on
  29010. * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger).
  29011. *
  29012. * @static
  29013. * @memberOf _
  29014. * @since 4.0.0
  29015. * @category Lang
  29016. * @param {*} value The value to check.
  29017. * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
  29018. * @example
  29019. *
  29020. * _.isSafeInteger(3);
  29021. * // => true
  29022. *
  29023. * _.isSafeInteger(Number.MIN_VALUE);
  29024. * // => false
  29025. *
  29026. * _.isSafeInteger(Infinity);
  29027. * // => false
  29028. *
  29029. * _.isSafeInteger('3');
  29030. * // => false
  29031. */
  29032. function isSafeInteger(value) {
  29033. return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER;
  29034. }
  29035. /**
  29036. * Checks if `value` is classified as a `Set` object.
  29037. *
  29038. * @static
  29039. * @memberOf _
  29040. * @since 4.3.0
  29041. * @category Lang
  29042. * @param {*} value The value to check.
  29043. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  29044. * @example
  29045. *
  29046. * _.isSet(new Set);
  29047. * // => true
  29048. *
  29049. * _.isSet(new WeakSet);
  29050. * // => false
  29051. */
  29052. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  29053. /**
  29054. * Checks if `value` is classified as a `String` primitive or object.
  29055. *
  29056. * @static
  29057. * @since 0.1.0
  29058. * @memberOf _
  29059. * @category Lang
  29060. * @param {*} value The value to check.
  29061. * @returns {boolean} Returns `true` if `value` is a string, else `false`.
  29062. * @example
  29063. *
  29064. * _.isString('abc');
  29065. * // => true
  29066. *
  29067. * _.isString(1);
  29068. * // => false
  29069. */
  29070. function isString(value) {
  29071. return typeof value == 'string' ||
  29072. (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
  29073. }
  29074. /**
  29075. * Checks if `value` is classified as a `Symbol` primitive or object.
  29076. *
  29077. * @static
  29078. * @memberOf _
  29079. * @since 4.0.0
  29080. * @category Lang
  29081. * @param {*} value The value to check.
  29082. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  29083. * @example
  29084. *
  29085. * _.isSymbol(Symbol.iterator);
  29086. * // => true
  29087. *
  29088. * _.isSymbol('abc');
  29089. * // => false
  29090. */
  29091. function isSymbol(value) {
  29092. return typeof value == 'symbol' ||
  29093. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  29094. }
  29095. /**
  29096. * Checks if `value` is classified as a typed array.
  29097. *
  29098. * @static
  29099. * @memberOf _
  29100. * @since 3.0.0
  29101. * @category Lang
  29102. * @param {*} value The value to check.
  29103. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  29104. * @example
  29105. *
  29106. * _.isTypedArray(new Uint8Array);
  29107. * // => true
  29108. *
  29109. * _.isTypedArray([]);
  29110. * // => false
  29111. */
  29112. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  29113. /**
  29114. * Checks if `value` is `undefined`.
  29115. *
  29116. * @static
  29117. * @since 0.1.0
  29118. * @memberOf _
  29119. * @category Lang
  29120. * @param {*} value The value to check.
  29121. * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
  29122. * @example
  29123. *
  29124. * _.isUndefined(void 0);
  29125. * // => true
  29126. *
  29127. * _.isUndefined(null);
  29128. * // => false
  29129. */
  29130. function isUndefined(value) {
  29131. return value === undefined;
  29132. }
  29133. /**
  29134. * Checks if `value` is classified as a `WeakMap` object.
  29135. *
  29136. * @static
  29137. * @memberOf _
  29138. * @since 4.3.0
  29139. * @category Lang
  29140. * @param {*} value The value to check.
  29141. * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
  29142. * @example
  29143. *
  29144. * _.isWeakMap(new WeakMap);
  29145. * // => true
  29146. *
  29147. * _.isWeakMap(new Map);
  29148. * // => false
  29149. */
  29150. function isWeakMap(value) {
  29151. return isObjectLike(value) && getTag(value) == weakMapTag;
  29152. }
  29153. /**
  29154. * Checks if `value` is classified as a `WeakSet` object.
  29155. *
  29156. * @static
  29157. * @memberOf _
  29158. * @since 4.3.0
  29159. * @category Lang
  29160. * @param {*} value The value to check.
  29161. * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
  29162. * @example
  29163. *
  29164. * _.isWeakSet(new WeakSet);
  29165. * // => true
  29166. *
  29167. * _.isWeakSet(new Set);
  29168. * // => false
  29169. */
  29170. function isWeakSet(value) {
  29171. return isObjectLike(value) && baseGetTag(value) == weakSetTag;
  29172. }
  29173. /**
  29174. * Checks if `value` is less than `other`.
  29175. *
  29176. * @static
  29177. * @memberOf _
  29178. * @since 3.9.0
  29179. * @category Lang
  29180. * @param {*} value The value to compare.
  29181. * @param {*} other The other value to compare.
  29182. * @returns {boolean} Returns `true` if `value` is less than `other`,
  29183. * else `false`.
  29184. * @see _.gt
  29185. * @example
  29186. *
  29187. * _.lt(1, 3);
  29188. * // => true
  29189. *
  29190. * _.lt(3, 3);
  29191. * // => false
  29192. *
  29193. * _.lt(3, 1);
  29194. * // => false
  29195. */
  29196. var lt = createRelationalOperation(baseLt);
  29197. /**
  29198. * Checks if `value` is less than or equal to `other`.
  29199. *
  29200. * @static
  29201. * @memberOf _
  29202. * @since 3.9.0
  29203. * @category Lang
  29204. * @param {*} value The value to compare.
  29205. * @param {*} other The other value to compare.
  29206. * @returns {boolean} Returns `true` if `value` is less than or equal to
  29207. * `other`, else `false`.
  29208. * @see _.gte
  29209. * @example
  29210. *
  29211. * _.lte(1, 3);
  29212. * // => true
  29213. *
  29214. * _.lte(3, 3);
  29215. * // => true
  29216. *
  29217. * _.lte(3, 1);
  29218. * // => false
  29219. */
  29220. var lte = createRelationalOperation(function(value, other) {
  29221. return value <= other;
  29222. });
  29223. /**
  29224. * Converts `value` to an array.
  29225. *
  29226. * @static
  29227. * @since 0.1.0
  29228. * @memberOf _
  29229. * @category Lang
  29230. * @param {*} value The value to convert.
  29231. * @returns {Array} Returns the converted array.
  29232. * @example
  29233. *
  29234. * _.toArray({ 'a': 1, 'b': 2 });
  29235. * // => [1, 2]
  29236. *
  29237. * _.toArray('abc');
  29238. * // => ['a', 'b', 'c']
  29239. *
  29240. * _.toArray(1);
  29241. * // => []
  29242. *
  29243. * _.toArray(null);
  29244. * // => []
  29245. */
  29246. function toArray(value) {
  29247. if (!value) {
  29248. return [];
  29249. }
  29250. if (isArrayLike(value)) {
  29251. return isString(value) ? stringToArray(value) : copyArray(value);
  29252. }
  29253. if (symIterator && value[symIterator]) {
  29254. return iteratorToArray(value[symIterator]());
  29255. }
  29256. var tag = getTag(value),
  29257. func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
  29258. return func(value);
  29259. }
  29260. /**
  29261. * Converts `value` to a finite number.
  29262. *
  29263. * @static
  29264. * @memberOf _
  29265. * @since 4.12.0
  29266. * @category Lang
  29267. * @param {*} value The value to convert.
  29268. * @returns {number} Returns the converted number.
  29269. * @example
  29270. *
  29271. * _.toFinite(3.2);
  29272. * // => 3.2
  29273. *
  29274. * _.toFinite(Number.MIN_VALUE);
  29275. * // => 5e-324
  29276. *
  29277. * _.toFinite(Infinity);
  29278. * // => 1.7976931348623157e+308
  29279. *
  29280. * _.toFinite('3.2');
  29281. * // => 3.2
  29282. */
  29283. function toFinite(value) {
  29284. if (!value) {
  29285. return value === 0 ? value : 0;
  29286. }
  29287. value = toNumber(value);
  29288. if (value === INFINITY || value === -INFINITY) {
  29289. var sign = (value < 0 ? -1 : 1);
  29290. return sign * MAX_INTEGER;
  29291. }
  29292. return value === value ? value : 0;
  29293. }
  29294. /**
  29295. * Converts `value` to an integer.
  29296. *
  29297. * **Note:** This method is loosely based on
  29298. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  29299. *
  29300. * @static
  29301. * @memberOf _
  29302. * @since 4.0.0
  29303. * @category Lang
  29304. * @param {*} value The value to convert.
  29305. * @returns {number} Returns the converted integer.
  29306. * @example
  29307. *
  29308. * _.toInteger(3.2);
  29309. * // => 3
  29310. *
  29311. * _.toInteger(Number.MIN_VALUE);
  29312. * // => 0
  29313. *
  29314. * _.toInteger(Infinity);
  29315. * // => 1.7976931348623157e+308
  29316. *
  29317. * _.toInteger('3.2');
  29318. * // => 3
  29319. */
  29320. function toInteger(value) {
  29321. var result = toFinite(value),
  29322. remainder = result % 1;
  29323. return result === result ? (remainder ? result - remainder : result) : 0;
  29324. }
  29325. /**
  29326. * Converts `value` to an integer suitable for use as the length of an
  29327. * array-like object.
  29328. *
  29329. * **Note:** This method is based on
  29330. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  29331. *
  29332. * @static
  29333. * @memberOf _
  29334. * @since 4.0.0
  29335. * @category Lang
  29336. * @param {*} value The value to convert.
  29337. * @returns {number} Returns the converted integer.
  29338. * @example
  29339. *
  29340. * _.toLength(3.2);
  29341. * // => 3
  29342. *
  29343. * _.toLength(Number.MIN_VALUE);
  29344. * // => 0
  29345. *
  29346. * _.toLength(Infinity);
  29347. * // => 4294967295
  29348. *
  29349. * _.toLength('3.2');
  29350. * // => 3
  29351. */
  29352. function toLength(value) {
  29353. return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
  29354. }
  29355. /**
  29356. * Converts `value` to a number.
  29357. *
  29358. * @static
  29359. * @memberOf _
  29360. * @since 4.0.0
  29361. * @category Lang
  29362. * @param {*} value The value to process.
  29363. * @returns {number} Returns the number.
  29364. * @example
  29365. *
  29366. * _.toNumber(3.2);
  29367. * // => 3.2
  29368. *
  29369. * _.toNumber(Number.MIN_VALUE);
  29370. * // => 5e-324
  29371. *
  29372. * _.toNumber(Infinity);
  29373. * // => Infinity
  29374. *
  29375. * _.toNumber('3.2');
  29376. * // => 3.2
  29377. */
  29378. function toNumber(value) {
  29379. if (typeof value == 'number') {
  29380. return value;
  29381. }
  29382. if (isSymbol(value)) {
  29383. return NAN;
  29384. }
  29385. if (isObject(value)) {
  29386. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  29387. value = isObject(other) ? (other + '') : other;
  29388. }
  29389. if (typeof value != 'string') {
  29390. return value === 0 ? value : +value;
  29391. }
  29392. value = value.replace(reTrim, '');
  29393. var isBinary = reIsBinary.test(value);
  29394. return (isBinary || reIsOctal.test(value))
  29395. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  29396. : (reIsBadHex.test(value) ? NAN : +value);
  29397. }
  29398. /**
  29399. * Converts `value` to a plain object flattening inherited enumerable string
  29400. * keyed properties of `value` to own properties of the plain object.
  29401. *
  29402. * @static
  29403. * @memberOf _
  29404. * @since 3.0.0
  29405. * @category Lang
  29406. * @param {*} value The value to convert.
  29407. * @returns {Object} Returns the converted plain object.
  29408. * @example
  29409. *
  29410. * function Foo() {
  29411. * this.b = 2;
  29412. * }
  29413. *
  29414. * Foo.prototype.c = 3;
  29415. *
  29416. * _.assign({ 'a': 1 }, new Foo);
  29417. * // => { 'a': 1, 'b': 2 }
  29418. *
  29419. * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
  29420. * // => { 'a': 1, 'b': 2, 'c': 3 }
  29421. */
  29422. function toPlainObject(value) {
  29423. return copyObject(value, keysIn(value));
  29424. }
  29425. /**
  29426. * Converts `value` to a safe integer. A safe integer can be compared and
  29427. * represented correctly.
  29428. *
  29429. * @static
  29430. * @memberOf _
  29431. * @since 4.0.0
  29432. * @category Lang
  29433. * @param {*} value The value to convert.
  29434. * @returns {number} Returns the converted integer.
  29435. * @example
  29436. *
  29437. * _.toSafeInteger(3.2);
  29438. * // => 3
  29439. *
  29440. * _.toSafeInteger(Number.MIN_VALUE);
  29441. * // => 0
  29442. *
  29443. * _.toSafeInteger(Infinity);
  29444. * // => 9007199254740991
  29445. *
  29446. * _.toSafeInteger('3.2');
  29447. * // => 3
  29448. */
  29449. function toSafeInteger(value) {
  29450. return value
  29451. ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
  29452. : (value === 0 ? value : 0);
  29453. }
  29454. /**
  29455. * Converts `value` to a string. An empty string is returned for `null`
  29456. * and `undefined` values. The sign of `-0` is preserved.
  29457. *
  29458. * @static
  29459. * @memberOf _
  29460. * @since 4.0.0
  29461. * @category Lang
  29462. * @param {*} value The value to convert.
  29463. * @returns {string} Returns the converted string.
  29464. * @example
  29465. *
  29466. * _.toString(null);
  29467. * // => ''
  29468. *
  29469. * _.toString(-0);
  29470. * // => '-0'
  29471. *
  29472. * _.toString([1, 2, 3]);
  29473. * // => '1,2,3'
  29474. */
  29475. function toString(value) {
  29476. return value == null ? '' : baseToString(value);
  29477. }
  29478. /*------------------------------------------------------------------------*/
  29479. /**
  29480. * Assigns own enumerable string keyed properties of source objects to the
  29481. * destination object. Source objects are applied from left to right.
  29482. * Subsequent sources overwrite property assignments of previous sources.
  29483. *
  29484. * **Note:** This method mutates `object` and is loosely based on
  29485. * [`Object.assign`](https://mdn.io/Object/assign).
  29486. *
  29487. * @static
  29488. * @memberOf _
  29489. * @since 0.10.0
  29490. * @category Object
  29491. * @param {Object} object The destination object.
  29492. * @param {...Object} [sources] The source objects.
  29493. * @returns {Object} Returns `object`.
  29494. * @see _.assignIn
  29495. * @example
  29496. *
  29497. * function Foo() {
  29498. * this.a = 1;
  29499. * }
  29500. *
  29501. * function Bar() {
  29502. * this.c = 3;
  29503. * }
  29504. *
  29505. * Foo.prototype.b = 2;
  29506. * Bar.prototype.d = 4;
  29507. *
  29508. * _.assign({ 'a': 0 }, new Foo, new Bar);
  29509. * // => { 'a': 1, 'c': 3 }
  29510. */
  29511. var assign = createAssigner(function(object, source) {
  29512. if (isPrototype(source) || isArrayLike(source)) {
  29513. copyObject(source, keys(source), object);
  29514. return;
  29515. }
  29516. for (var key in source) {
  29517. if (hasOwnProperty.call(source, key)) {
  29518. assignValue(object, key, source[key]);
  29519. }
  29520. }
  29521. });
  29522. /**
  29523. * This method is like `_.assign` except that it iterates over own and
  29524. * inherited source properties.
  29525. *
  29526. * **Note:** This method mutates `object`.
  29527. *
  29528. * @static
  29529. * @memberOf _
  29530. * @since 4.0.0
  29531. * @alias extend
  29532. * @category Object
  29533. * @param {Object} object The destination object.
  29534. * @param {...Object} [sources] The source objects.
  29535. * @returns {Object} Returns `object`.
  29536. * @see _.assign
  29537. * @example
  29538. *
  29539. * function Foo() {
  29540. * this.a = 1;
  29541. * }
  29542. *
  29543. * function Bar() {
  29544. * this.c = 3;
  29545. * }
  29546. *
  29547. * Foo.prototype.b = 2;
  29548. * Bar.prototype.d = 4;
  29549. *
  29550. * _.assignIn({ 'a': 0 }, new Foo, new Bar);
  29551. * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
  29552. */
  29553. var assignIn = createAssigner(function(object, source) {
  29554. copyObject(source, keysIn(source), object);
  29555. });
  29556. /**
  29557. * This method is like `_.assignIn` except that it accepts `customizer`
  29558. * which is invoked to produce the assigned values. If `customizer` returns
  29559. * `undefined`, assignment is handled by the method instead. The `customizer`
  29560. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  29561. *
  29562. * **Note:** This method mutates `object`.
  29563. *
  29564. * @static
  29565. * @memberOf _
  29566. * @since 4.0.0
  29567. * @alias extendWith
  29568. * @category Object
  29569. * @param {Object} object The destination object.
  29570. * @param {...Object} sources The source objects.
  29571. * @param {Function} [customizer] The function to customize assigned values.
  29572. * @returns {Object} Returns `object`.
  29573. * @see _.assignWith
  29574. * @example
  29575. *
  29576. * function customizer(objValue, srcValue) {
  29577. * return _.isUndefined(objValue) ? srcValue : objValue;
  29578. * }
  29579. *
  29580. * var defaults = _.partialRight(_.assignInWith, customizer);
  29581. *
  29582. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29583. * // => { 'a': 1, 'b': 2 }
  29584. */
  29585. var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
  29586. copyObject(source, keysIn(source), object, customizer);
  29587. });
  29588. /**
  29589. * This method is like `_.assign` except that it accepts `customizer`
  29590. * which is invoked to produce the assigned values. If `customizer` returns
  29591. * `undefined`, assignment is handled by the method instead. The `customizer`
  29592. * is invoked with five arguments: (objValue, srcValue, key, object, source).
  29593. *
  29594. * **Note:** This method mutates `object`.
  29595. *
  29596. * @static
  29597. * @memberOf _
  29598. * @since 4.0.0
  29599. * @category Object
  29600. * @param {Object} object The destination object.
  29601. * @param {...Object} sources The source objects.
  29602. * @param {Function} [customizer] The function to customize assigned values.
  29603. * @returns {Object} Returns `object`.
  29604. * @see _.assignInWith
  29605. * @example
  29606. *
  29607. * function customizer(objValue, srcValue) {
  29608. * return _.isUndefined(objValue) ? srcValue : objValue;
  29609. * }
  29610. *
  29611. * var defaults = _.partialRight(_.assignWith, customizer);
  29612. *
  29613. * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29614. * // => { 'a': 1, 'b': 2 }
  29615. */
  29616. var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
  29617. copyObject(source, keys(source), object, customizer);
  29618. });
  29619. /**
  29620. * Creates an array of values corresponding to `paths` of `object`.
  29621. *
  29622. * @static
  29623. * @memberOf _
  29624. * @since 1.0.0
  29625. * @category Object
  29626. * @param {Object} object The object to iterate over.
  29627. * @param {...(string|string[])} [paths] The property paths to pick.
  29628. * @returns {Array} Returns the picked values.
  29629. * @example
  29630. *
  29631. * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
  29632. *
  29633. * _.at(object, ['a[0].b.c', 'a[1]']);
  29634. * // => [3, 4]
  29635. */
  29636. var at = flatRest(baseAt);
  29637. /**
  29638. * Creates an object that inherits from the `prototype` object. If a
  29639. * `properties` object is given, its own enumerable string keyed properties
  29640. * are assigned to the created object.
  29641. *
  29642. * @static
  29643. * @memberOf _
  29644. * @since 2.3.0
  29645. * @category Object
  29646. * @param {Object} prototype The object to inherit from.
  29647. * @param {Object} [properties] The properties to assign to the object.
  29648. * @returns {Object} Returns the new object.
  29649. * @example
  29650. *
  29651. * function Shape() {
  29652. * this.x = 0;
  29653. * this.y = 0;
  29654. * }
  29655. *
  29656. * function Circle() {
  29657. * Shape.call(this);
  29658. * }
  29659. *
  29660. * Circle.prototype = _.create(Shape.prototype, {
  29661. * 'constructor': Circle
  29662. * });
  29663. *
  29664. * var circle = new Circle;
  29665. * circle instanceof Circle;
  29666. * // => true
  29667. *
  29668. * circle instanceof Shape;
  29669. * // => true
  29670. */
  29671. function create(prototype, properties) {
  29672. var result = baseCreate(prototype);
  29673. return properties == null ? result : baseAssign(result, properties);
  29674. }
  29675. /**
  29676. * Assigns own and inherited enumerable string keyed properties of source
  29677. * objects to the destination object for all destination properties that
  29678. * resolve to `undefined`. Source objects are applied from left to right.
  29679. * Once a property is set, additional values of the same property are ignored.
  29680. *
  29681. * **Note:** This method mutates `object`.
  29682. *
  29683. * @static
  29684. * @since 0.1.0
  29685. * @memberOf _
  29686. * @category Object
  29687. * @param {Object} object The destination object.
  29688. * @param {...Object} [sources] The source objects.
  29689. * @returns {Object} Returns `object`.
  29690. * @see _.defaultsDeep
  29691. * @example
  29692. *
  29693. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  29694. * // => { 'a': 1, 'b': 2 }
  29695. */
  29696. var defaults = baseRest(function(object, sources) {
  29697. object = Object(object);
  29698. var index = -1;
  29699. var length = sources.length;
  29700. var guard = length > 2 ? sources[2] : undefined;
  29701. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  29702. length = 1;
  29703. }
  29704. while (++index < length) {
  29705. var source = sources[index];
  29706. var props = keysIn(source);
  29707. var propsIndex = -1;
  29708. var propsLength = props.length;
  29709. while (++propsIndex < propsLength) {
  29710. var key = props[propsIndex];
  29711. var value = object[key];
  29712. if (value === undefined ||
  29713. (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) {
  29714. object[key] = source[key];
  29715. }
  29716. }
  29717. }
  29718. return object;
  29719. });
  29720. /**
  29721. * This method is like `_.defaults` except that it recursively assigns
  29722. * default properties.
  29723. *
  29724. * **Note:** This method mutates `object`.
  29725. *
  29726. * @static
  29727. * @memberOf _
  29728. * @since 3.10.0
  29729. * @category Object
  29730. * @param {Object} object The destination object.
  29731. * @param {...Object} [sources] The source objects.
  29732. * @returns {Object} Returns `object`.
  29733. * @see _.defaults
  29734. * @example
  29735. *
  29736. * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
  29737. * // => { 'a': { 'b': 2, 'c': 3 } }
  29738. */
  29739. var defaultsDeep = baseRest(function(args) {
  29740. args.push(undefined, customDefaultsMerge);
  29741. return apply(mergeWith, undefined, args);
  29742. });
  29743. /**
  29744. * This method is like `_.find` except that it returns the key of the first
  29745. * element `predicate` returns truthy for instead of the element itself.
  29746. *
  29747. * @static
  29748. * @memberOf _
  29749. * @since 1.1.0
  29750. * @category Object
  29751. * @param {Object} object The object to inspect.
  29752. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29753. * @returns {string|undefined} Returns the key of the matched element,
  29754. * else `undefined`.
  29755. * @example
  29756. *
  29757. * var users = {
  29758. * 'barney': { 'age': 36, 'active': true },
  29759. * 'fred': { 'age': 40, 'active': false },
  29760. * 'pebbles': { 'age': 1, 'active': true }
  29761. * };
  29762. *
  29763. * _.findKey(users, function(o) { return o.age < 40; });
  29764. * // => 'barney' (iteration order is not guaranteed)
  29765. *
  29766. * // The `_.matches` iteratee shorthand.
  29767. * _.findKey(users, { 'age': 1, 'active': true });
  29768. * // => 'pebbles'
  29769. *
  29770. * // The `_.matchesProperty` iteratee shorthand.
  29771. * _.findKey(users, ['active', false]);
  29772. * // => 'fred'
  29773. *
  29774. * // The `_.property` iteratee shorthand.
  29775. * _.findKey(users, 'active');
  29776. * // => 'barney'
  29777. */
  29778. function findKey(object, predicate) {
  29779. return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
  29780. }
  29781. /**
  29782. * This method is like `_.findKey` except that it iterates over elements of
  29783. * a collection in the opposite order.
  29784. *
  29785. * @static
  29786. * @memberOf _
  29787. * @since 2.0.0
  29788. * @category Object
  29789. * @param {Object} object The object to inspect.
  29790. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  29791. * @returns {string|undefined} Returns the key of the matched element,
  29792. * else `undefined`.
  29793. * @example
  29794. *
  29795. * var users = {
  29796. * 'barney': { 'age': 36, 'active': true },
  29797. * 'fred': { 'age': 40, 'active': false },
  29798. * 'pebbles': { 'age': 1, 'active': true }
  29799. * };
  29800. *
  29801. * _.findLastKey(users, function(o) { return o.age < 40; });
  29802. * // => returns 'pebbles' assuming `_.findKey` returns 'barney'
  29803. *
  29804. * // The `_.matches` iteratee shorthand.
  29805. * _.findLastKey(users, { 'age': 36, 'active': true });
  29806. * // => 'barney'
  29807. *
  29808. * // The `_.matchesProperty` iteratee shorthand.
  29809. * _.findLastKey(users, ['active', false]);
  29810. * // => 'fred'
  29811. *
  29812. * // The `_.property` iteratee shorthand.
  29813. * _.findLastKey(users, 'active');
  29814. * // => 'pebbles'
  29815. */
  29816. function findLastKey(object, predicate) {
  29817. return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
  29818. }
  29819. /**
  29820. * Iterates over own and inherited enumerable string keyed properties of an
  29821. * object and invokes `iteratee` for each property. The iteratee is invoked
  29822. * with three arguments: (value, key, object). Iteratee functions may exit
  29823. * iteration early by explicitly returning `false`.
  29824. *
  29825. * @static
  29826. * @memberOf _
  29827. * @since 0.3.0
  29828. * @category Object
  29829. * @param {Object} object The object to iterate over.
  29830. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29831. * @returns {Object} Returns `object`.
  29832. * @see _.forInRight
  29833. * @example
  29834. *
  29835. * function Foo() {
  29836. * this.a = 1;
  29837. * this.b = 2;
  29838. * }
  29839. *
  29840. * Foo.prototype.c = 3;
  29841. *
  29842. * _.forIn(new Foo, function(value, key) {
  29843. * console.log(key);
  29844. * });
  29845. * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
  29846. */
  29847. function forIn(object, iteratee) {
  29848. return object == null
  29849. ? object
  29850. : baseFor(object, getIteratee(iteratee, 3), keysIn);
  29851. }
  29852. /**
  29853. * This method is like `_.forIn` except that it iterates over properties of
  29854. * `object` in the opposite order.
  29855. *
  29856. * @static
  29857. * @memberOf _
  29858. * @since 2.0.0
  29859. * @category Object
  29860. * @param {Object} object The object to iterate over.
  29861. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29862. * @returns {Object} Returns `object`.
  29863. * @see _.forIn
  29864. * @example
  29865. *
  29866. * function Foo() {
  29867. * this.a = 1;
  29868. * this.b = 2;
  29869. * }
  29870. *
  29871. * Foo.prototype.c = 3;
  29872. *
  29873. * _.forInRight(new Foo, function(value, key) {
  29874. * console.log(key);
  29875. * });
  29876. * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'.
  29877. */
  29878. function forInRight(object, iteratee) {
  29879. return object == null
  29880. ? object
  29881. : baseForRight(object, getIteratee(iteratee, 3), keysIn);
  29882. }
  29883. /**
  29884. * Iterates over own enumerable string keyed properties of an object and
  29885. * invokes `iteratee` for each property. The iteratee is invoked with three
  29886. * arguments: (value, key, object). Iteratee functions may exit iteration
  29887. * early by explicitly returning `false`.
  29888. *
  29889. * @static
  29890. * @memberOf _
  29891. * @since 0.3.0
  29892. * @category Object
  29893. * @param {Object} object The object to iterate over.
  29894. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29895. * @returns {Object} Returns `object`.
  29896. * @see _.forOwnRight
  29897. * @example
  29898. *
  29899. * function Foo() {
  29900. * this.a = 1;
  29901. * this.b = 2;
  29902. * }
  29903. *
  29904. * Foo.prototype.c = 3;
  29905. *
  29906. * _.forOwn(new Foo, function(value, key) {
  29907. * console.log(key);
  29908. * });
  29909. * // => Logs 'a' then 'b' (iteration order is not guaranteed).
  29910. */
  29911. function forOwn(object, iteratee) {
  29912. return object && baseForOwn(object, getIteratee(iteratee, 3));
  29913. }
  29914. /**
  29915. * This method is like `_.forOwn` except that it iterates over properties of
  29916. * `object` in the opposite order.
  29917. *
  29918. * @static
  29919. * @memberOf _
  29920. * @since 2.0.0
  29921. * @category Object
  29922. * @param {Object} object The object to iterate over.
  29923. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  29924. * @returns {Object} Returns `object`.
  29925. * @see _.forOwn
  29926. * @example
  29927. *
  29928. * function Foo() {
  29929. * this.a = 1;
  29930. * this.b = 2;
  29931. * }
  29932. *
  29933. * Foo.prototype.c = 3;
  29934. *
  29935. * _.forOwnRight(new Foo, function(value, key) {
  29936. * console.log(key);
  29937. * });
  29938. * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'.
  29939. */
  29940. function forOwnRight(object, iteratee) {
  29941. return object && baseForOwnRight(object, getIteratee(iteratee, 3));
  29942. }
  29943. /**
  29944. * Creates an array of function property names from own enumerable properties
  29945. * of `object`.
  29946. *
  29947. * @static
  29948. * @since 0.1.0
  29949. * @memberOf _
  29950. * @category Object
  29951. * @param {Object} object The object to inspect.
  29952. * @returns {Array} Returns the function names.
  29953. * @see _.functionsIn
  29954. * @example
  29955. *
  29956. * function Foo() {
  29957. * this.a = _.constant('a');
  29958. * this.b = _.constant('b');
  29959. * }
  29960. *
  29961. * Foo.prototype.c = _.constant('c');
  29962. *
  29963. * _.functions(new Foo);
  29964. * // => ['a', 'b']
  29965. */
  29966. function functions(object) {
  29967. return object == null ? [] : baseFunctions(object, keys(object));
  29968. }
  29969. /**
  29970. * Creates an array of function property names from own and inherited
  29971. * enumerable properties of `object`.
  29972. *
  29973. * @static
  29974. * @memberOf _
  29975. * @since 4.0.0
  29976. * @category Object
  29977. * @param {Object} object The object to inspect.
  29978. * @returns {Array} Returns the function names.
  29979. * @see _.functions
  29980. * @example
  29981. *
  29982. * function Foo() {
  29983. * this.a = _.constant('a');
  29984. * this.b = _.constant('b');
  29985. * }
  29986. *
  29987. * Foo.prototype.c = _.constant('c');
  29988. *
  29989. * _.functionsIn(new Foo);
  29990. * // => ['a', 'b', 'c']
  29991. */
  29992. function functionsIn(object) {
  29993. return object == null ? [] : baseFunctions(object, keysIn(object));
  29994. }
  29995. /**
  29996. * Gets the value at `path` of `object`. If the resolved value is
  29997. * `undefined`, the `defaultValue` is returned in its place.
  29998. *
  29999. * @static
  30000. * @memberOf _
  30001. * @since 3.7.0
  30002. * @category Object
  30003. * @param {Object} object The object to query.
  30004. * @param {Array|string} path The path of the property to get.
  30005. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  30006. * @returns {*} Returns the resolved value.
  30007. * @example
  30008. *
  30009. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30010. *
  30011. * _.get(object, 'a[0].b.c');
  30012. * // => 3
  30013. *
  30014. * _.get(object, ['a', '0', 'b', 'c']);
  30015. * // => 3
  30016. *
  30017. * _.get(object, 'a.b.c', 'default');
  30018. * // => 'default'
  30019. */
  30020. function get(object, path, defaultValue) {
  30021. var result = object == null ? undefined : baseGet(object, path);
  30022. return result === undefined ? defaultValue : result;
  30023. }
  30024. /**
  30025. * Checks if `path` is a direct property of `object`.
  30026. *
  30027. * @static
  30028. * @since 0.1.0
  30029. * @memberOf _
  30030. * @category Object
  30031. * @param {Object} object The object to query.
  30032. * @param {Array|string} path The path to check.
  30033. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  30034. * @example
  30035. *
  30036. * var object = { 'a': { 'b': 2 } };
  30037. * var other = _.create({ 'a': _.create({ 'b': 2 }) });
  30038. *
  30039. * _.has(object, 'a');
  30040. * // => true
  30041. *
  30042. * _.has(object, 'a.b');
  30043. * // => true
  30044. *
  30045. * _.has(object, ['a', 'b']);
  30046. * // => true
  30047. *
  30048. * _.has(other, 'a');
  30049. * // => false
  30050. */
  30051. function has(object, path) {
  30052. return object != null && hasPath(object, path, baseHas);
  30053. }
  30054. /**
  30055. * Checks if `path` is a direct or inherited property of `object`.
  30056. *
  30057. * @static
  30058. * @memberOf _
  30059. * @since 4.0.0
  30060. * @category Object
  30061. * @param {Object} object The object to query.
  30062. * @param {Array|string} path The path to check.
  30063. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  30064. * @example
  30065. *
  30066. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  30067. *
  30068. * _.hasIn(object, 'a');
  30069. * // => true
  30070. *
  30071. * _.hasIn(object, 'a.b');
  30072. * // => true
  30073. *
  30074. * _.hasIn(object, ['a', 'b']);
  30075. * // => true
  30076. *
  30077. * _.hasIn(object, 'b');
  30078. * // => false
  30079. */
  30080. function hasIn(object, path) {
  30081. return object != null && hasPath(object, path, baseHasIn);
  30082. }
  30083. /**
  30084. * Creates an object composed of the inverted keys and values of `object`.
  30085. * If `object` contains duplicate values, subsequent values overwrite
  30086. * property assignments of previous values.
  30087. *
  30088. * @static
  30089. * @memberOf _
  30090. * @since 0.7.0
  30091. * @category Object
  30092. * @param {Object} object The object to invert.
  30093. * @returns {Object} Returns the new inverted object.
  30094. * @example
  30095. *
  30096. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  30097. *
  30098. * _.invert(object);
  30099. * // => { '1': 'c', '2': 'b' }
  30100. */
  30101. var invert = createInverter(function(result, value, key) {
  30102. if (value != null &&
  30103. typeof value.toString != 'function') {
  30104. value = nativeObjectToString.call(value);
  30105. }
  30106. result[value] = key;
  30107. }, constant(identity));
  30108. /**
  30109. * This method is like `_.invert` except that the inverted object is generated
  30110. * from the results of running each element of `object` thru `iteratee`. The
  30111. * corresponding inverted value of each inverted key is an array of keys
  30112. * responsible for generating the inverted value. The iteratee is invoked
  30113. * with one argument: (value).
  30114. *
  30115. * @static
  30116. * @memberOf _
  30117. * @since 4.1.0
  30118. * @category Object
  30119. * @param {Object} object The object to invert.
  30120. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  30121. * @returns {Object} Returns the new inverted object.
  30122. * @example
  30123. *
  30124. * var object = { 'a': 1, 'b': 2, 'c': 1 };
  30125. *
  30126. * _.invertBy(object);
  30127. * // => { '1': ['a', 'c'], '2': ['b'] }
  30128. *
  30129. * _.invertBy(object, function(value) {
  30130. * return 'group' + value;
  30131. * });
  30132. * // => { 'group1': ['a', 'c'], 'group2': ['b'] }
  30133. */
  30134. var invertBy = createInverter(function(result, value, key) {
  30135. if (value != null &&
  30136. typeof value.toString != 'function') {
  30137. value = nativeObjectToString.call(value);
  30138. }
  30139. if (hasOwnProperty.call(result, value)) {
  30140. result[value].push(key);
  30141. } else {
  30142. result[value] = [key];
  30143. }
  30144. }, getIteratee);
  30145. /**
  30146. * Invokes the method at `path` of `object`.
  30147. *
  30148. * @static
  30149. * @memberOf _
  30150. * @since 4.0.0
  30151. * @category Object
  30152. * @param {Object} object The object to query.
  30153. * @param {Array|string} path The path of the method to invoke.
  30154. * @param {...*} [args] The arguments to invoke the method with.
  30155. * @returns {*} Returns the result of the invoked method.
  30156. * @example
  30157. *
  30158. * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] };
  30159. *
  30160. * _.invoke(object, 'a[0].b.c.slice', 1, 3);
  30161. * // => [2, 3]
  30162. */
  30163. var invoke = baseRest(baseInvoke);
  30164. /**
  30165. * Creates an array of the own enumerable property names of `object`.
  30166. *
  30167. * **Note:** Non-object values are coerced to objects. See the
  30168. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  30169. * for more details.
  30170. *
  30171. * @static
  30172. * @since 0.1.0
  30173. * @memberOf _
  30174. * @category Object
  30175. * @param {Object} object The object to query.
  30176. * @returns {Array} Returns the array of property names.
  30177. * @example
  30178. *
  30179. * function Foo() {
  30180. * this.a = 1;
  30181. * this.b = 2;
  30182. * }
  30183. *
  30184. * Foo.prototype.c = 3;
  30185. *
  30186. * _.keys(new Foo);
  30187. * // => ['a', 'b'] (iteration order is not guaranteed)
  30188. *
  30189. * _.keys('hi');
  30190. * // => ['0', '1']
  30191. */
  30192. function keys(object) {
  30193. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  30194. }
  30195. /**
  30196. * Creates an array of the own and inherited enumerable property names of `object`.
  30197. *
  30198. * **Note:** Non-object values are coerced to objects.
  30199. *
  30200. * @static
  30201. * @memberOf _
  30202. * @since 3.0.0
  30203. * @category Object
  30204. * @param {Object} object The object to query.
  30205. * @returns {Array} Returns the array of property names.
  30206. * @example
  30207. *
  30208. * function Foo() {
  30209. * this.a = 1;
  30210. * this.b = 2;
  30211. * }
  30212. *
  30213. * Foo.prototype.c = 3;
  30214. *
  30215. * _.keysIn(new Foo);
  30216. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  30217. */
  30218. function keysIn(object) {
  30219. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  30220. }
  30221. /**
  30222. * The opposite of `_.mapValues`; this method creates an object with the
  30223. * same values as `object` and keys generated by running each own enumerable
  30224. * string keyed property of `object` thru `iteratee`. The iteratee is invoked
  30225. * with three arguments: (value, key, object).
  30226. *
  30227. * @static
  30228. * @memberOf _
  30229. * @since 3.8.0
  30230. * @category Object
  30231. * @param {Object} object The object to iterate over.
  30232. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30233. * @returns {Object} Returns the new mapped object.
  30234. * @see _.mapValues
  30235. * @example
  30236. *
  30237. * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) {
  30238. * return key + value;
  30239. * });
  30240. * // => { 'a1': 1, 'b2': 2 }
  30241. */
  30242. function mapKeys(object, iteratee) {
  30243. var result = {};
  30244. iteratee = getIteratee(iteratee, 3);
  30245. baseForOwn(object, function(value, key, object) {
  30246. baseAssignValue(result, iteratee(value, key, object), value);
  30247. });
  30248. return result;
  30249. }
  30250. /**
  30251. * Creates an object with the same keys as `object` and values generated
  30252. * by running each own enumerable string keyed property of `object` thru
  30253. * `iteratee`. The iteratee is invoked with three arguments:
  30254. * (value, key, object).
  30255. *
  30256. * @static
  30257. * @memberOf _
  30258. * @since 2.4.0
  30259. * @category Object
  30260. * @param {Object} object The object to iterate over.
  30261. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30262. * @returns {Object} Returns the new mapped object.
  30263. * @see _.mapKeys
  30264. * @example
  30265. *
  30266. * var users = {
  30267. * 'fred': { 'user': 'fred', 'age': 40 },
  30268. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  30269. * };
  30270. *
  30271. * _.mapValues(users, function(o) { return o.age; });
  30272. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  30273. *
  30274. * // The `_.property` iteratee shorthand.
  30275. * _.mapValues(users, 'age');
  30276. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  30277. */
  30278. function mapValues(object, iteratee) {
  30279. var result = {};
  30280. iteratee = getIteratee(iteratee, 3);
  30281. baseForOwn(object, function(value, key, object) {
  30282. baseAssignValue(result, key, iteratee(value, key, object));
  30283. });
  30284. return result;
  30285. }
  30286. /**
  30287. * This method is like `_.assign` except that it recursively merges own and
  30288. * inherited enumerable string keyed properties of source objects into the
  30289. * destination object. Source properties that resolve to `undefined` are
  30290. * skipped if a destination value exists. Array and plain object properties
  30291. * are merged recursively. Other objects and value types are overridden by
  30292. * assignment. Source objects are applied from left to right. Subsequent
  30293. * sources overwrite property assignments of previous sources.
  30294. *
  30295. * **Note:** This method mutates `object`.
  30296. *
  30297. * @static
  30298. * @memberOf _
  30299. * @since 0.5.0
  30300. * @category Object
  30301. * @param {Object} object The destination object.
  30302. * @param {...Object} [sources] The source objects.
  30303. * @returns {Object} Returns `object`.
  30304. * @example
  30305. *
  30306. * var object = {
  30307. * 'a': [{ 'b': 2 }, { 'd': 4 }]
  30308. * };
  30309. *
  30310. * var other = {
  30311. * 'a': [{ 'c': 3 }, { 'e': 5 }]
  30312. * };
  30313. *
  30314. * _.merge(object, other);
  30315. * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
  30316. */
  30317. var merge = createAssigner(function(object, source, srcIndex) {
  30318. baseMerge(object, source, srcIndex);
  30319. });
  30320. /**
  30321. * This method is like `_.merge` except that it accepts `customizer` which
  30322. * is invoked to produce the merged values of the destination and source
  30323. * properties. If `customizer` returns `undefined`, merging is handled by the
  30324. * method instead. The `customizer` is invoked with six arguments:
  30325. * (objValue, srcValue, key, object, source, stack).
  30326. *
  30327. * **Note:** This method mutates `object`.
  30328. *
  30329. * @static
  30330. * @memberOf _
  30331. * @since 4.0.0
  30332. * @category Object
  30333. * @param {Object} object The destination object.
  30334. * @param {...Object} sources The source objects.
  30335. * @param {Function} customizer The function to customize assigned values.
  30336. * @returns {Object} Returns `object`.
  30337. * @example
  30338. *
  30339. * function customizer(objValue, srcValue) {
  30340. * if (_.isArray(objValue)) {
  30341. * return objValue.concat(srcValue);
  30342. * }
  30343. * }
  30344. *
  30345. * var object = { 'a': [1], 'b': [2] };
  30346. * var other = { 'a': [3], 'b': [4] };
  30347. *
  30348. * _.mergeWith(object, other, customizer);
  30349. * // => { 'a': [1, 3], 'b': [2, 4] }
  30350. */
  30351. var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
  30352. baseMerge(object, source, srcIndex, customizer);
  30353. });
  30354. /**
  30355. * The opposite of `_.pick`; this method creates an object composed of the
  30356. * own and inherited enumerable property paths of `object` that are not omitted.
  30357. *
  30358. * **Note:** This method is considerably slower than `_.pick`.
  30359. *
  30360. * @static
  30361. * @since 0.1.0
  30362. * @memberOf _
  30363. * @category Object
  30364. * @param {Object} object The source object.
  30365. * @param {...(string|string[])} [paths] The property paths to omit.
  30366. * @returns {Object} Returns the new object.
  30367. * @example
  30368. *
  30369. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30370. *
  30371. * _.omit(object, ['a', 'c']);
  30372. * // => { 'b': '2' }
  30373. */
  30374. var omit = flatRest(function(object, paths) {
  30375. var result = {};
  30376. if (object == null) {
  30377. return result;
  30378. }
  30379. var isDeep = false;
  30380. paths = arrayMap(paths, function(path) {
  30381. path = castPath(path, object);
  30382. isDeep || (isDeep = path.length > 1);
  30383. return path;
  30384. });
  30385. copyObject(object, getAllKeysIn(object), result);
  30386. if (isDeep) {
  30387. result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
  30388. }
  30389. var length = paths.length;
  30390. while (length--) {
  30391. baseUnset(result, paths[length]);
  30392. }
  30393. return result;
  30394. });
  30395. /**
  30396. * The opposite of `_.pickBy`; this method creates an object composed of
  30397. * the own and inherited enumerable string keyed properties of `object` that
  30398. * `predicate` doesn't return truthy for. The predicate is invoked with two
  30399. * arguments: (value, key).
  30400. *
  30401. * @static
  30402. * @memberOf _
  30403. * @since 4.0.0
  30404. * @category Object
  30405. * @param {Object} object The source object.
  30406. * @param {Function} [predicate=_.identity] The function invoked per property.
  30407. * @returns {Object} Returns the new object.
  30408. * @example
  30409. *
  30410. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30411. *
  30412. * _.omitBy(object, _.isNumber);
  30413. * // => { 'b': '2' }
  30414. */
  30415. function omitBy(object, predicate) {
  30416. return pickBy(object, negate(getIteratee(predicate)));
  30417. }
  30418. /**
  30419. * Creates an object composed of the picked `object` properties.
  30420. *
  30421. * @static
  30422. * @since 0.1.0
  30423. * @memberOf _
  30424. * @category Object
  30425. * @param {Object} object The source object.
  30426. * @param {...(string|string[])} [paths] The property paths to pick.
  30427. * @returns {Object} Returns the new object.
  30428. * @example
  30429. *
  30430. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30431. *
  30432. * _.pick(object, ['a', 'c']);
  30433. * // => { 'a': 1, 'c': 3 }
  30434. */
  30435. var pick = flatRest(function(object, paths) {
  30436. return object == null ? {} : basePick(object, paths);
  30437. });
  30438. /**
  30439. * Creates an object composed of the `object` properties `predicate` returns
  30440. * truthy for. The predicate is invoked with two arguments: (value, key).
  30441. *
  30442. * @static
  30443. * @memberOf _
  30444. * @since 4.0.0
  30445. * @category Object
  30446. * @param {Object} object The source object.
  30447. * @param {Function} [predicate=_.identity] The function invoked per property.
  30448. * @returns {Object} Returns the new object.
  30449. * @example
  30450. *
  30451. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  30452. *
  30453. * _.pickBy(object, _.isNumber);
  30454. * // => { 'a': 1, 'c': 3 }
  30455. */
  30456. function pickBy(object, predicate) {
  30457. if (object == null) {
  30458. return {};
  30459. }
  30460. var props = arrayMap(getAllKeysIn(object), function(prop) {
  30461. return [prop];
  30462. });
  30463. predicate = getIteratee(predicate);
  30464. return basePickBy(object, props, function(value, path) {
  30465. return predicate(value, path[0]);
  30466. });
  30467. }
  30468. /**
  30469. * This method is like `_.get` except that if the resolved value is a
  30470. * function it's invoked with the `this` binding of its parent object and
  30471. * its result is returned.
  30472. *
  30473. * @static
  30474. * @since 0.1.0
  30475. * @memberOf _
  30476. * @category Object
  30477. * @param {Object} object The object to query.
  30478. * @param {Array|string} path The path of the property to resolve.
  30479. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  30480. * @returns {*} Returns the resolved value.
  30481. * @example
  30482. *
  30483. * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] };
  30484. *
  30485. * _.result(object, 'a[0].b.c1');
  30486. * // => 3
  30487. *
  30488. * _.result(object, 'a[0].b.c2');
  30489. * // => 4
  30490. *
  30491. * _.result(object, 'a[0].b.c3', 'default');
  30492. * // => 'default'
  30493. *
  30494. * _.result(object, 'a[0].b.c3', _.constant('default'));
  30495. * // => 'default'
  30496. */
  30497. function result(object, path, defaultValue) {
  30498. path = castPath(path, object);
  30499. var index = -1,
  30500. length = path.length;
  30501. // Ensure the loop is entered when path is empty.
  30502. if (!length) {
  30503. length = 1;
  30504. object = undefined;
  30505. }
  30506. while (++index < length) {
  30507. var value = object == null ? undefined : object[toKey(path[index])];
  30508. if (value === undefined) {
  30509. index = length;
  30510. value = defaultValue;
  30511. }
  30512. object = isFunction(value) ? value.call(object) : value;
  30513. }
  30514. return object;
  30515. }
  30516. /**
  30517. * Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
  30518. * it's created. Arrays are created for missing index properties while objects
  30519. * are created for all other missing properties. Use `_.setWith` to customize
  30520. * `path` creation.
  30521. *
  30522. * **Note:** This method mutates `object`.
  30523. *
  30524. * @static
  30525. * @memberOf _
  30526. * @since 3.7.0
  30527. * @category Object
  30528. * @param {Object} object The object to modify.
  30529. * @param {Array|string} path The path of the property to set.
  30530. * @param {*} value The value to set.
  30531. * @returns {Object} Returns `object`.
  30532. * @example
  30533. *
  30534. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30535. *
  30536. * _.set(object, 'a[0].b.c', 4);
  30537. * console.log(object.a[0].b.c);
  30538. * // => 4
  30539. *
  30540. * _.set(object, ['x', '0', 'y', 'z'], 5);
  30541. * console.log(object.x[0].y.z);
  30542. * // => 5
  30543. */
  30544. function set(object, path, value) {
  30545. return object == null ? object : baseSet(object, path, value);
  30546. }
  30547. /**
  30548. * This method is like `_.set` except that it accepts `customizer` which is
  30549. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  30550. * path creation is handled by the method instead. The `customizer` is invoked
  30551. * with three arguments: (nsValue, key, nsObject).
  30552. *
  30553. * **Note:** This method mutates `object`.
  30554. *
  30555. * @static
  30556. * @memberOf _
  30557. * @since 4.0.0
  30558. * @category Object
  30559. * @param {Object} object The object to modify.
  30560. * @param {Array|string} path The path of the property to set.
  30561. * @param {*} value The value to set.
  30562. * @param {Function} [customizer] The function to customize assigned values.
  30563. * @returns {Object} Returns `object`.
  30564. * @example
  30565. *
  30566. * var object = {};
  30567. *
  30568. * _.setWith(object, '[0][1]', 'a', Object);
  30569. * // => { '0': { '1': 'a' } }
  30570. */
  30571. function setWith(object, path, value, customizer) {
  30572. customizer = typeof customizer == 'function' ? customizer : undefined;
  30573. return object == null ? object : baseSet(object, path, value, customizer);
  30574. }
  30575. /**
  30576. * Creates an array of own enumerable string keyed-value pairs for `object`
  30577. * which can be consumed by `_.fromPairs`. If `object` is a map or set, its
  30578. * entries are returned.
  30579. *
  30580. * @static
  30581. * @memberOf _
  30582. * @since 4.0.0
  30583. * @alias entries
  30584. * @category Object
  30585. * @param {Object} object The object to query.
  30586. * @returns {Array} Returns the key-value pairs.
  30587. * @example
  30588. *
  30589. * function Foo() {
  30590. * this.a = 1;
  30591. * this.b = 2;
  30592. * }
  30593. *
  30594. * Foo.prototype.c = 3;
  30595. *
  30596. * _.toPairs(new Foo);
  30597. * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed)
  30598. */
  30599. var toPairs = createToPairs(keys);
  30600. /**
  30601. * Creates an array of own and inherited enumerable string keyed-value pairs
  30602. * for `object` which can be consumed by `_.fromPairs`. If `object` is a map
  30603. * or set, its entries are returned.
  30604. *
  30605. * @static
  30606. * @memberOf _
  30607. * @since 4.0.0
  30608. * @alias entriesIn
  30609. * @category Object
  30610. * @param {Object} object The object to query.
  30611. * @returns {Array} Returns the key-value pairs.
  30612. * @example
  30613. *
  30614. * function Foo() {
  30615. * this.a = 1;
  30616. * this.b = 2;
  30617. * }
  30618. *
  30619. * Foo.prototype.c = 3;
  30620. *
  30621. * _.toPairsIn(new Foo);
  30622. * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed)
  30623. */
  30624. var toPairsIn = createToPairs(keysIn);
  30625. /**
  30626. * An alternative to `_.reduce`; this method transforms `object` to a new
  30627. * `accumulator` object which is the result of running each of its own
  30628. * enumerable string keyed properties thru `iteratee`, with each invocation
  30629. * potentially mutating the `accumulator` object. If `accumulator` is not
  30630. * provided, a new object with the same `[[Prototype]]` will be used. The
  30631. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  30632. * Iteratee functions may exit iteration early by explicitly returning `false`.
  30633. *
  30634. * @static
  30635. * @memberOf _
  30636. * @since 1.3.0
  30637. * @category Object
  30638. * @param {Object} object The object to iterate over.
  30639. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  30640. * @param {*} [accumulator] The custom accumulator value.
  30641. * @returns {*} Returns the accumulated value.
  30642. * @example
  30643. *
  30644. * _.transform([2, 3, 4], function(result, n) {
  30645. * result.push(n *= n);
  30646. * return n % 2 == 0;
  30647. * }, []);
  30648. * // => [4, 9]
  30649. *
  30650. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  30651. * (result[value] || (result[value] = [])).push(key);
  30652. * }, {});
  30653. * // => { '1': ['a', 'c'], '2': ['b'] }
  30654. */
  30655. function transform(object, iteratee, accumulator) {
  30656. var isArr = isArray(object),
  30657. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  30658. iteratee = getIteratee(iteratee, 4);
  30659. if (accumulator == null) {
  30660. var Ctor = object && object.constructor;
  30661. if (isArrLike) {
  30662. accumulator = isArr ? new Ctor : [];
  30663. }
  30664. else if (isObject(object)) {
  30665. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  30666. }
  30667. else {
  30668. accumulator = {};
  30669. }
  30670. }
  30671. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  30672. return iteratee(accumulator, value, index, object);
  30673. });
  30674. return accumulator;
  30675. }
  30676. /**
  30677. * Removes the property at `path` of `object`.
  30678. *
  30679. * **Note:** This method mutates `object`.
  30680. *
  30681. * @static
  30682. * @memberOf _
  30683. * @since 4.0.0
  30684. * @category Object
  30685. * @param {Object} object The object to modify.
  30686. * @param {Array|string} path The path of the property to unset.
  30687. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  30688. * @example
  30689. *
  30690. * var object = { 'a': [{ 'b': { 'c': 7 } }] };
  30691. * _.unset(object, 'a[0].b.c');
  30692. * // => true
  30693. *
  30694. * console.log(object);
  30695. * // => { 'a': [{ 'b': {} }] };
  30696. *
  30697. * _.unset(object, ['a', '0', 'b', 'c']);
  30698. * // => true
  30699. *
  30700. * console.log(object);
  30701. * // => { 'a': [{ 'b': {} }] };
  30702. */
  30703. function unset(object, path) {
  30704. return object == null ? true : baseUnset(object, path);
  30705. }
  30706. /**
  30707. * This method is like `_.set` except that accepts `updater` to produce the
  30708. * value to set. Use `_.updateWith` to customize `path` creation. The `updater`
  30709. * is invoked with one argument: (value).
  30710. *
  30711. * **Note:** This method mutates `object`.
  30712. *
  30713. * @static
  30714. * @memberOf _
  30715. * @since 4.6.0
  30716. * @category Object
  30717. * @param {Object} object The object to modify.
  30718. * @param {Array|string} path The path of the property to set.
  30719. * @param {Function} updater The function to produce the updated value.
  30720. * @returns {Object} Returns `object`.
  30721. * @example
  30722. *
  30723. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  30724. *
  30725. * _.update(object, 'a[0].b.c', function(n) { return n * n; });
  30726. * console.log(object.a[0].b.c);
  30727. * // => 9
  30728. *
  30729. * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; });
  30730. * console.log(object.x[0].y.z);
  30731. * // => 0
  30732. */
  30733. function update(object, path, updater) {
  30734. return object == null ? object : baseUpdate(object, path, castFunction(updater));
  30735. }
  30736. /**
  30737. * This method is like `_.update` except that it accepts `customizer` which is
  30738. * invoked to produce the objects of `path`. If `customizer` returns `undefined`
  30739. * path creation is handled by the method instead. The `customizer` is invoked
  30740. * with three arguments: (nsValue, key, nsObject).
  30741. *
  30742. * **Note:** This method mutates `object`.
  30743. *
  30744. * @static
  30745. * @memberOf _
  30746. * @since 4.6.0
  30747. * @category Object
  30748. * @param {Object} object The object to modify.
  30749. * @param {Array|string} path The path of the property to set.
  30750. * @param {Function} updater The function to produce the updated value.
  30751. * @param {Function} [customizer] The function to customize assigned values.
  30752. * @returns {Object} Returns `object`.
  30753. * @example
  30754. *
  30755. * var object = {};
  30756. *
  30757. * _.updateWith(object, '[0][1]', _.constant('a'), Object);
  30758. * // => { '0': { '1': 'a' } }
  30759. */
  30760. function updateWith(object, path, updater, customizer) {
  30761. customizer = typeof customizer == 'function' ? customizer : undefined;
  30762. return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
  30763. }
  30764. /**
  30765. * Creates an array of the own enumerable string keyed property values of `object`.
  30766. *
  30767. * **Note:** Non-object values are coerced to objects.
  30768. *
  30769. * @static
  30770. * @since 0.1.0
  30771. * @memberOf _
  30772. * @category Object
  30773. * @param {Object} object The object to query.
  30774. * @returns {Array} Returns the array of property values.
  30775. * @example
  30776. *
  30777. * function Foo() {
  30778. * this.a = 1;
  30779. * this.b = 2;
  30780. * }
  30781. *
  30782. * Foo.prototype.c = 3;
  30783. *
  30784. * _.values(new Foo);
  30785. * // => [1, 2] (iteration order is not guaranteed)
  30786. *
  30787. * _.values('hi');
  30788. * // => ['h', 'i']
  30789. */
  30790. function values(object) {
  30791. return object == null ? [] : baseValues(object, keys(object));
  30792. }
  30793. /**
  30794. * Creates an array of the own and inherited enumerable string keyed property
  30795. * values of `object`.
  30796. *
  30797. * **Note:** Non-object values are coerced to objects.
  30798. *
  30799. * @static
  30800. * @memberOf _
  30801. * @since 3.0.0
  30802. * @category Object
  30803. * @param {Object} object The object to query.
  30804. * @returns {Array} Returns the array of property values.
  30805. * @example
  30806. *
  30807. * function Foo() {
  30808. * this.a = 1;
  30809. * this.b = 2;
  30810. * }
  30811. *
  30812. * Foo.prototype.c = 3;
  30813. *
  30814. * _.valuesIn(new Foo);
  30815. * // => [1, 2, 3] (iteration order is not guaranteed)
  30816. */
  30817. function valuesIn(object) {
  30818. return object == null ? [] : baseValues(object, keysIn(object));
  30819. }
  30820. /*------------------------------------------------------------------------*/
  30821. /**
  30822. * Clamps `number` within the inclusive `lower` and `upper` bounds.
  30823. *
  30824. * @static
  30825. * @memberOf _
  30826. * @since 4.0.0
  30827. * @category Number
  30828. * @param {number} number The number to clamp.
  30829. * @param {number} [lower] The lower bound.
  30830. * @param {number} upper The upper bound.
  30831. * @returns {number} Returns the clamped number.
  30832. * @example
  30833. *
  30834. * _.clamp(-10, -5, 5);
  30835. * // => -5
  30836. *
  30837. * _.clamp(10, -5, 5);
  30838. * // => 5
  30839. */
  30840. function clamp(number, lower, upper) {
  30841. if (upper === undefined) {
  30842. upper = lower;
  30843. lower = undefined;
  30844. }
  30845. if (upper !== undefined) {
  30846. upper = toNumber(upper);
  30847. upper = upper === upper ? upper : 0;
  30848. }
  30849. if (lower !== undefined) {
  30850. lower = toNumber(lower);
  30851. lower = lower === lower ? lower : 0;
  30852. }
  30853. return baseClamp(toNumber(number), lower, upper);
  30854. }
  30855. /**
  30856. * Checks if `n` is between `start` and up to, but not including, `end`. If
  30857. * `end` is not specified, it's set to `start` with `start` then set to `0`.
  30858. * If `start` is greater than `end` the params are swapped to support
  30859. * negative ranges.
  30860. *
  30861. * @static
  30862. * @memberOf _
  30863. * @since 3.3.0
  30864. * @category Number
  30865. * @param {number} number The number to check.
  30866. * @param {number} [start=0] The start of the range.
  30867. * @param {number} end The end of the range.
  30868. * @returns {boolean} Returns `true` if `number` is in the range, else `false`.
  30869. * @see _.range, _.rangeRight
  30870. * @example
  30871. *
  30872. * _.inRange(3, 2, 4);
  30873. * // => true
  30874. *
  30875. * _.inRange(4, 8);
  30876. * // => true
  30877. *
  30878. * _.inRange(4, 2);
  30879. * // => false
  30880. *
  30881. * _.inRange(2, 2);
  30882. * // => false
  30883. *
  30884. * _.inRange(1.2, 2);
  30885. * // => true
  30886. *
  30887. * _.inRange(5.2, 4);
  30888. * // => false
  30889. *
  30890. * _.inRange(-3, -2, -6);
  30891. * // => true
  30892. */
  30893. function inRange(number, start, end) {
  30894. start = toFinite(start);
  30895. if (end === undefined) {
  30896. end = start;
  30897. start = 0;
  30898. } else {
  30899. end = toFinite(end);
  30900. }
  30901. number = toNumber(number);
  30902. return baseInRange(number, start, end);
  30903. }
  30904. /**
  30905. * Produces a random number between the inclusive `lower` and `upper` bounds.
  30906. * If only one argument is provided a number between `0` and the given number
  30907. * is returned. If `floating` is `true`, or either `lower` or `upper` are
  30908. * floats, a floating-point number is returned instead of an integer.
  30909. *
  30910. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  30911. * floating-point values which can produce unexpected results.
  30912. *
  30913. * @static
  30914. * @memberOf _
  30915. * @since 0.7.0
  30916. * @category Number
  30917. * @param {number} [lower=0] The lower bound.
  30918. * @param {number} [upper=1] The upper bound.
  30919. * @param {boolean} [floating] Specify returning a floating-point number.
  30920. * @returns {number} Returns the random number.
  30921. * @example
  30922. *
  30923. * _.random(0, 5);
  30924. * // => an integer between 0 and 5
  30925. *
  30926. * _.random(5);
  30927. * // => also an integer between 0 and 5
  30928. *
  30929. * _.random(5, true);
  30930. * // => a floating-point number between 0 and 5
  30931. *
  30932. * _.random(1.2, 5.2);
  30933. * // => a floating-point number between 1.2 and 5.2
  30934. */
  30935. function random(lower, upper, floating) {
  30936. if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) {
  30937. upper = floating = undefined;
  30938. }
  30939. if (floating === undefined) {
  30940. if (typeof upper == 'boolean') {
  30941. floating = upper;
  30942. upper = undefined;
  30943. }
  30944. else if (typeof lower == 'boolean') {
  30945. floating = lower;
  30946. lower = undefined;
  30947. }
  30948. }
  30949. if (lower === undefined && upper === undefined) {
  30950. lower = 0;
  30951. upper = 1;
  30952. }
  30953. else {
  30954. lower = toFinite(lower);
  30955. if (upper === undefined) {
  30956. upper = lower;
  30957. lower = 0;
  30958. } else {
  30959. upper = toFinite(upper);
  30960. }
  30961. }
  30962. if (lower > upper) {
  30963. var temp = lower;
  30964. lower = upper;
  30965. upper = temp;
  30966. }
  30967. if (floating || lower % 1 || upper % 1) {
  30968. var rand = nativeRandom();
  30969. return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper);
  30970. }
  30971. return baseRandom(lower, upper);
  30972. }
  30973. /*------------------------------------------------------------------------*/
  30974. /**
  30975. * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase).
  30976. *
  30977. * @static
  30978. * @memberOf _
  30979. * @since 3.0.0
  30980. * @category String
  30981. * @param {string} [string=''] The string to convert.
  30982. * @returns {string} Returns the camel cased string.
  30983. * @example
  30984. *
  30985. * _.camelCase('Foo Bar');
  30986. * // => 'fooBar'
  30987. *
  30988. * _.camelCase('--foo-bar--');
  30989. * // => 'fooBar'
  30990. *
  30991. * _.camelCase('__FOO_BAR__');
  30992. * // => 'fooBar'
  30993. */
  30994. var camelCase = createCompounder(function(result, word, index) {
  30995. word = word.toLowerCase();
  30996. return result + (index ? capitalize(word) : word);
  30997. });
  30998. /**
  30999. * Converts the first character of `string` to upper case and the remaining
  31000. * to lower case.
  31001. *
  31002. * @static
  31003. * @memberOf _
  31004. * @since 3.0.0
  31005. * @category String
  31006. * @param {string} [string=''] The string to capitalize.
  31007. * @returns {string} Returns the capitalized string.
  31008. * @example
  31009. *
  31010. * _.capitalize('FRED');
  31011. * // => 'Fred'
  31012. */
  31013. function capitalize(string) {
  31014. return upperFirst(toString(string).toLowerCase());
  31015. }
  31016. /**
  31017. * Deburrs `string` by converting
  31018. * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
  31019. * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
  31020. * letters to basic Latin letters and removing
  31021. * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
  31022. *
  31023. * @static
  31024. * @memberOf _
  31025. * @since 3.0.0
  31026. * @category String
  31027. * @param {string} [string=''] The string to deburr.
  31028. * @returns {string} Returns the deburred string.
  31029. * @example
  31030. *
  31031. * _.deburr('déjà vu');
  31032. * // => 'deja vu'
  31033. */
  31034. function deburr(string) {
  31035. string = toString(string);
  31036. return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
  31037. }
  31038. /**
  31039. * Checks if `string` ends with the given target string.
  31040. *
  31041. * @static
  31042. * @memberOf _
  31043. * @since 3.0.0
  31044. * @category String
  31045. * @param {string} [string=''] The string to inspect.
  31046. * @param {string} [target] The string to search for.
  31047. * @param {number} [position=string.length] The position to search up to.
  31048. * @returns {boolean} Returns `true` if `string` ends with `target`,
  31049. * else `false`.
  31050. * @example
  31051. *
  31052. * _.endsWith('abc', 'c');
  31053. * // => true
  31054. *
  31055. * _.endsWith('abc', 'b');
  31056. * // => false
  31057. *
  31058. * _.endsWith('abc', 'b', 2);
  31059. * // => true
  31060. */
  31061. function endsWith(string, target, position) {
  31062. string = toString(string);
  31063. target = baseToString(target);
  31064. var length = string.length;
  31065. position = position === undefined
  31066. ? length
  31067. : baseClamp(toInteger(position), 0, length);
  31068. var end = position;
  31069. position -= target.length;
  31070. return position >= 0 && string.slice(position, end) == target;
  31071. }
  31072. /**
  31073. * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
  31074. * corresponding HTML entities.
  31075. *
  31076. * **Note:** No other characters are escaped. To escape additional
  31077. * characters use a third-party library like [_he_](https://mths.be/he).
  31078. *
  31079. * Though the ">" character is escaped for symmetry, characters like
  31080. * ">" and "/" don't need escaping in HTML and have no special meaning
  31081. * unless they're part of a tag or unquoted attribute value. See
  31082. * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
  31083. * (under "semi-related fun fact") for more details.
  31084. *
  31085. * When working with HTML you should always
  31086. * [quote attribute values](http://wonko.com/post/html-escaping) to reduce
  31087. * XSS vectors.
  31088. *
  31089. * @static
  31090. * @since 0.1.0
  31091. * @memberOf _
  31092. * @category String
  31093. * @param {string} [string=''] The string to escape.
  31094. * @returns {string} Returns the escaped string.
  31095. * @example
  31096. *
  31097. * _.escape('fred, barney, & pebbles');
  31098. * // => 'fred, barney, &amp; pebbles'
  31099. */
  31100. function escape(string) {
  31101. string = toString(string);
  31102. return (string && reHasUnescapedHtml.test(string))
  31103. ? string.replace(reUnescapedHtml, escapeHtmlChar)
  31104. : string;
  31105. }
  31106. /**
  31107. * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+",
  31108. * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`.
  31109. *
  31110. * @static
  31111. * @memberOf _
  31112. * @since 3.0.0
  31113. * @category String
  31114. * @param {string} [string=''] The string to escape.
  31115. * @returns {string} Returns the escaped string.
  31116. * @example
  31117. *
  31118. * _.escapeRegExp('[lodash](https://lodash.com/)');
  31119. * // => '\[lodash\]\(https://lodash\.com/\)'
  31120. */
  31121. function escapeRegExp(string) {
  31122. string = toString(string);
  31123. return (string && reHasRegExpChar.test(string))
  31124. ? string.replace(reRegExpChar, '\\$&')
  31125. : string;
  31126. }
  31127. /**
  31128. * Converts `string` to
  31129. * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles).
  31130. *
  31131. * @static
  31132. * @memberOf _
  31133. * @since 3.0.0
  31134. * @category String
  31135. * @param {string} [string=''] The string to convert.
  31136. * @returns {string} Returns the kebab cased string.
  31137. * @example
  31138. *
  31139. * _.kebabCase('Foo Bar');
  31140. * // => 'foo-bar'
  31141. *
  31142. * _.kebabCase('fooBar');
  31143. * // => 'foo-bar'
  31144. *
  31145. * _.kebabCase('__FOO_BAR__');
  31146. * // => 'foo-bar'
  31147. */
  31148. var kebabCase = createCompounder(function(result, word, index) {
  31149. return result + (index ? '-' : '') + word.toLowerCase();
  31150. });
  31151. /**
  31152. * Converts `string`, as space separated words, to lower case.
  31153. *
  31154. * @static
  31155. * @memberOf _
  31156. * @since 4.0.0
  31157. * @category String
  31158. * @param {string} [string=''] The string to convert.
  31159. * @returns {string} Returns the lower cased string.
  31160. * @example
  31161. *
  31162. * _.lowerCase('--Foo-Bar--');
  31163. * // => 'foo bar'
  31164. *
  31165. * _.lowerCase('fooBar');
  31166. * // => 'foo bar'
  31167. *
  31168. * _.lowerCase('__FOO_BAR__');
  31169. * // => 'foo bar'
  31170. */
  31171. var lowerCase = createCompounder(function(result, word, index) {
  31172. return result + (index ? ' ' : '') + word.toLowerCase();
  31173. });
  31174. /**
  31175. * Converts the first character of `string` to lower case.
  31176. *
  31177. * @static
  31178. * @memberOf _
  31179. * @since 4.0.0
  31180. * @category String
  31181. * @param {string} [string=''] The string to convert.
  31182. * @returns {string} Returns the converted string.
  31183. * @example
  31184. *
  31185. * _.lowerFirst('Fred');
  31186. * // => 'fred'
  31187. *
  31188. * _.lowerFirst('FRED');
  31189. * // => 'fRED'
  31190. */
  31191. var lowerFirst = createCaseFirst('toLowerCase');
  31192. /**
  31193. * Pads `string` on the left and right sides if it's shorter than `length`.
  31194. * Padding characters are truncated if they can't be evenly divided by `length`.
  31195. *
  31196. * @static
  31197. * @memberOf _
  31198. * @since 3.0.0
  31199. * @category String
  31200. * @param {string} [string=''] The string to pad.
  31201. * @param {number} [length=0] The padding length.
  31202. * @param {string} [chars=' '] The string used as padding.
  31203. * @returns {string} Returns the padded string.
  31204. * @example
  31205. *
  31206. * _.pad('abc', 8);
  31207. * // => ' abc '
  31208. *
  31209. * _.pad('abc', 8, '_-');
  31210. * // => '_-abc_-_'
  31211. *
  31212. * _.pad('abc', 3);
  31213. * // => 'abc'
  31214. */
  31215. function pad(string, length, chars) {
  31216. string = toString(string);
  31217. length = toInteger(length);
  31218. var strLength = length ? stringSize(string) : 0;
  31219. if (!length || strLength >= length) {
  31220. return string;
  31221. }
  31222. var mid = (length - strLength) / 2;
  31223. return (
  31224. createPadding(nativeFloor(mid), chars) +
  31225. string +
  31226. createPadding(nativeCeil(mid), chars)
  31227. );
  31228. }
  31229. /**
  31230. * Pads `string` on the right side if it's shorter than `length`. Padding
  31231. * characters are truncated if they exceed `length`.
  31232. *
  31233. * @static
  31234. * @memberOf _
  31235. * @since 4.0.0
  31236. * @category String
  31237. * @param {string} [string=''] The string to pad.
  31238. * @param {number} [length=0] The padding length.
  31239. * @param {string} [chars=' '] The string used as padding.
  31240. * @returns {string} Returns the padded string.
  31241. * @example
  31242. *
  31243. * _.padEnd('abc', 6);
  31244. * // => 'abc '
  31245. *
  31246. * _.padEnd('abc', 6, '_-');
  31247. * // => 'abc_-_'
  31248. *
  31249. * _.padEnd('abc', 3);
  31250. * // => 'abc'
  31251. */
  31252. function padEnd(string, length, chars) {
  31253. string = toString(string);
  31254. length = toInteger(length);
  31255. var strLength = length ? stringSize(string) : 0;
  31256. return (length && strLength < length)
  31257. ? (string + createPadding(length - strLength, chars))
  31258. : string;
  31259. }
  31260. /**
  31261. * Pads `string` on the left side if it's shorter than `length`. Padding
  31262. * characters are truncated if they exceed `length`.
  31263. *
  31264. * @static
  31265. * @memberOf _
  31266. * @since 4.0.0
  31267. * @category String
  31268. * @param {string} [string=''] The string to pad.
  31269. * @param {number} [length=0] The padding length.
  31270. * @param {string} [chars=' '] The string used as padding.
  31271. * @returns {string} Returns the padded string.
  31272. * @example
  31273. *
  31274. * _.padStart('abc', 6);
  31275. * // => ' abc'
  31276. *
  31277. * _.padStart('abc', 6, '_-');
  31278. * // => '_-_abc'
  31279. *
  31280. * _.padStart('abc', 3);
  31281. * // => 'abc'
  31282. */
  31283. function padStart(string, length, chars) {
  31284. string = toString(string);
  31285. length = toInteger(length);
  31286. var strLength = length ? stringSize(string) : 0;
  31287. return (length && strLength < length)
  31288. ? (createPadding(length - strLength, chars) + string)
  31289. : string;
  31290. }
  31291. /**
  31292. * Converts `string` to an integer of the specified radix. If `radix` is
  31293. * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
  31294. * hexadecimal, in which case a `radix` of `16` is used.
  31295. *
  31296. * **Note:** This method aligns with the
  31297. * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
  31298. *
  31299. * @static
  31300. * @memberOf _
  31301. * @since 1.1.0
  31302. * @category String
  31303. * @param {string} string The string to convert.
  31304. * @param {number} [radix=10] The radix to interpret `value` by.
  31305. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31306. * @returns {number} Returns the converted integer.
  31307. * @example
  31308. *
  31309. * _.parseInt('08');
  31310. * // => 8
  31311. *
  31312. * _.map(['6', '08', '10'], _.parseInt);
  31313. * // => [6, 8, 10]
  31314. */
  31315. function parseInt(string, radix, guard) {
  31316. if (guard || radix == null) {
  31317. radix = 0;
  31318. } else if (radix) {
  31319. radix = +radix;
  31320. }
  31321. return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
  31322. }
  31323. /**
  31324. * Repeats the given string `n` times.
  31325. *
  31326. * @static
  31327. * @memberOf _
  31328. * @since 3.0.0
  31329. * @category String
  31330. * @param {string} [string=''] The string to repeat.
  31331. * @param {number} [n=1] The number of times to repeat the string.
  31332. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31333. * @returns {string} Returns the repeated string.
  31334. * @example
  31335. *
  31336. * _.repeat('*', 3);
  31337. * // => '***'
  31338. *
  31339. * _.repeat('abc', 2);
  31340. * // => 'abcabc'
  31341. *
  31342. * _.repeat('abc', 0);
  31343. * // => ''
  31344. */
  31345. function repeat(string, n, guard) {
  31346. if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) {
  31347. n = 1;
  31348. } else {
  31349. n = toInteger(n);
  31350. }
  31351. return baseRepeat(toString(string), n);
  31352. }
  31353. /**
  31354. * Replaces matches for `pattern` in `string` with `replacement`.
  31355. *
  31356. * **Note:** This method is based on
  31357. * [`String#replace`](https://mdn.io/String/replace).
  31358. *
  31359. * @static
  31360. * @memberOf _
  31361. * @since 4.0.0
  31362. * @category String
  31363. * @param {string} [string=''] The string to modify.
  31364. * @param {RegExp|string} pattern The pattern to replace.
  31365. * @param {Function|string} replacement The match replacement.
  31366. * @returns {string} Returns the modified string.
  31367. * @example
  31368. *
  31369. * _.replace('Hi Fred', 'Fred', 'Barney');
  31370. * // => 'Hi Barney'
  31371. */
  31372. function replace() {
  31373. var args = arguments,
  31374. string = toString(args[0]);
  31375. return args.length < 3 ? string : string.replace(args[1], args[2]);
  31376. }
  31377. /**
  31378. * Converts `string` to
  31379. * [snake case](https://en.wikipedia.org/wiki/Snake_case).
  31380. *
  31381. * @static
  31382. * @memberOf _
  31383. * @since 3.0.0
  31384. * @category String
  31385. * @param {string} [string=''] The string to convert.
  31386. * @returns {string} Returns the snake cased string.
  31387. * @example
  31388. *
  31389. * _.snakeCase('Foo Bar');
  31390. * // => 'foo_bar'
  31391. *
  31392. * _.snakeCase('fooBar');
  31393. * // => 'foo_bar'
  31394. *
  31395. * _.snakeCase('--FOO-BAR--');
  31396. * // => 'foo_bar'
  31397. */
  31398. var snakeCase = createCompounder(function(result, word, index) {
  31399. return result + (index ? '_' : '') + word.toLowerCase();
  31400. });
  31401. /**
  31402. * Splits `string` by `separator`.
  31403. *
  31404. * **Note:** This method is based on
  31405. * [`String#split`](https://mdn.io/String/split).
  31406. *
  31407. * @static
  31408. * @memberOf _
  31409. * @since 4.0.0
  31410. * @category String
  31411. * @param {string} [string=''] The string to split.
  31412. * @param {RegExp|string} separator The separator pattern to split by.
  31413. * @param {number} [limit] The length to truncate results to.
  31414. * @returns {Array} Returns the string segments.
  31415. * @example
  31416. *
  31417. * _.split('a-b-c', '-', 2);
  31418. * // => ['a', 'b']
  31419. */
  31420. function split(string, separator, limit) {
  31421. if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
  31422. separator = limit = undefined;
  31423. }
  31424. limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
  31425. if (!limit) {
  31426. return [];
  31427. }
  31428. string = toString(string);
  31429. if (string && (
  31430. typeof separator == 'string' ||
  31431. (separator != null && !isRegExp(separator))
  31432. )) {
  31433. separator = baseToString(separator);
  31434. if (!separator && hasUnicode(string)) {
  31435. return castSlice(stringToArray(string), 0, limit);
  31436. }
  31437. }
  31438. return string.split(separator, limit);
  31439. }
  31440. /**
  31441. * Converts `string` to
  31442. * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage).
  31443. *
  31444. * @static
  31445. * @memberOf _
  31446. * @since 3.1.0
  31447. * @category String
  31448. * @param {string} [string=''] The string to convert.
  31449. * @returns {string} Returns the start cased string.
  31450. * @example
  31451. *
  31452. * _.startCase('--foo-bar--');
  31453. * // => 'Foo Bar'
  31454. *
  31455. * _.startCase('fooBar');
  31456. * // => 'Foo Bar'
  31457. *
  31458. * _.startCase('__FOO_BAR__');
  31459. * // => 'FOO BAR'
  31460. */
  31461. var startCase = createCompounder(function(result, word, index) {
  31462. return result + (index ? ' ' : '') + upperFirst(word);
  31463. });
  31464. /**
  31465. * Checks if `string` starts with the given target string.
  31466. *
  31467. * @static
  31468. * @memberOf _
  31469. * @since 3.0.0
  31470. * @category String
  31471. * @param {string} [string=''] The string to inspect.
  31472. * @param {string} [target] The string to search for.
  31473. * @param {number} [position=0] The position to search from.
  31474. * @returns {boolean} Returns `true` if `string` starts with `target`,
  31475. * else `false`.
  31476. * @example
  31477. *
  31478. * _.startsWith('abc', 'a');
  31479. * // => true
  31480. *
  31481. * _.startsWith('abc', 'b');
  31482. * // => false
  31483. *
  31484. * _.startsWith('abc', 'b', 1);
  31485. * // => true
  31486. */
  31487. function startsWith(string, target, position) {
  31488. string = toString(string);
  31489. position = position == null
  31490. ? 0
  31491. : baseClamp(toInteger(position), 0, string.length);
  31492. target = baseToString(target);
  31493. return string.slice(position, position + target.length) == target;
  31494. }
  31495. /**
  31496. * Creates a compiled template function that can interpolate data properties
  31497. * in "interpolate" delimiters, HTML-escape interpolated data properties in
  31498. * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data
  31499. * properties may be accessed as free variables in the template. If a setting
  31500. * object is given, it takes precedence over `_.templateSettings` values.
  31501. *
  31502. * **Note:** In the development build `_.template` utilizes
  31503. * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
  31504. * for easier debugging.
  31505. *
  31506. * For more information on precompiling templates see
  31507. * [lodash's custom builds documentation](https://lodash.com/custom-builds).
  31508. *
  31509. * For more information on Chrome extension sandboxes see
  31510. * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval).
  31511. *
  31512. * @static
  31513. * @since 0.1.0
  31514. * @memberOf _
  31515. * @category String
  31516. * @param {string} [string=''] The template string.
  31517. * @param {Object} [options={}] The options object.
  31518. * @param {RegExp} [options.escape=_.templateSettings.escape]
  31519. * The HTML "escape" delimiter.
  31520. * @param {RegExp} [options.evaluate=_.templateSettings.evaluate]
  31521. * The "evaluate" delimiter.
  31522. * @param {Object} [options.imports=_.templateSettings.imports]
  31523. * An object to import into the template as free variables.
  31524. * @param {RegExp} [options.interpolate=_.templateSettings.interpolate]
  31525. * The "interpolate" delimiter.
  31526. * @param {string} [options.sourceURL='lodash.templateSources[n]']
  31527. * The sourceURL of the compiled template.
  31528. * @param {string} [options.variable='obj']
  31529. * The data object variable name.
  31530. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31531. * @returns {Function} Returns the compiled template function.
  31532. * @example
  31533. *
  31534. * // Use the "interpolate" delimiter to create a compiled template.
  31535. * var compiled = _.template('hello <%= user %>!');
  31536. * compiled({ 'user': 'fred' });
  31537. * // => 'hello fred!'
  31538. *
  31539. * // Use the HTML "escape" delimiter to escape data property values.
  31540. * var compiled = _.template('<b><%- value %></b>');
  31541. * compiled({ 'value': '<script>' });
  31542. * // => '<b>&lt;script&gt;</b>'
  31543. *
  31544. * // Use the "evaluate" delimiter to execute JavaScript and generate HTML.
  31545. * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>');
  31546. * compiled({ 'users': ['fred', 'barney'] });
  31547. * // => '<li>fred</li><li>barney</li>'
  31548. *
  31549. * // Use the internal `print` function in "evaluate" delimiters.
  31550. * var compiled = _.template('<% print("hello " + user); %>!');
  31551. * compiled({ 'user': 'barney' });
  31552. * // => 'hello barney!'
  31553. *
  31554. * // Use the ES template literal delimiter as an "interpolate" delimiter.
  31555. * // Disable support by replacing the "interpolate" delimiter.
  31556. * var compiled = _.template('hello ${ user }!');
  31557. * compiled({ 'user': 'pebbles' });
  31558. * // => 'hello pebbles!'
  31559. *
  31560. * // Use backslashes to treat delimiters as plain text.
  31561. * var compiled = _.template('<%= "\\<%- value %\\>" %>');
  31562. * compiled({ 'value': 'ignored' });
  31563. * // => '<%- value %>'
  31564. *
  31565. * // Use the `imports` option to import `jQuery` as `jq`.
  31566. * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>';
  31567. * var compiled = _.template(text, { 'imports': { 'jq': jQuery } });
  31568. * compiled({ 'users': ['fred', 'barney'] });
  31569. * // => '<li>fred</li><li>barney</li>'
  31570. *
  31571. * // Use the `sourceURL` option to specify a custom sourceURL for the template.
  31572. * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' });
  31573. * compiled(data);
  31574. * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector.
  31575. *
  31576. * // Use the `variable` option to ensure a with-statement isn't used in the compiled template.
  31577. * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' });
  31578. * compiled.source;
  31579. * // => function(data) {
  31580. * // var __t, __p = '';
  31581. * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!';
  31582. * // return __p;
  31583. * // }
  31584. *
  31585. * // Use custom template delimiters.
  31586. * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
  31587. * var compiled = _.template('hello {{ user }}!');
  31588. * compiled({ 'user': 'mustache' });
  31589. * // => 'hello mustache!'
  31590. *
  31591. * // Use the `source` property to inline compiled templates for meaningful
  31592. * // line numbers in error messages and stack traces.
  31593. * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\
  31594. * var JST = {\
  31595. * "main": ' + _.template(mainText).source + '\
  31596. * };\
  31597. * ');
  31598. */
  31599. function template(string, options, guard) {
  31600. // Based on John Resig's `tmpl` implementation
  31601. // (http://ejohn.org/blog/javascript-micro-templating/)
  31602. // and Laura Doktorova's doT.js (https://github.com/olado/doT).
  31603. var settings = lodash.templateSettings;
  31604. if (guard && isIterateeCall(string, options, guard)) {
  31605. options = undefined;
  31606. }
  31607. string = toString(string);
  31608. options = assignInWith({}, options, settings, customDefaultsAssignIn);
  31609. var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
  31610. importsKeys = keys(imports),
  31611. importsValues = baseValues(imports, importsKeys);
  31612. var isEscaping,
  31613. isEvaluating,
  31614. index = 0,
  31615. interpolate = options.interpolate || reNoMatch,
  31616. source = "__p += '";
  31617. // Compile the regexp to match each delimiter.
  31618. var reDelimiters = RegExp(
  31619. (options.escape || reNoMatch).source + '|' +
  31620. interpolate.source + '|' +
  31621. (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
  31622. (options.evaluate || reNoMatch).source + '|$'
  31623. , 'g');
  31624. // Use a sourceURL for easier debugging.
  31625. // The sourceURL gets injected into the source that's eval-ed, so be careful
  31626. // with lookup (in case of e.g. prototype pollution), and strip newlines if any.
  31627. // A newline wouldn't be a valid sourceURL anyway, and it'd enable code injection.
  31628. var sourceURL = '//# sourceURL=' +
  31629. (hasOwnProperty.call(options, 'sourceURL')
  31630. ? (options.sourceURL + '').replace(/[\r\n]/g, ' ')
  31631. : ('lodash.templateSources[' + (++templateCounter) + ']')
  31632. ) + '\n';
  31633. string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
  31634. interpolateValue || (interpolateValue = esTemplateValue);
  31635. // Escape characters that can't be included in string literals.
  31636. source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
  31637. // Replace delimiters with snippets.
  31638. if (escapeValue) {
  31639. isEscaping = true;
  31640. source += "' +\n__e(" + escapeValue + ") +\n'";
  31641. }
  31642. if (evaluateValue) {
  31643. isEvaluating = true;
  31644. source += "';\n" + evaluateValue + ";\n__p += '";
  31645. }
  31646. if (interpolateValue) {
  31647. source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
  31648. }
  31649. index = offset + match.length;
  31650. // The JS engine embedded in Adobe products needs `match` returned in
  31651. // order to produce the correct `offset` value.
  31652. return match;
  31653. });
  31654. source += "';\n";
  31655. // If `variable` is not specified wrap a with-statement around the generated
  31656. // code to add the data object to the top of the scope chain.
  31657. // Like with sourceURL, we take care to not check the option's prototype,
  31658. // as this configuration is a code injection vector.
  31659. var variable = hasOwnProperty.call(options, 'variable') && options.variable;
  31660. if (!variable) {
  31661. source = 'with (obj) {\n' + source + '\n}\n';
  31662. }
  31663. // Cleanup code by stripping empty strings.
  31664. source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
  31665. .replace(reEmptyStringMiddle, '$1')
  31666. .replace(reEmptyStringTrailing, '$1;');
  31667. // Frame code as the function body.
  31668. source = 'function(' + (variable || 'obj') + ') {\n' +
  31669. (variable
  31670. ? ''
  31671. : 'obj || (obj = {});\n'
  31672. ) +
  31673. "var __t, __p = ''" +
  31674. (isEscaping
  31675. ? ', __e = _.escape'
  31676. : ''
  31677. ) +
  31678. (isEvaluating
  31679. ? ', __j = Array.prototype.join;\n' +
  31680. "function print() { __p += __j.call(arguments, '') }\n"
  31681. : ';\n'
  31682. ) +
  31683. source +
  31684. 'return __p\n}';
  31685. var result = attempt(function() {
  31686. return Function(importsKeys, sourceURL + 'return ' + source)
  31687. .apply(undefined, importsValues);
  31688. });
  31689. // Provide the compiled function's source by its `toString` method or
  31690. // the `source` property as a convenience for inlining compiled templates.
  31691. result.source = source;
  31692. if (isError(result)) {
  31693. throw result;
  31694. }
  31695. return result;
  31696. }
  31697. /**
  31698. * Converts `string`, as a whole, to lower case just like
  31699. * [String#toLowerCase](https://mdn.io/toLowerCase).
  31700. *
  31701. * @static
  31702. * @memberOf _
  31703. * @since 4.0.0
  31704. * @category String
  31705. * @param {string} [string=''] The string to convert.
  31706. * @returns {string} Returns the lower cased string.
  31707. * @example
  31708. *
  31709. * _.toLower('--Foo-Bar--');
  31710. * // => '--foo-bar--'
  31711. *
  31712. * _.toLower('fooBar');
  31713. * // => 'foobar'
  31714. *
  31715. * _.toLower('__FOO_BAR__');
  31716. * // => '__foo_bar__'
  31717. */
  31718. function toLower(value) {
  31719. return toString(value).toLowerCase();
  31720. }
  31721. /**
  31722. * Converts `string`, as a whole, to upper case just like
  31723. * [String#toUpperCase](https://mdn.io/toUpperCase).
  31724. *
  31725. * @static
  31726. * @memberOf _
  31727. * @since 4.0.0
  31728. * @category String
  31729. * @param {string} [string=''] The string to convert.
  31730. * @returns {string} Returns the upper cased string.
  31731. * @example
  31732. *
  31733. * _.toUpper('--foo-bar--');
  31734. * // => '--FOO-BAR--'
  31735. *
  31736. * _.toUpper('fooBar');
  31737. * // => 'FOOBAR'
  31738. *
  31739. * _.toUpper('__foo_bar__');
  31740. * // => '__FOO_BAR__'
  31741. */
  31742. function toUpper(value) {
  31743. return toString(value).toUpperCase();
  31744. }
  31745. /**
  31746. * Removes leading and trailing whitespace or specified characters from `string`.
  31747. *
  31748. * @static
  31749. * @memberOf _
  31750. * @since 3.0.0
  31751. * @category String
  31752. * @param {string} [string=''] The string to trim.
  31753. * @param {string} [chars=whitespace] The characters to trim.
  31754. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31755. * @returns {string} Returns the trimmed string.
  31756. * @example
  31757. *
  31758. * _.trim(' abc ');
  31759. * // => 'abc'
  31760. *
  31761. * _.trim('-_-abc-_-', '_-');
  31762. * // => 'abc'
  31763. *
  31764. * _.map([' foo ', ' bar '], _.trim);
  31765. * // => ['foo', 'bar']
  31766. */
  31767. function trim(string, chars, guard) {
  31768. string = toString(string);
  31769. if (string && (guard || chars === undefined)) {
  31770. return string.replace(reTrim, '');
  31771. }
  31772. if (!string || !(chars = baseToString(chars))) {
  31773. return string;
  31774. }
  31775. var strSymbols = stringToArray(string),
  31776. chrSymbols = stringToArray(chars),
  31777. start = charsStartIndex(strSymbols, chrSymbols),
  31778. end = charsEndIndex(strSymbols, chrSymbols) + 1;
  31779. return castSlice(strSymbols, start, end).join('');
  31780. }
  31781. /**
  31782. * Removes trailing whitespace or specified characters from `string`.
  31783. *
  31784. * @static
  31785. * @memberOf _
  31786. * @since 4.0.0
  31787. * @category String
  31788. * @param {string} [string=''] The string to trim.
  31789. * @param {string} [chars=whitespace] The characters to trim.
  31790. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31791. * @returns {string} Returns the trimmed string.
  31792. * @example
  31793. *
  31794. * _.trimEnd(' abc ');
  31795. * // => ' abc'
  31796. *
  31797. * _.trimEnd('-_-abc-_-', '_-');
  31798. * // => '-_-abc'
  31799. */
  31800. function trimEnd(string, chars, guard) {
  31801. string = toString(string);
  31802. if (string && (guard || chars === undefined)) {
  31803. return string.replace(reTrimEnd, '');
  31804. }
  31805. if (!string || !(chars = baseToString(chars))) {
  31806. return string;
  31807. }
  31808. var strSymbols = stringToArray(string),
  31809. end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
  31810. return castSlice(strSymbols, 0, end).join('');
  31811. }
  31812. /**
  31813. * Removes leading whitespace or specified characters from `string`.
  31814. *
  31815. * @static
  31816. * @memberOf _
  31817. * @since 4.0.0
  31818. * @category String
  31819. * @param {string} [string=''] The string to trim.
  31820. * @param {string} [chars=whitespace] The characters to trim.
  31821. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  31822. * @returns {string} Returns the trimmed string.
  31823. * @example
  31824. *
  31825. * _.trimStart(' abc ');
  31826. * // => 'abc '
  31827. *
  31828. * _.trimStart('-_-abc-_-', '_-');
  31829. * // => 'abc-_-'
  31830. */
  31831. function trimStart(string, chars, guard) {
  31832. string = toString(string);
  31833. if (string && (guard || chars === undefined)) {
  31834. return string.replace(reTrimStart, '');
  31835. }
  31836. if (!string || !(chars = baseToString(chars))) {
  31837. return string;
  31838. }
  31839. var strSymbols = stringToArray(string),
  31840. start = charsStartIndex(strSymbols, stringToArray(chars));
  31841. return castSlice(strSymbols, start).join('');
  31842. }
  31843. /**
  31844. * Truncates `string` if it's longer than the given maximum string length.
  31845. * The last characters of the truncated string are replaced with the omission
  31846. * string which defaults to "...".
  31847. *
  31848. * @static
  31849. * @memberOf _
  31850. * @since 4.0.0
  31851. * @category String
  31852. * @param {string} [string=''] The string to truncate.
  31853. * @param {Object} [options={}] The options object.
  31854. * @param {number} [options.length=30] The maximum string length.
  31855. * @param {string} [options.omission='...'] The string to indicate text is omitted.
  31856. * @param {RegExp|string} [options.separator] The separator pattern to truncate to.
  31857. * @returns {string} Returns the truncated string.
  31858. * @example
  31859. *
  31860. * _.truncate('hi-diddly-ho there, neighborino');
  31861. * // => 'hi-diddly-ho there, neighbo...'
  31862. *
  31863. * _.truncate('hi-diddly-ho there, neighborino', {
  31864. * 'length': 24,
  31865. * 'separator': ' '
  31866. * });
  31867. * // => 'hi-diddly-ho there,...'
  31868. *
  31869. * _.truncate('hi-diddly-ho there, neighborino', {
  31870. * 'length': 24,
  31871. * 'separator': /,? +/
  31872. * });
  31873. * // => 'hi-diddly-ho there...'
  31874. *
  31875. * _.truncate('hi-diddly-ho there, neighborino', {
  31876. * 'omission': ' [...]'
  31877. * });
  31878. * // => 'hi-diddly-ho there, neig [...]'
  31879. */
  31880. function truncate(string, options) {
  31881. var length = DEFAULT_TRUNC_LENGTH,
  31882. omission = DEFAULT_TRUNC_OMISSION;
  31883. if (isObject(options)) {
  31884. var separator = 'separator' in options ? options.separator : separator;
  31885. length = 'length' in options ? toInteger(options.length) : length;
  31886. omission = 'omission' in options ? baseToString(options.omission) : omission;
  31887. }
  31888. string = toString(string);
  31889. var strLength = string.length;
  31890. if (hasUnicode(string)) {
  31891. var strSymbols = stringToArray(string);
  31892. strLength = strSymbols.length;
  31893. }
  31894. if (length >= strLength) {
  31895. return string;
  31896. }
  31897. var end = length - stringSize(omission);
  31898. if (end < 1) {
  31899. return omission;
  31900. }
  31901. var result = strSymbols
  31902. ? castSlice(strSymbols, 0, end).join('')
  31903. : string.slice(0, end);
  31904. if (separator === undefined) {
  31905. return result + omission;
  31906. }
  31907. if (strSymbols) {
  31908. end += (result.length - end);
  31909. }
  31910. if (isRegExp(separator)) {
  31911. if (string.slice(end).search(separator)) {
  31912. var match,
  31913. substring = result;
  31914. if (!separator.global) {
  31915. separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g');
  31916. }
  31917. separator.lastIndex = 0;
  31918. while ((match = separator.exec(substring))) {
  31919. var newEnd = match.index;
  31920. }
  31921. result = result.slice(0, newEnd === undefined ? end : newEnd);
  31922. }
  31923. } else if (string.indexOf(baseToString(separator), end) != end) {
  31924. var index = result.lastIndexOf(separator);
  31925. if (index > -1) {
  31926. result = result.slice(0, index);
  31927. }
  31928. }
  31929. return result + omission;
  31930. }
  31931. /**
  31932. * The inverse of `_.escape`; this method converts the HTML entities
  31933. * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
  31934. * their corresponding characters.
  31935. *
  31936. * **Note:** No other HTML entities are unescaped. To unescape additional
  31937. * HTML entities use a third-party library like [_he_](https://mths.be/he).
  31938. *
  31939. * @static
  31940. * @memberOf _
  31941. * @since 0.6.0
  31942. * @category String
  31943. * @param {string} [string=''] The string to unescape.
  31944. * @returns {string} Returns the unescaped string.
  31945. * @example
  31946. *
  31947. * _.unescape('fred, barney, &amp; pebbles');
  31948. * // => 'fred, barney, & pebbles'
  31949. */
  31950. function unescape(string) {
  31951. string = toString(string);
  31952. return (string && reHasEscapedHtml.test(string))
  31953. ? string.replace(reEscapedHtml, unescapeHtmlChar)
  31954. : string;
  31955. }
  31956. /**
  31957. * Converts `string`, as space separated words, to upper case.
  31958. *
  31959. * @static
  31960. * @memberOf _
  31961. * @since 4.0.0
  31962. * @category String
  31963. * @param {string} [string=''] The string to convert.
  31964. * @returns {string} Returns the upper cased string.
  31965. * @example
  31966. *
  31967. * _.upperCase('--foo-bar');
  31968. * // => 'FOO BAR'
  31969. *
  31970. * _.upperCase('fooBar');
  31971. * // => 'FOO BAR'
  31972. *
  31973. * _.upperCase('__foo_bar__');
  31974. * // => 'FOO BAR'
  31975. */
  31976. var upperCase = createCompounder(function(result, word, index) {
  31977. return result + (index ? ' ' : '') + word.toUpperCase();
  31978. });
  31979. /**
  31980. * Converts the first character of `string` to upper case.
  31981. *
  31982. * @static
  31983. * @memberOf _
  31984. * @since 4.0.0
  31985. * @category String
  31986. * @param {string} [string=''] The string to convert.
  31987. * @returns {string} Returns the converted string.
  31988. * @example
  31989. *
  31990. * _.upperFirst('fred');
  31991. * // => 'Fred'
  31992. *
  31993. * _.upperFirst('FRED');
  31994. * // => 'FRED'
  31995. */
  31996. var upperFirst = createCaseFirst('toUpperCase');
  31997. /**
  31998. * Splits `string` into an array of its words.
  31999. *
  32000. * @static
  32001. * @memberOf _
  32002. * @since 3.0.0
  32003. * @category String
  32004. * @param {string} [string=''] The string to inspect.
  32005. * @param {RegExp|string} [pattern] The pattern to match words.
  32006. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  32007. * @returns {Array} Returns the words of `string`.
  32008. * @example
  32009. *
  32010. * _.words('fred, barney, & pebbles');
  32011. * // => ['fred', 'barney', 'pebbles']
  32012. *
  32013. * _.words('fred, barney, & pebbles', /[^, ]+/g);
  32014. * // => ['fred', 'barney', '&', 'pebbles']
  32015. */
  32016. function words(string, pattern, guard) {
  32017. string = toString(string);
  32018. pattern = guard ? undefined : pattern;
  32019. if (pattern === undefined) {
  32020. return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
  32021. }
  32022. return string.match(pattern) || [];
  32023. }
  32024. /*------------------------------------------------------------------------*/
  32025. /**
  32026. * Attempts to invoke `func`, returning either the result or the caught error
  32027. * object. Any additional arguments are provided to `func` when it's invoked.
  32028. *
  32029. * @static
  32030. * @memberOf _
  32031. * @since 3.0.0
  32032. * @category Util
  32033. * @param {Function} func The function to attempt.
  32034. * @param {...*} [args] The arguments to invoke `func` with.
  32035. * @returns {*} Returns the `func` result or error object.
  32036. * @example
  32037. *
  32038. * // Avoid throwing errors for invalid selectors.
  32039. * var elements = _.attempt(function(selector) {
  32040. * return document.querySelectorAll(selector);
  32041. * }, '>_>');
  32042. *
  32043. * if (_.isError(elements)) {
  32044. * elements = [];
  32045. * }
  32046. */
  32047. var attempt = baseRest(function(func, args) {
  32048. try {
  32049. return apply(func, undefined, args);
  32050. } catch (e) {
  32051. return isError(e) ? e : new Error(e);
  32052. }
  32053. });
  32054. /**
  32055. * Binds methods of an object to the object itself, overwriting the existing
  32056. * method.
  32057. *
  32058. * **Note:** This method doesn't set the "length" property of bound functions.
  32059. *
  32060. * @static
  32061. * @since 0.1.0
  32062. * @memberOf _
  32063. * @category Util
  32064. * @param {Object} object The object to bind and assign the bound methods to.
  32065. * @param {...(string|string[])} methodNames The object method names to bind.
  32066. * @returns {Object} Returns `object`.
  32067. * @example
  32068. *
  32069. * var view = {
  32070. * 'label': 'docs',
  32071. * 'click': function() {
  32072. * console.log('clicked ' + this.label);
  32073. * }
  32074. * };
  32075. *
  32076. * _.bindAll(view, ['click']);
  32077. * jQuery(element).on('click', view.click);
  32078. * // => Logs 'clicked docs' when clicked.
  32079. */
  32080. var bindAll = flatRest(function(object, methodNames) {
  32081. arrayEach(methodNames, function(key) {
  32082. key = toKey(key);
  32083. baseAssignValue(object, key, bind(object[key], object));
  32084. });
  32085. return object;
  32086. });
  32087. /**
  32088. * Creates a function that iterates over `pairs` and invokes the corresponding
  32089. * function of the first predicate to return truthy. The predicate-function
  32090. * pairs are invoked with the `this` binding and arguments of the created
  32091. * function.
  32092. *
  32093. * @static
  32094. * @memberOf _
  32095. * @since 4.0.0
  32096. * @category Util
  32097. * @param {Array} pairs The predicate-function pairs.
  32098. * @returns {Function} Returns the new composite function.
  32099. * @example
  32100. *
  32101. * var func = _.cond([
  32102. * [_.matches({ 'a': 1 }), _.constant('matches A')],
  32103. * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
  32104. * [_.stubTrue, _.constant('no match')]
  32105. * ]);
  32106. *
  32107. * func({ 'a': 1, 'b': 2 });
  32108. * // => 'matches A'
  32109. *
  32110. * func({ 'a': 0, 'b': 1 });
  32111. * // => 'matches B'
  32112. *
  32113. * func({ 'a': '1', 'b': '2' });
  32114. * // => 'no match'
  32115. */
  32116. function cond(pairs) {
  32117. var length = pairs == null ? 0 : pairs.length,
  32118. toIteratee = getIteratee();
  32119. pairs = !length ? [] : arrayMap(pairs, function(pair) {
  32120. if (typeof pair[1] != 'function') {
  32121. throw new TypeError(FUNC_ERROR_TEXT);
  32122. }
  32123. return [toIteratee(pair[0]), pair[1]];
  32124. });
  32125. return baseRest(function(args) {
  32126. var index = -1;
  32127. while (++index < length) {
  32128. var pair = pairs[index];
  32129. if (apply(pair[0], this, args)) {
  32130. return apply(pair[1], this, args);
  32131. }
  32132. }
  32133. });
  32134. }
  32135. /**
  32136. * Creates a function that invokes the predicate properties of `source` with
  32137. * the corresponding property values of a given object, returning `true` if
  32138. * all predicates return truthy, else `false`.
  32139. *
  32140. * **Note:** The created function is equivalent to `_.conformsTo` with
  32141. * `source` partially applied.
  32142. *
  32143. * @static
  32144. * @memberOf _
  32145. * @since 4.0.0
  32146. * @category Util
  32147. * @param {Object} source The object of property predicates to conform to.
  32148. * @returns {Function} Returns the new spec function.
  32149. * @example
  32150. *
  32151. * var objects = [
  32152. * { 'a': 2, 'b': 1 },
  32153. * { 'a': 1, 'b': 2 }
  32154. * ];
  32155. *
  32156. * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
  32157. * // => [{ 'a': 1, 'b': 2 }]
  32158. */
  32159. function conforms(source) {
  32160. return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
  32161. }
  32162. /**
  32163. * Creates a function that returns `value`.
  32164. *
  32165. * @static
  32166. * @memberOf _
  32167. * @since 2.4.0
  32168. * @category Util
  32169. * @param {*} value The value to return from the new function.
  32170. * @returns {Function} Returns the new constant function.
  32171. * @example
  32172. *
  32173. * var objects = _.times(2, _.constant({ 'a': 1 }));
  32174. *
  32175. * console.log(objects);
  32176. * // => [{ 'a': 1 }, { 'a': 1 }]
  32177. *
  32178. * console.log(objects[0] === objects[1]);
  32179. * // => true
  32180. */
  32181. function constant(value) {
  32182. return function() {
  32183. return value;
  32184. };
  32185. }
  32186. /**
  32187. * Checks `value` to determine whether a default value should be returned in
  32188. * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
  32189. * or `undefined`.
  32190. *
  32191. * @static
  32192. * @memberOf _
  32193. * @since 4.14.0
  32194. * @category Util
  32195. * @param {*} value The value to check.
  32196. * @param {*} defaultValue The default value.
  32197. * @returns {*} Returns the resolved value.
  32198. * @example
  32199. *
  32200. * _.defaultTo(1, 10);
  32201. * // => 1
  32202. *
  32203. * _.defaultTo(undefined, 10);
  32204. * // => 10
  32205. */
  32206. function defaultTo(value, defaultValue) {
  32207. return (value == null || value !== value) ? defaultValue : value;
  32208. }
  32209. /**
  32210. * Creates a function that returns the result of invoking the given functions
  32211. * with the `this` binding of the created function, where each successive
  32212. * invocation is supplied the return value of the previous.
  32213. *
  32214. * @static
  32215. * @memberOf _
  32216. * @since 3.0.0
  32217. * @category Util
  32218. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  32219. * @returns {Function} Returns the new composite function.
  32220. * @see _.flowRight
  32221. * @example
  32222. *
  32223. * function square(n) {
  32224. * return n * n;
  32225. * }
  32226. *
  32227. * var addSquare = _.flow([_.add, square]);
  32228. * addSquare(1, 2);
  32229. * // => 9
  32230. */
  32231. var flow = createFlow();
  32232. /**
  32233. * This method is like `_.flow` except that it creates a function that
  32234. * invokes the given functions from right to left.
  32235. *
  32236. * @static
  32237. * @since 3.0.0
  32238. * @memberOf _
  32239. * @category Util
  32240. * @param {...(Function|Function[])} [funcs] The functions to invoke.
  32241. * @returns {Function} Returns the new composite function.
  32242. * @see _.flow
  32243. * @example
  32244. *
  32245. * function square(n) {
  32246. * return n * n;
  32247. * }
  32248. *
  32249. * var addSquare = _.flowRight([square, _.add]);
  32250. * addSquare(1, 2);
  32251. * // => 9
  32252. */
  32253. var flowRight = createFlow(true);
  32254. /**
  32255. * This method returns the first argument it receives.
  32256. *
  32257. * @static
  32258. * @since 0.1.0
  32259. * @memberOf _
  32260. * @category Util
  32261. * @param {*} value Any value.
  32262. * @returns {*} Returns `value`.
  32263. * @example
  32264. *
  32265. * var object = { 'a': 1 };
  32266. *
  32267. * console.log(_.identity(object) === object);
  32268. * // => true
  32269. */
  32270. function identity(value) {
  32271. return value;
  32272. }
  32273. /**
  32274. * Creates a function that invokes `func` with the arguments of the created
  32275. * function. If `func` is a property name, the created function returns the
  32276. * property value for a given element. If `func` is an array or object, the
  32277. * created function returns `true` for elements that contain the equivalent
  32278. * source properties, otherwise it returns `false`.
  32279. *
  32280. * @static
  32281. * @since 4.0.0
  32282. * @memberOf _
  32283. * @category Util
  32284. * @param {*} [func=_.identity] The value to convert to a callback.
  32285. * @returns {Function} Returns the callback.
  32286. * @example
  32287. *
  32288. * var users = [
  32289. * { 'user': 'barney', 'age': 36, 'active': true },
  32290. * { 'user': 'fred', 'age': 40, 'active': false }
  32291. * ];
  32292. *
  32293. * // The `_.matches` iteratee shorthand.
  32294. * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true }));
  32295. * // => [{ 'user': 'barney', 'age': 36, 'active': true }]
  32296. *
  32297. * // The `_.matchesProperty` iteratee shorthand.
  32298. * _.filter(users, _.iteratee(['user', 'fred']));
  32299. * // => [{ 'user': 'fred', 'age': 40 }]
  32300. *
  32301. * // The `_.property` iteratee shorthand.
  32302. * _.map(users, _.iteratee('user'));
  32303. * // => ['barney', 'fred']
  32304. *
  32305. * // Create custom iteratee shorthands.
  32306. * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) {
  32307. * return !_.isRegExp(func) ? iteratee(func) : function(string) {
  32308. * return func.test(string);
  32309. * };
  32310. * });
  32311. *
  32312. * _.filter(['abc', 'def'], /ef/);
  32313. * // => ['def']
  32314. */
  32315. function iteratee(func) {
  32316. return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
  32317. }
  32318. /**
  32319. * Creates a function that performs a partial deep comparison between a given
  32320. * object and `source`, returning `true` if the given object has equivalent
  32321. * property values, else `false`.
  32322. *
  32323. * **Note:** The created function is equivalent to `_.isMatch` with `source`
  32324. * partially applied.
  32325. *
  32326. * Partial comparisons will match empty array and empty object `source`
  32327. * values against any array or object value, respectively. See `_.isEqual`
  32328. * for a list of supported value comparisons.
  32329. *
  32330. * @static
  32331. * @memberOf _
  32332. * @since 3.0.0
  32333. * @category Util
  32334. * @param {Object} source The object of property values to match.
  32335. * @returns {Function} Returns the new spec function.
  32336. * @example
  32337. *
  32338. * var objects = [
  32339. * { 'a': 1, 'b': 2, 'c': 3 },
  32340. * { 'a': 4, 'b': 5, 'c': 6 }
  32341. * ];
  32342. *
  32343. * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
  32344. * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
  32345. */
  32346. function matches(source) {
  32347. return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
  32348. }
  32349. /**
  32350. * Creates a function that performs a partial deep comparison between the
  32351. * value at `path` of a given object to `srcValue`, returning `true` if the
  32352. * object value is equivalent, else `false`.
  32353. *
  32354. * **Note:** Partial comparisons will match empty array and empty object
  32355. * `srcValue` values against any array or object value, respectively. See
  32356. * `_.isEqual` for a list of supported value comparisons.
  32357. *
  32358. * @static
  32359. * @memberOf _
  32360. * @since 3.2.0
  32361. * @category Util
  32362. * @param {Array|string} path The path of the property to get.
  32363. * @param {*} srcValue The value to match.
  32364. * @returns {Function} Returns the new spec function.
  32365. * @example
  32366. *
  32367. * var objects = [
  32368. * { 'a': 1, 'b': 2, 'c': 3 },
  32369. * { 'a': 4, 'b': 5, 'c': 6 }
  32370. * ];
  32371. *
  32372. * _.find(objects, _.matchesProperty('a', 4));
  32373. * // => { 'a': 4, 'b': 5, 'c': 6 }
  32374. */
  32375. function matchesProperty(path, srcValue) {
  32376. return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
  32377. }
  32378. /**
  32379. * Creates a function that invokes the method at `path` of a given object.
  32380. * Any additional arguments are provided to the invoked method.
  32381. *
  32382. * @static
  32383. * @memberOf _
  32384. * @since 3.7.0
  32385. * @category Util
  32386. * @param {Array|string} path The path of the method to invoke.
  32387. * @param {...*} [args] The arguments to invoke the method with.
  32388. * @returns {Function} Returns the new invoker function.
  32389. * @example
  32390. *
  32391. * var objects = [
  32392. * { 'a': { 'b': _.constant(2) } },
  32393. * { 'a': { 'b': _.constant(1) } }
  32394. * ];
  32395. *
  32396. * _.map(objects, _.method('a.b'));
  32397. * // => [2, 1]
  32398. *
  32399. * _.map(objects, _.method(['a', 'b']));
  32400. * // => [2, 1]
  32401. */
  32402. var method = baseRest(function(path, args) {
  32403. return function(object) {
  32404. return baseInvoke(object, path, args);
  32405. };
  32406. });
  32407. /**
  32408. * The opposite of `_.method`; this method creates a function that invokes
  32409. * the method at a given path of `object`. Any additional arguments are
  32410. * provided to the invoked method.
  32411. *
  32412. * @static
  32413. * @memberOf _
  32414. * @since 3.7.0
  32415. * @category Util
  32416. * @param {Object} object The object to query.
  32417. * @param {...*} [args] The arguments to invoke the method with.
  32418. * @returns {Function} Returns the new invoker function.
  32419. * @example
  32420. *
  32421. * var array = _.times(3, _.constant),
  32422. * object = { 'a': array, 'b': array, 'c': array };
  32423. *
  32424. * _.map(['a[2]', 'c[0]'], _.methodOf(object));
  32425. * // => [2, 0]
  32426. *
  32427. * _.map([['a', '2'], ['c', '0']], _.methodOf(object));
  32428. * // => [2, 0]
  32429. */
  32430. var methodOf = baseRest(function(object, args) {
  32431. return function(path) {
  32432. return baseInvoke(object, path, args);
  32433. };
  32434. });
  32435. /**
  32436. * Adds all own enumerable string keyed function properties of a source
  32437. * object to the destination object. If `object` is a function, then methods
  32438. * are added to its prototype as well.
  32439. *
  32440. * **Note:** Use `_.runInContext` to create a pristine `lodash` function to
  32441. * avoid conflicts caused by modifying the original.
  32442. *
  32443. * @static
  32444. * @since 0.1.0
  32445. * @memberOf _
  32446. * @category Util
  32447. * @param {Function|Object} [object=lodash] The destination object.
  32448. * @param {Object} source The object of functions to add.
  32449. * @param {Object} [options={}] The options object.
  32450. * @param {boolean} [options.chain=true] Specify whether mixins are chainable.
  32451. * @returns {Function|Object} Returns `object`.
  32452. * @example
  32453. *
  32454. * function vowels(string) {
  32455. * return _.filter(string, function(v) {
  32456. * return /[aeiou]/i.test(v);
  32457. * });
  32458. * }
  32459. *
  32460. * _.mixin({ 'vowels': vowels });
  32461. * _.vowels('fred');
  32462. * // => ['e']
  32463. *
  32464. * _('fred').vowels().value();
  32465. * // => ['e']
  32466. *
  32467. * _.mixin({ 'vowels': vowels }, { 'chain': false });
  32468. * _('fred').vowels();
  32469. * // => ['e']
  32470. */
  32471. function mixin(object, source, options) {
  32472. var props = keys(source),
  32473. methodNames = baseFunctions(source, props);
  32474. if (options == null &&
  32475. !(isObject(source) && (methodNames.length || !props.length))) {
  32476. options = source;
  32477. source = object;
  32478. object = this;
  32479. methodNames = baseFunctions(source, keys(source));
  32480. }
  32481. var chain = !(isObject(options) && 'chain' in options) || !!options.chain,
  32482. isFunc = isFunction(object);
  32483. arrayEach(methodNames, function(methodName) {
  32484. var func = source[methodName];
  32485. object[methodName] = func;
  32486. if (isFunc) {
  32487. object.prototype[methodName] = function() {
  32488. var chainAll = this.__chain__;
  32489. if (chain || chainAll) {
  32490. var result = object(this.__wrapped__),
  32491. actions = result.__actions__ = copyArray(this.__actions__);
  32492. actions.push({ 'func': func, 'args': arguments, 'thisArg': object });
  32493. result.__chain__ = chainAll;
  32494. return result;
  32495. }
  32496. return func.apply(object, arrayPush([this.value()], arguments));
  32497. };
  32498. }
  32499. });
  32500. return object;
  32501. }
  32502. /**
  32503. * Reverts the `_` variable to its previous value and returns a reference to
  32504. * the `lodash` function.
  32505. *
  32506. * @static
  32507. * @since 0.1.0
  32508. * @memberOf _
  32509. * @category Util
  32510. * @returns {Function} Returns the `lodash` function.
  32511. * @example
  32512. *
  32513. * var lodash = _.noConflict();
  32514. */
  32515. function noConflict() {
  32516. if (root._ === this) {
  32517. root._ = oldDash;
  32518. }
  32519. return this;
  32520. }
  32521. /**
  32522. * This method returns `undefined`.
  32523. *
  32524. * @static
  32525. * @memberOf _
  32526. * @since 2.3.0
  32527. * @category Util
  32528. * @example
  32529. *
  32530. * _.times(2, _.noop);
  32531. * // => [undefined, undefined]
  32532. */
  32533. function noop() {
  32534. // No operation performed.
  32535. }
  32536. /**
  32537. * Creates a function that gets the argument at index `n`. If `n` is negative,
  32538. * the nth argument from the end is returned.
  32539. *
  32540. * @static
  32541. * @memberOf _
  32542. * @since 4.0.0
  32543. * @category Util
  32544. * @param {number} [n=0] The index of the argument to return.
  32545. * @returns {Function} Returns the new pass-thru function.
  32546. * @example
  32547. *
  32548. * var func = _.nthArg(1);
  32549. * func('a', 'b', 'c', 'd');
  32550. * // => 'b'
  32551. *
  32552. * var func = _.nthArg(-2);
  32553. * func('a', 'b', 'c', 'd');
  32554. * // => 'c'
  32555. */
  32556. function nthArg(n) {
  32557. n = toInteger(n);
  32558. return baseRest(function(args) {
  32559. return baseNth(args, n);
  32560. });
  32561. }
  32562. /**
  32563. * Creates a function that invokes `iteratees` with the arguments it receives
  32564. * and returns their results.
  32565. *
  32566. * @static
  32567. * @memberOf _
  32568. * @since 4.0.0
  32569. * @category Util
  32570. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  32571. * The iteratees to invoke.
  32572. * @returns {Function} Returns the new function.
  32573. * @example
  32574. *
  32575. * var func = _.over([Math.max, Math.min]);
  32576. *
  32577. * func(1, 2, 3, 4);
  32578. * // => [4, 1]
  32579. */
  32580. var over = createOver(arrayMap);
  32581. /**
  32582. * Creates a function that checks if **all** of the `predicates` return
  32583. * truthy when invoked with the arguments it receives.
  32584. *
  32585. * @static
  32586. * @memberOf _
  32587. * @since 4.0.0
  32588. * @category Util
  32589. * @param {...(Function|Function[])} [predicates=[_.identity]]
  32590. * The predicates to check.
  32591. * @returns {Function} Returns the new function.
  32592. * @example
  32593. *
  32594. * var func = _.overEvery([Boolean, isFinite]);
  32595. *
  32596. * func('1');
  32597. * // => true
  32598. *
  32599. * func(null);
  32600. * // => false
  32601. *
  32602. * func(NaN);
  32603. * // => false
  32604. */
  32605. var overEvery = createOver(arrayEvery);
  32606. /**
  32607. * Creates a function that checks if **any** of the `predicates` return
  32608. * truthy when invoked with the arguments it receives.
  32609. *
  32610. * @static
  32611. * @memberOf _
  32612. * @since 4.0.0
  32613. * @category Util
  32614. * @param {...(Function|Function[])} [predicates=[_.identity]]
  32615. * The predicates to check.
  32616. * @returns {Function} Returns the new function.
  32617. * @example
  32618. *
  32619. * var func = _.overSome([Boolean, isFinite]);
  32620. *
  32621. * func('1');
  32622. * // => true
  32623. *
  32624. * func(null);
  32625. * // => true
  32626. *
  32627. * func(NaN);
  32628. * // => false
  32629. */
  32630. var overSome = createOver(arraySome);
  32631. /**
  32632. * Creates a function that returns the value at `path` of a given object.
  32633. *
  32634. * @static
  32635. * @memberOf _
  32636. * @since 2.4.0
  32637. * @category Util
  32638. * @param {Array|string} path The path of the property to get.
  32639. * @returns {Function} Returns the new accessor function.
  32640. * @example
  32641. *
  32642. * var objects = [
  32643. * { 'a': { 'b': 2 } },
  32644. * { 'a': { 'b': 1 } }
  32645. * ];
  32646. *
  32647. * _.map(objects, _.property('a.b'));
  32648. * // => [2, 1]
  32649. *
  32650. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  32651. * // => [1, 2]
  32652. */
  32653. function property(path) {
  32654. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  32655. }
  32656. /**
  32657. * The opposite of `_.property`; this method creates a function that returns
  32658. * the value at a given path of `object`.
  32659. *
  32660. * @static
  32661. * @memberOf _
  32662. * @since 3.0.0
  32663. * @category Util
  32664. * @param {Object} object The object to query.
  32665. * @returns {Function} Returns the new accessor function.
  32666. * @example
  32667. *
  32668. * var array = [0, 1, 2],
  32669. * object = { 'a': array, 'b': array, 'c': array };
  32670. *
  32671. * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
  32672. * // => [2, 0]
  32673. *
  32674. * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
  32675. * // => [2, 0]
  32676. */
  32677. function propertyOf(object) {
  32678. return function(path) {
  32679. return object == null ? undefined : baseGet(object, path);
  32680. };
  32681. }
  32682. /**
  32683. * Creates an array of numbers (positive and/or negative) progressing from
  32684. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  32685. * `start` is specified without an `end` or `step`. If `end` is not specified,
  32686. * it's set to `start` with `start` then set to `0`.
  32687. *
  32688. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  32689. * floating-point values which can produce unexpected results.
  32690. *
  32691. * @static
  32692. * @since 0.1.0
  32693. * @memberOf _
  32694. * @category Util
  32695. * @param {number} [start=0] The start of the range.
  32696. * @param {number} end The end of the range.
  32697. * @param {number} [step=1] The value to increment or decrement by.
  32698. * @returns {Array} Returns the range of numbers.
  32699. * @see _.inRange, _.rangeRight
  32700. * @example
  32701. *
  32702. * _.range(4);
  32703. * // => [0, 1, 2, 3]
  32704. *
  32705. * _.range(-4);
  32706. * // => [0, -1, -2, -3]
  32707. *
  32708. * _.range(1, 5);
  32709. * // => [1, 2, 3, 4]
  32710. *
  32711. * _.range(0, 20, 5);
  32712. * // => [0, 5, 10, 15]
  32713. *
  32714. * _.range(0, -4, -1);
  32715. * // => [0, -1, -2, -3]
  32716. *
  32717. * _.range(1, 4, 0);
  32718. * // => [1, 1, 1]
  32719. *
  32720. * _.range(0);
  32721. * // => []
  32722. */
  32723. var range = createRange();
  32724. /**
  32725. * This method is like `_.range` except that it populates values in
  32726. * descending order.
  32727. *
  32728. * @static
  32729. * @memberOf _
  32730. * @since 4.0.0
  32731. * @category Util
  32732. * @param {number} [start=0] The start of the range.
  32733. * @param {number} end The end of the range.
  32734. * @param {number} [step=1] The value to increment or decrement by.
  32735. * @returns {Array} Returns the range of numbers.
  32736. * @see _.inRange, _.range
  32737. * @example
  32738. *
  32739. * _.rangeRight(4);
  32740. * // => [3, 2, 1, 0]
  32741. *
  32742. * _.rangeRight(-4);
  32743. * // => [-3, -2, -1, 0]
  32744. *
  32745. * _.rangeRight(1, 5);
  32746. * // => [4, 3, 2, 1]
  32747. *
  32748. * _.rangeRight(0, 20, 5);
  32749. * // => [15, 10, 5, 0]
  32750. *
  32751. * _.rangeRight(0, -4, -1);
  32752. * // => [-3, -2, -1, 0]
  32753. *
  32754. * _.rangeRight(1, 4, 0);
  32755. * // => [1, 1, 1]
  32756. *
  32757. * _.rangeRight(0);
  32758. * // => []
  32759. */
  32760. var rangeRight = createRange(true);
  32761. /**
  32762. * This method returns a new empty array.
  32763. *
  32764. * @static
  32765. * @memberOf _
  32766. * @since 4.13.0
  32767. * @category Util
  32768. * @returns {Array} Returns the new empty array.
  32769. * @example
  32770. *
  32771. * var arrays = _.times(2, _.stubArray);
  32772. *
  32773. * console.log(arrays);
  32774. * // => [[], []]
  32775. *
  32776. * console.log(arrays[0] === arrays[1]);
  32777. * // => false
  32778. */
  32779. function stubArray() {
  32780. return [];
  32781. }
  32782. /**
  32783. * This method returns `false`.
  32784. *
  32785. * @static
  32786. * @memberOf _
  32787. * @since 4.13.0
  32788. * @category Util
  32789. * @returns {boolean} Returns `false`.
  32790. * @example
  32791. *
  32792. * _.times(2, _.stubFalse);
  32793. * // => [false, false]
  32794. */
  32795. function stubFalse() {
  32796. return false;
  32797. }
  32798. /**
  32799. * This method returns a new empty object.
  32800. *
  32801. * @static
  32802. * @memberOf _
  32803. * @since 4.13.0
  32804. * @category Util
  32805. * @returns {Object} Returns the new empty object.
  32806. * @example
  32807. *
  32808. * var objects = _.times(2, _.stubObject);
  32809. *
  32810. * console.log(objects);
  32811. * // => [{}, {}]
  32812. *
  32813. * console.log(objects[0] === objects[1]);
  32814. * // => false
  32815. */
  32816. function stubObject() {
  32817. return {};
  32818. }
  32819. /**
  32820. * This method returns an empty string.
  32821. *
  32822. * @static
  32823. * @memberOf _
  32824. * @since 4.13.0
  32825. * @category Util
  32826. * @returns {string} Returns the empty string.
  32827. * @example
  32828. *
  32829. * _.times(2, _.stubString);
  32830. * // => ['', '']
  32831. */
  32832. function stubString() {
  32833. return '';
  32834. }
  32835. /**
  32836. * This method returns `true`.
  32837. *
  32838. * @static
  32839. * @memberOf _
  32840. * @since 4.13.0
  32841. * @category Util
  32842. * @returns {boolean} Returns `true`.
  32843. * @example
  32844. *
  32845. * _.times(2, _.stubTrue);
  32846. * // => [true, true]
  32847. */
  32848. function stubTrue() {
  32849. return true;
  32850. }
  32851. /**
  32852. * Invokes the iteratee `n` times, returning an array of the results of
  32853. * each invocation. The iteratee is invoked with one argument; (index).
  32854. *
  32855. * @static
  32856. * @since 0.1.0
  32857. * @memberOf _
  32858. * @category Util
  32859. * @param {number} n The number of times to invoke `iteratee`.
  32860. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  32861. * @returns {Array} Returns the array of results.
  32862. * @example
  32863. *
  32864. * _.times(3, String);
  32865. * // => ['0', '1', '2']
  32866. *
  32867. * _.times(4, _.constant(0));
  32868. * // => [0, 0, 0, 0]
  32869. */
  32870. function times(n, iteratee) {
  32871. n = toInteger(n);
  32872. if (n < 1 || n > MAX_SAFE_INTEGER) {
  32873. return [];
  32874. }
  32875. var index = MAX_ARRAY_LENGTH,
  32876. length = nativeMin(n, MAX_ARRAY_LENGTH);
  32877. iteratee = getIteratee(iteratee);
  32878. n -= MAX_ARRAY_LENGTH;
  32879. var result = baseTimes(length, iteratee);
  32880. while (++index < n) {
  32881. iteratee(index);
  32882. }
  32883. return result;
  32884. }
  32885. /**
  32886. * Converts `value` to a property path array.
  32887. *
  32888. * @static
  32889. * @memberOf _
  32890. * @since 4.0.0
  32891. * @category Util
  32892. * @param {*} value The value to convert.
  32893. * @returns {Array} Returns the new property path array.
  32894. * @example
  32895. *
  32896. * _.toPath('a.b.c');
  32897. * // => ['a', 'b', 'c']
  32898. *
  32899. * _.toPath('a[0].b.c');
  32900. * // => ['a', '0', 'b', 'c']
  32901. */
  32902. function toPath(value) {
  32903. if (isArray(value)) {
  32904. return arrayMap(value, toKey);
  32905. }
  32906. return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
  32907. }
  32908. /**
  32909. * Generates a unique ID. If `prefix` is given, the ID is appended to it.
  32910. *
  32911. * @static
  32912. * @since 0.1.0
  32913. * @memberOf _
  32914. * @category Util
  32915. * @param {string} [prefix=''] The value to prefix the ID with.
  32916. * @returns {string} Returns the unique ID.
  32917. * @example
  32918. *
  32919. * _.uniqueId('contact_');
  32920. * // => 'contact_104'
  32921. *
  32922. * _.uniqueId();
  32923. * // => '105'
  32924. */
  32925. function uniqueId(prefix) {
  32926. var id = ++idCounter;
  32927. return toString(prefix) + id;
  32928. }
  32929. /*------------------------------------------------------------------------*/
  32930. /**
  32931. * Adds two numbers.
  32932. *
  32933. * @static
  32934. * @memberOf _
  32935. * @since 3.4.0
  32936. * @category Math
  32937. * @param {number} augend The first number in an addition.
  32938. * @param {number} addend The second number in an addition.
  32939. * @returns {number} Returns the total.
  32940. * @example
  32941. *
  32942. * _.add(6, 4);
  32943. * // => 10
  32944. */
  32945. var add = createMathOperation(function(augend, addend) {
  32946. return augend + addend;
  32947. }, 0);
  32948. /**
  32949. * Computes `number` rounded up to `precision`.
  32950. *
  32951. * @static
  32952. * @memberOf _
  32953. * @since 3.10.0
  32954. * @category Math
  32955. * @param {number} number The number to round up.
  32956. * @param {number} [precision=0] The precision to round up to.
  32957. * @returns {number} Returns the rounded up number.
  32958. * @example
  32959. *
  32960. * _.ceil(4.006);
  32961. * // => 5
  32962. *
  32963. * _.ceil(6.004, 2);
  32964. * // => 6.01
  32965. *
  32966. * _.ceil(6040, -2);
  32967. * // => 6100
  32968. */
  32969. var ceil = createRound('ceil');
  32970. /**
  32971. * Divide two numbers.
  32972. *
  32973. * @static
  32974. * @memberOf _
  32975. * @since 4.7.0
  32976. * @category Math
  32977. * @param {number} dividend The first number in a division.
  32978. * @param {number} divisor The second number in a division.
  32979. * @returns {number} Returns the quotient.
  32980. * @example
  32981. *
  32982. * _.divide(6, 4);
  32983. * // => 1.5
  32984. */
  32985. var divide = createMathOperation(function(dividend, divisor) {
  32986. return dividend / divisor;
  32987. }, 1);
  32988. /**
  32989. * Computes `number` rounded down to `precision`.
  32990. *
  32991. * @static
  32992. * @memberOf _
  32993. * @since 3.10.0
  32994. * @category Math
  32995. * @param {number} number The number to round down.
  32996. * @param {number} [precision=0] The precision to round down to.
  32997. * @returns {number} Returns the rounded down number.
  32998. * @example
  32999. *
  33000. * _.floor(4.006);
  33001. * // => 4
  33002. *
  33003. * _.floor(0.046, 2);
  33004. * // => 0.04
  33005. *
  33006. * _.floor(4060, -2);
  33007. * // => 4000
  33008. */
  33009. var floor = createRound('floor');
  33010. /**
  33011. * Computes the maximum value of `array`. If `array` is empty or falsey,
  33012. * `undefined` is returned.
  33013. *
  33014. * @static
  33015. * @since 0.1.0
  33016. * @memberOf _
  33017. * @category Math
  33018. * @param {Array} array The array to iterate over.
  33019. * @returns {*} Returns the maximum value.
  33020. * @example
  33021. *
  33022. * _.max([4, 2, 8, 6]);
  33023. * // => 8
  33024. *
  33025. * _.max([]);
  33026. * // => undefined
  33027. */
  33028. function max(array) {
  33029. return (array && array.length)
  33030. ? baseExtremum(array, identity, baseGt)
  33031. : undefined;
  33032. }
  33033. /**
  33034. * This method is like `_.max` except that it accepts `iteratee` which is
  33035. * invoked for each element in `array` to generate the criterion by which
  33036. * the value is ranked. The iteratee is invoked with one argument: (value).
  33037. *
  33038. * @static
  33039. * @memberOf _
  33040. * @since 4.0.0
  33041. * @category Math
  33042. * @param {Array} array The array to iterate over.
  33043. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33044. * @returns {*} Returns the maximum value.
  33045. * @example
  33046. *
  33047. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  33048. *
  33049. * _.maxBy(objects, function(o) { return o.n; });
  33050. * // => { 'n': 2 }
  33051. *
  33052. * // The `_.property` iteratee shorthand.
  33053. * _.maxBy(objects, 'n');
  33054. * // => { 'n': 2 }
  33055. */
  33056. function maxBy(array, iteratee) {
  33057. return (array && array.length)
  33058. ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
  33059. : undefined;
  33060. }
  33061. /**
  33062. * Computes the mean of the values in `array`.
  33063. *
  33064. * @static
  33065. * @memberOf _
  33066. * @since 4.0.0
  33067. * @category Math
  33068. * @param {Array} array The array to iterate over.
  33069. * @returns {number} Returns the mean.
  33070. * @example
  33071. *
  33072. * _.mean([4, 2, 8, 6]);
  33073. * // => 5
  33074. */
  33075. function mean(array) {
  33076. return baseMean(array, identity);
  33077. }
  33078. /**
  33079. * This method is like `_.mean` except that it accepts `iteratee` which is
  33080. * invoked for each element in `array` to generate the value to be averaged.
  33081. * The iteratee is invoked with one argument: (value).
  33082. *
  33083. * @static
  33084. * @memberOf _
  33085. * @since 4.7.0
  33086. * @category Math
  33087. * @param {Array} array The array to iterate over.
  33088. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33089. * @returns {number} Returns the mean.
  33090. * @example
  33091. *
  33092. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  33093. *
  33094. * _.meanBy(objects, function(o) { return o.n; });
  33095. * // => 5
  33096. *
  33097. * // The `_.property` iteratee shorthand.
  33098. * _.meanBy(objects, 'n');
  33099. * // => 5
  33100. */
  33101. function meanBy(array, iteratee) {
  33102. return baseMean(array, getIteratee(iteratee, 2));
  33103. }
  33104. /**
  33105. * Computes the minimum value of `array`. If `array` is empty or falsey,
  33106. * `undefined` is returned.
  33107. *
  33108. * @static
  33109. * @since 0.1.0
  33110. * @memberOf _
  33111. * @category Math
  33112. * @param {Array} array The array to iterate over.
  33113. * @returns {*} Returns the minimum value.
  33114. * @example
  33115. *
  33116. * _.min([4, 2, 8, 6]);
  33117. * // => 2
  33118. *
  33119. * _.min([]);
  33120. * // => undefined
  33121. */
  33122. function min(array) {
  33123. return (array && array.length)
  33124. ? baseExtremum(array, identity, baseLt)
  33125. : undefined;
  33126. }
  33127. /**
  33128. * This method is like `_.min` except that it accepts `iteratee` which is
  33129. * invoked for each element in `array` to generate the criterion by which
  33130. * the value is ranked. The iteratee is invoked with one argument: (value).
  33131. *
  33132. * @static
  33133. * @memberOf _
  33134. * @since 4.0.0
  33135. * @category Math
  33136. * @param {Array} array The array to iterate over.
  33137. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33138. * @returns {*} Returns the minimum value.
  33139. * @example
  33140. *
  33141. * var objects = [{ 'n': 1 }, { 'n': 2 }];
  33142. *
  33143. * _.minBy(objects, function(o) { return o.n; });
  33144. * // => { 'n': 1 }
  33145. *
  33146. * // The `_.property` iteratee shorthand.
  33147. * _.minBy(objects, 'n');
  33148. * // => { 'n': 1 }
  33149. */
  33150. function minBy(array, iteratee) {
  33151. return (array && array.length)
  33152. ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
  33153. : undefined;
  33154. }
  33155. /**
  33156. * Multiply two numbers.
  33157. *
  33158. * @static
  33159. * @memberOf _
  33160. * @since 4.7.0
  33161. * @category Math
  33162. * @param {number} multiplier The first number in a multiplication.
  33163. * @param {number} multiplicand The second number in a multiplication.
  33164. * @returns {number} Returns the product.
  33165. * @example
  33166. *
  33167. * _.multiply(6, 4);
  33168. * // => 24
  33169. */
  33170. var multiply = createMathOperation(function(multiplier, multiplicand) {
  33171. return multiplier * multiplicand;
  33172. }, 1);
  33173. /**
  33174. * Computes `number` rounded to `precision`.
  33175. *
  33176. * @static
  33177. * @memberOf _
  33178. * @since 3.10.0
  33179. * @category Math
  33180. * @param {number} number The number to round.
  33181. * @param {number} [precision=0] The precision to round to.
  33182. * @returns {number} Returns the rounded number.
  33183. * @example
  33184. *
  33185. * _.round(4.006);
  33186. * // => 4
  33187. *
  33188. * _.round(4.006, 2);
  33189. * // => 4.01
  33190. *
  33191. * _.round(4060, -2);
  33192. * // => 4100
  33193. */
  33194. var round = createRound('round');
  33195. /**
  33196. * Subtract two numbers.
  33197. *
  33198. * @static
  33199. * @memberOf _
  33200. * @since 4.0.0
  33201. * @category Math
  33202. * @param {number} minuend The first number in a subtraction.
  33203. * @param {number} subtrahend The second number in a subtraction.
  33204. * @returns {number} Returns the difference.
  33205. * @example
  33206. *
  33207. * _.subtract(6, 4);
  33208. * // => 2
  33209. */
  33210. var subtract = createMathOperation(function(minuend, subtrahend) {
  33211. return minuend - subtrahend;
  33212. }, 0);
  33213. /**
  33214. * Computes the sum of the values in `array`.
  33215. *
  33216. * @static
  33217. * @memberOf _
  33218. * @since 3.4.0
  33219. * @category Math
  33220. * @param {Array} array The array to iterate over.
  33221. * @returns {number} Returns the sum.
  33222. * @example
  33223. *
  33224. * _.sum([4, 2, 8, 6]);
  33225. * // => 20
  33226. */
  33227. function sum(array) {
  33228. return (array && array.length)
  33229. ? baseSum(array, identity)
  33230. : 0;
  33231. }
  33232. /**
  33233. * This method is like `_.sum` except that it accepts `iteratee` which is
  33234. * invoked for each element in `array` to generate the value to be summed.
  33235. * The iteratee is invoked with one argument: (value).
  33236. *
  33237. * @static
  33238. * @memberOf _
  33239. * @since 4.0.0
  33240. * @category Math
  33241. * @param {Array} array The array to iterate over.
  33242. * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
  33243. * @returns {number} Returns the sum.
  33244. * @example
  33245. *
  33246. * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];
  33247. *
  33248. * _.sumBy(objects, function(o) { return o.n; });
  33249. * // => 20
  33250. *
  33251. * // The `_.property` iteratee shorthand.
  33252. * _.sumBy(objects, 'n');
  33253. * // => 20
  33254. */
  33255. function sumBy(array, iteratee) {
  33256. return (array && array.length)
  33257. ? baseSum(array, getIteratee(iteratee, 2))
  33258. : 0;
  33259. }
  33260. /*------------------------------------------------------------------------*/
  33261. // Add methods that return wrapped values in chain sequences.
  33262. lodash.after = after;
  33263. lodash.ary = ary;
  33264. lodash.assign = assign;
  33265. lodash.assignIn = assignIn;
  33266. lodash.assignInWith = assignInWith;
  33267. lodash.assignWith = assignWith;
  33268. lodash.at = at;
  33269. lodash.before = before;
  33270. lodash.bind = bind;
  33271. lodash.bindAll = bindAll;
  33272. lodash.bindKey = bindKey;
  33273. lodash.castArray = castArray;
  33274. lodash.chain = chain;
  33275. lodash.chunk = chunk;
  33276. lodash.compact = compact;
  33277. lodash.concat = concat;
  33278. lodash.cond = cond;
  33279. lodash.conforms = conforms;
  33280. lodash.constant = constant;
  33281. lodash.countBy = countBy;
  33282. lodash.create = create;
  33283. lodash.curry = curry;
  33284. lodash.curryRight = curryRight;
  33285. lodash.debounce = debounce;
  33286. lodash.defaults = defaults;
  33287. lodash.defaultsDeep = defaultsDeep;
  33288. lodash.defer = defer;
  33289. lodash.delay = delay;
  33290. lodash.difference = difference;
  33291. lodash.differenceBy = differenceBy;
  33292. lodash.differenceWith = differenceWith;
  33293. lodash.drop = drop;
  33294. lodash.dropRight = dropRight;
  33295. lodash.dropRightWhile = dropRightWhile;
  33296. lodash.dropWhile = dropWhile;
  33297. lodash.fill = fill;
  33298. lodash.filter = filter;
  33299. lodash.flatMap = flatMap;
  33300. lodash.flatMapDeep = flatMapDeep;
  33301. lodash.flatMapDepth = flatMapDepth;
  33302. lodash.flatten = flatten;
  33303. lodash.flattenDeep = flattenDeep;
  33304. lodash.flattenDepth = flattenDepth;
  33305. lodash.flip = flip;
  33306. lodash.flow = flow;
  33307. lodash.flowRight = flowRight;
  33308. lodash.fromPairs = fromPairs;
  33309. lodash.functions = functions;
  33310. lodash.functionsIn = functionsIn;
  33311. lodash.groupBy = groupBy;
  33312. lodash.initial = initial;
  33313. lodash.intersection = intersection;
  33314. lodash.intersectionBy = intersectionBy;
  33315. lodash.intersectionWith = intersectionWith;
  33316. lodash.invert = invert;
  33317. lodash.invertBy = invertBy;
  33318. lodash.invokeMap = invokeMap;
  33319. lodash.iteratee = iteratee;
  33320. lodash.keyBy = keyBy;
  33321. lodash.keys = keys;
  33322. lodash.keysIn = keysIn;
  33323. lodash.map = map;
  33324. lodash.mapKeys = mapKeys;
  33325. lodash.mapValues = mapValues;
  33326. lodash.matches = matches;
  33327. lodash.matchesProperty = matchesProperty;
  33328. lodash.memoize = memoize;
  33329. lodash.merge = merge;
  33330. lodash.mergeWith = mergeWith;
  33331. lodash.method = method;
  33332. lodash.methodOf = methodOf;
  33333. lodash.mixin = mixin;
  33334. lodash.negate = negate;
  33335. lodash.nthArg = nthArg;
  33336. lodash.omit = omit;
  33337. lodash.omitBy = omitBy;
  33338. lodash.once = once;
  33339. lodash.orderBy = orderBy;
  33340. lodash.over = over;
  33341. lodash.overArgs = overArgs;
  33342. lodash.overEvery = overEvery;
  33343. lodash.overSome = overSome;
  33344. lodash.partial = partial;
  33345. lodash.partialRight = partialRight;
  33346. lodash.partition = partition;
  33347. lodash.pick = pick;
  33348. lodash.pickBy = pickBy;
  33349. lodash.property = property;
  33350. lodash.propertyOf = propertyOf;
  33351. lodash.pull = pull;
  33352. lodash.pullAll = pullAll;
  33353. lodash.pullAllBy = pullAllBy;
  33354. lodash.pullAllWith = pullAllWith;
  33355. lodash.pullAt = pullAt;
  33356. lodash.range = range;
  33357. lodash.rangeRight = rangeRight;
  33358. lodash.rearg = rearg;
  33359. lodash.reject = reject;
  33360. lodash.remove = remove;
  33361. lodash.rest = rest;
  33362. lodash.reverse = reverse;
  33363. lodash.sampleSize = sampleSize;
  33364. lodash.set = set;
  33365. lodash.setWith = setWith;
  33366. lodash.shuffle = shuffle;
  33367. lodash.slice = slice;
  33368. lodash.sortBy = sortBy;
  33369. lodash.sortedUniq = sortedUniq;
  33370. lodash.sortedUniqBy = sortedUniqBy;
  33371. lodash.split = split;
  33372. lodash.spread = spread;
  33373. lodash.tail = tail;
  33374. lodash.take = take;
  33375. lodash.takeRight = takeRight;
  33376. lodash.takeRightWhile = takeRightWhile;
  33377. lodash.takeWhile = takeWhile;
  33378. lodash.tap = tap;
  33379. lodash.throttle = throttle;
  33380. lodash.thru = thru;
  33381. lodash.toArray = toArray;
  33382. lodash.toPairs = toPairs;
  33383. lodash.toPairsIn = toPairsIn;
  33384. lodash.toPath = toPath;
  33385. lodash.toPlainObject = toPlainObject;
  33386. lodash.transform = transform;
  33387. lodash.unary = unary;
  33388. lodash.union = union;
  33389. lodash.unionBy = unionBy;
  33390. lodash.unionWith = unionWith;
  33391. lodash.uniq = uniq;
  33392. lodash.uniqBy = uniqBy;
  33393. lodash.uniqWith = uniqWith;
  33394. lodash.unset = unset;
  33395. lodash.unzip = unzip;
  33396. lodash.unzipWith = unzipWith;
  33397. lodash.update = update;
  33398. lodash.updateWith = updateWith;
  33399. lodash.values = values;
  33400. lodash.valuesIn = valuesIn;
  33401. lodash.without = without;
  33402. lodash.words = words;
  33403. lodash.wrap = wrap;
  33404. lodash.xor = xor;
  33405. lodash.xorBy = xorBy;
  33406. lodash.xorWith = xorWith;
  33407. lodash.zip = zip;
  33408. lodash.zipObject = zipObject;
  33409. lodash.zipObjectDeep = zipObjectDeep;
  33410. lodash.zipWith = zipWith;
  33411. // Add aliases.
  33412. lodash.entries = toPairs;
  33413. lodash.entriesIn = toPairsIn;
  33414. lodash.extend = assignIn;
  33415. lodash.extendWith = assignInWith;
  33416. // Add methods to `lodash.prototype`.
  33417. mixin(lodash, lodash);
  33418. /*------------------------------------------------------------------------*/
  33419. // Add methods that return unwrapped values in chain sequences.
  33420. lodash.add = add;
  33421. lodash.attempt = attempt;
  33422. lodash.camelCase = camelCase;
  33423. lodash.capitalize = capitalize;
  33424. lodash.ceil = ceil;
  33425. lodash.clamp = clamp;
  33426. lodash.clone = clone;
  33427. lodash.cloneDeep = cloneDeep;
  33428. lodash.cloneDeepWith = cloneDeepWith;
  33429. lodash.cloneWith = cloneWith;
  33430. lodash.conformsTo = conformsTo;
  33431. lodash.deburr = deburr;
  33432. lodash.defaultTo = defaultTo;
  33433. lodash.divide = divide;
  33434. lodash.endsWith = endsWith;
  33435. lodash.eq = eq;
  33436. lodash.escape = escape;
  33437. lodash.escapeRegExp = escapeRegExp;
  33438. lodash.every = every;
  33439. lodash.find = find;
  33440. lodash.findIndex = findIndex;
  33441. lodash.findKey = findKey;
  33442. lodash.findLast = findLast;
  33443. lodash.findLastIndex = findLastIndex;
  33444. lodash.findLastKey = findLastKey;
  33445. lodash.floor = floor;
  33446. lodash.forEach = forEach;
  33447. lodash.forEachRight = forEachRight;
  33448. lodash.forIn = forIn;
  33449. lodash.forInRight = forInRight;
  33450. lodash.forOwn = forOwn;
  33451. lodash.forOwnRight = forOwnRight;
  33452. lodash.get = get;
  33453. lodash.gt = gt;
  33454. lodash.gte = gte;
  33455. lodash.has = has;
  33456. lodash.hasIn = hasIn;
  33457. lodash.head = head;
  33458. lodash.identity = identity;
  33459. lodash.includes = includes;
  33460. lodash.indexOf = indexOf;
  33461. lodash.inRange = inRange;
  33462. lodash.invoke = invoke;
  33463. lodash.isArguments = isArguments;
  33464. lodash.isArray = isArray;
  33465. lodash.isArrayBuffer = isArrayBuffer;
  33466. lodash.isArrayLike = isArrayLike;
  33467. lodash.isArrayLikeObject = isArrayLikeObject;
  33468. lodash.isBoolean = isBoolean;
  33469. lodash.isBuffer = isBuffer;
  33470. lodash.isDate = isDate;
  33471. lodash.isElement = isElement;
  33472. lodash.isEmpty = isEmpty;
  33473. lodash.isEqual = isEqual;
  33474. lodash.isEqualWith = isEqualWith;
  33475. lodash.isError = isError;
  33476. lodash.isFinite = isFinite;
  33477. lodash.isFunction = isFunction;
  33478. lodash.isInteger = isInteger;
  33479. lodash.isLength = isLength;
  33480. lodash.isMap = isMap;
  33481. lodash.isMatch = isMatch;
  33482. lodash.isMatchWith = isMatchWith;
  33483. lodash.isNaN = isNaN;
  33484. lodash.isNative = isNative;
  33485. lodash.isNil = isNil;
  33486. lodash.isNull = isNull;
  33487. lodash.isNumber = isNumber;
  33488. lodash.isObject = isObject;
  33489. lodash.isObjectLike = isObjectLike;
  33490. lodash.isPlainObject = isPlainObject;
  33491. lodash.isRegExp = isRegExp;
  33492. lodash.isSafeInteger = isSafeInteger;
  33493. lodash.isSet = isSet;
  33494. lodash.isString = isString;
  33495. lodash.isSymbol = isSymbol;
  33496. lodash.isTypedArray = isTypedArray;
  33497. lodash.isUndefined = isUndefined;
  33498. lodash.isWeakMap = isWeakMap;
  33499. lodash.isWeakSet = isWeakSet;
  33500. lodash.join = join;
  33501. lodash.kebabCase = kebabCase;
  33502. lodash.last = last;
  33503. lodash.lastIndexOf = lastIndexOf;
  33504. lodash.lowerCase = lowerCase;
  33505. lodash.lowerFirst = lowerFirst;
  33506. lodash.lt = lt;
  33507. lodash.lte = lte;
  33508. lodash.max = max;
  33509. lodash.maxBy = maxBy;
  33510. lodash.mean = mean;
  33511. lodash.meanBy = meanBy;
  33512. lodash.min = min;
  33513. lodash.minBy = minBy;
  33514. lodash.stubArray = stubArray;
  33515. lodash.stubFalse = stubFalse;
  33516. lodash.stubObject = stubObject;
  33517. lodash.stubString = stubString;
  33518. lodash.stubTrue = stubTrue;
  33519. lodash.multiply = multiply;
  33520. lodash.nth = nth;
  33521. lodash.noConflict = noConflict;
  33522. lodash.noop = noop;
  33523. lodash.now = now;
  33524. lodash.pad = pad;
  33525. lodash.padEnd = padEnd;
  33526. lodash.padStart = padStart;
  33527. lodash.parseInt = parseInt;
  33528. lodash.random = random;
  33529. lodash.reduce = reduce;
  33530. lodash.reduceRight = reduceRight;
  33531. lodash.repeat = repeat;
  33532. lodash.replace = replace;
  33533. lodash.result = result;
  33534. lodash.round = round;
  33535. lodash.runInContext = runInContext;
  33536. lodash.sample = sample;
  33537. lodash.size = size;
  33538. lodash.snakeCase = snakeCase;
  33539. lodash.some = some;
  33540. lodash.sortedIndex = sortedIndex;
  33541. lodash.sortedIndexBy = sortedIndexBy;
  33542. lodash.sortedIndexOf = sortedIndexOf;
  33543. lodash.sortedLastIndex = sortedLastIndex;
  33544. lodash.sortedLastIndexBy = sortedLastIndexBy;
  33545. lodash.sortedLastIndexOf = sortedLastIndexOf;
  33546. lodash.startCase = startCase;
  33547. lodash.startsWith = startsWith;
  33548. lodash.subtract = subtract;
  33549. lodash.sum = sum;
  33550. lodash.sumBy = sumBy;
  33551. lodash.template = template;
  33552. lodash.times = times;
  33553. lodash.toFinite = toFinite;
  33554. lodash.toInteger = toInteger;
  33555. lodash.toLength = toLength;
  33556. lodash.toLower = toLower;
  33557. lodash.toNumber = toNumber;
  33558. lodash.toSafeInteger = toSafeInteger;
  33559. lodash.toString = toString;
  33560. lodash.toUpper = toUpper;
  33561. lodash.trim = trim;
  33562. lodash.trimEnd = trimEnd;
  33563. lodash.trimStart = trimStart;
  33564. lodash.truncate = truncate;
  33565. lodash.unescape = unescape;
  33566. lodash.uniqueId = uniqueId;
  33567. lodash.upperCase = upperCase;
  33568. lodash.upperFirst = upperFirst;
  33569. // Add aliases.
  33570. lodash.each = forEach;
  33571. lodash.eachRight = forEachRight;
  33572. lodash.first = head;
  33573. mixin(lodash, (function() {
  33574. var source = {};
  33575. baseForOwn(lodash, function(func, methodName) {
  33576. if (!hasOwnProperty.call(lodash.prototype, methodName)) {
  33577. source[methodName] = func;
  33578. }
  33579. });
  33580. return source;
  33581. }()), { 'chain': false });
  33582. /*------------------------------------------------------------------------*/
  33583. /**
  33584. * The semantic version number.
  33585. *
  33586. * @static
  33587. * @memberOf _
  33588. * @type {string}
  33589. */
  33590. lodash.VERSION = VERSION;
  33591. // Assign default placeholders.
  33592. arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
  33593. lodash[methodName].placeholder = lodash;
  33594. });
  33595. // Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
  33596. arrayEach(['drop', 'take'], function(methodName, index) {
  33597. LazyWrapper.prototype[methodName] = function(n) {
  33598. n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
  33599. var result = (this.__filtered__ && !index)
  33600. ? new LazyWrapper(this)
  33601. : this.clone();
  33602. if (result.__filtered__) {
  33603. result.__takeCount__ = nativeMin(n, result.__takeCount__);
  33604. } else {
  33605. result.__views__.push({
  33606. 'size': nativeMin(n, MAX_ARRAY_LENGTH),
  33607. 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
  33608. });
  33609. }
  33610. return result;
  33611. };
  33612. LazyWrapper.prototype[methodName + 'Right'] = function(n) {
  33613. return this.reverse()[methodName](n).reverse();
  33614. };
  33615. });
  33616. // Add `LazyWrapper` methods that accept an `iteratee` value.
  33617. arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
  33618. var type = index + 1,
  33619. isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
  33620. LazyWrapper.prototype[methodName] = function(iteratee) {
  33621. var result = this.clone();
  33622. result.__iteratees__.push({
  33623. 'iteratee': getIteratee(iteratee, 3),
  33624. 'type': type
  33625. });
  33626. result.__filtered__ = result.__filtered__ || isFilter;
  33627. return result;
  33628. };
  33629. });
  33630. // Add `LazyWrapper` methods for `_.head` and `_.last`.
  33631. arrayEach(['head', 'last'], function(methodName, index) {
  33632. var takeName = 'take' + (index ? 'Right' : '');
  33633. LazyWrapper.prototype[methodName] = function() {
  33634. return this[takeName](1).value()[0];
  33635. };
  33636. });
  33637. // Add `LazyWrapper` methods for `_.initial` and `_.tail`.
  33638. arrayEach(['initial', 'tail'], function(methodName, index) {
  33639. var dropName = 'drop' + (index ? '' : 'Right');
  33640. LazyWrapper.prototype[methodName] = function() {
  33641. return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
  33642. };
  33643. });
  33644. LazyWrapper.prototype.compact = function() {
  33645. return this.filter(identity);
  33646. };
  33647. LazyWrapper.prototype.find = function(predicate) {
  33648. return this.filter(predicate).head();
  33649. };
  33650. LazyWrapper.prototype.findLast = function(predicate) {
  33651. return this.reverse().find(predicate);
  33652. };
  33653. LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
  33654. if (typeof path == 'function') {
  33655. return new LazyWrapper(this);
  33656. }
  33657. return this.map(function(value) {
  33658. return baseInvoke(value, path, args);
  33659. });
  33660. });
  33661. LazyWrapper.prototype.reject = function(predicate) {
  33662. return this.filter(negate(getIteratee(predicate)));
  33663. };
  33664. LazyWrapper.prototype.slice = function(start, end) {
  33665. start = toInteger(start);
  33666. var result = this;
  33667. if (result.__filtered__ && (start > 0 || end < 0)) {
  33668. return new LazyWrapper(result);
  33669. }
  33670. if (start < 0) {
  33671. result = result.takeRight(-start);
  33672. } else if (start) {
  33673. result = result.drop(start);
  33674. }
  33675. if (end !== undefined) {
  33676. end = toInteger(end);
  33677. result = end < 0 ? result.dropRight(-end) : result.take(end - start);
  33678. }
  33679. return result;
  33680. };
  33681. LazyWrapper.prototype.takeRightWhile = function(predicate) {
  33682. return this.reverse().takeWhile(predicate).reverse();
  33683. };
  33684. LazyWrapper.prototype.toArray = function() {
  33685. return this.take(MAX_ARRAY_LENGTH);
  33686. };
  33687. // Add `LazyWrapper` methods to `lodash.prototype`.
  33688. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  33689. var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
  33690. isTaker = /^(?:head|last)$/.test(methodName),
  33691. lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
  33692. retUnwrapped = isTaker || /^find/.test(methodName);
  33693. if (!lodashFunc) {
  33694. return;
  33695. }
  33696. lodash.prototype[methodName] = function() {
  33697. var value = this.__wrapped__,
  33698. args = isTaker ? [1] : arguments,
  33699. isLazy = value instanceof LazyWrapper,
  33700. iteratee = args[0],
  33701. useLazy = isLazy || isArray(value);
  33702. var interceptor = function(value) {
  33703. var result = lodashFunc.apply(lodash, arrayPush([value], args));
  33704. return (isTaker && chainAll) ? result[0] : result;
  33705. };
  33706. if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) {
  33707. // Avoid lazy use if the iteratee has a "length" value other than `1`.
  33708. isLazy = useLazy = false;
  33709. }
  33710. var chainAll = this.__chain__,
  33711. isHybrid = !!this.__actions__.length,
  33712. isUnwrapped = retUnwrapped && !chainAll,
  33713. onlyLazy = isLazy && !isHybrid;
  33714. if (!retUnwrapped && useLazy) {
  33715. value = onlyLazy ? value : new LazyWrapper(this);
  33716. var result = func.apply(value, args);
  33717. result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
  33718. return new LodashWrapper(result, chainAll);
  33719. }
  33720. if (isUnwrapped && onlyLazy) {
  33721. return func.apply(this, args);
  33722. }
  33723. result = this.thru(interceptor);
  33724. return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result;
  33725. };
  33726. });
  33727. // Add `Array` methods to `lodash.prototype`.
  33728. arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
  33729. var func = arrayProto[methodName],
  33730. chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
  33731. retUnwrapped = /^(?:pop|shift)$/.test(methodName);
  33732. lodash.prototype[methodName] = function() {
  33733. var args = arguments;
  33734. if (retUnwrapped && !this.__chain__) {
  33735. var value = this.value();
  33736. return func.apply(isArray(value) ? value : [], args);
  33737. }
  33738. return this[chainName](function(value) {
  33739. return func.apply(isArray(value) ? value : [], args);
  33740. });
  33741. };
  33742. });
  33743. // Map minified method names to their real names.
  33744. baseForOwn(LazyWrapper.prototype, function(func, methodName) {
  33745. var lodashFunc = lodash[methodName];
  33746. if (lodashFunc) {
  33747. var key = lodashFunc.name + '';
  33748. if (!hasOwnProperty.call(realNames, key)) {
  33749. realNames[key] = [];
  33750. }
  33751. realNames[key].push({ 'name': methodName, 'func': lodashFunc });
  33752. }
  33753. });
  33754. realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
  33755. 'name': 'wrapper',
  33756. 'func': undefined
  33757. }];
  33758. // Add methods to `LazyWrapper`.
  33759. LazyWrapper.prototype.clone = lazyClone;
  33760. LazyWrapper.prototype.reverse = lazyReverse;
  33761. LazyWrapper.prototype.value = lazyValue;
  33762. // Add chain sequence methods to the `lodash` wrapper.
  33763. lodash.prototype.at = wrapperAt;
  33764. lodash.prototype.chain = wrapperChain;
  33765. lodash.prototype.commit = wrapperCommit;
  33766. lodash.prototype.next = wrapperNext;
  33767. lodash.prototype.plant = wrapperPlant;
  33768. lodash.prototype.reverse = wrapperReverse;
  33769. lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
  33770. // Add lazy aliases.
  33771. lodash.prototype.first = lodash.prototype.head;
  33772. if (symIterator) {
  33773. lodash.prototype[symIterator] = wrapperToIterator;
  33774. }
  33775. return lodash;
  33776. });
  33777. /*--------------------------------------------------------------------------*/
  33778. // Export lodash.
  33779. var _ = runInContext();
  33780. // Some AMD build optimizers, like r.js, check for condition patterns like:
  33781. if (true) {
  33782. // Expose Lodash on the global object to prevent errors when Lodash is
  33783. // loaded by a script tag in the presence of an AMD loader.
  33784. // See http://requirejs.org/docs/errors.html#mismatch for more details.
  33785. // Use `_.noConflict` to remove Lodash from the global object.
  33786. root._ = _;
  33787. // Define as an anonymous module so, through path mapping, it can be
  33788. // referenced as the "underscore" module.
  33789. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  33790. return _;
  33791. }).call(exports, __webpack_require__, exports, module),
  33792. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  33793. }
  33794. // Check for `exports` after `define` in case a build optimizer adds it.
  33795. else {}
  33796. }.call(this));
  33797. /* 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)))
  33798. /***/ }),
  33799. /***/ "./node_modules/popper.js/dist/esm/popper.js":
  33800. /*!***************************************************!*\
  33801. !*** ./node_modules/popper.js/dist/esm/popper.js ***!
  33802. \***************************************************/
  33803. /*! exports provided: default */
  33804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33805. "use strict";
  33806. __webpack_require__.r(__webpack_exports__);
  33807. /* WEBPACK VAR INJECTION */(function(global) {/**!
  33808. * @fileOverview Kickass library to create and place poppers near their reference elements.
  33809. * @version 1.16.1
  33810. * @license
  33811. * Copyright (c) 2016 Federico Zivolo and contributors
  33812. *
  33813. * Permission is hereby granted, free of charge, to any person obtaining a copy
  33814. * of this software and associated documentation files (the "Software"), to deal
  33815. * in the Software without restriction, including without limitation the rights
  33816. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  33817. * copies of the Software, and to permit persons to whom the Software is
  33818. * furnished to do so, subject to the following conditions:
  33819. *
  33820. * The above copyright notice and this permission notice shall be included in all
  33821. * copies or substantial portions of the Software.
  33822. *
  33823. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  33824. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  33825. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  33826. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  33827. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  33828. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  33829. * SOFTWARE.
  33830. */
  33831. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof navigator !== 'undefined';
  33832. var timeoutDuration = function () {
  33833. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  33834. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  33835. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  33836. return 1;
  33837. }
  33838. }
  33839. return 0;
  33840. }();
  33841. function microtaskDebounce(fn) {
  33842. var called = false;
  33843. return function () {
  33844. if (called) {
  33845. return;
  33846. }
  33847. called = true;
  33848. window.Promise.resolve().then(function () {
  33849. called = false;
  33850. fn();
  33851. });
  33852. };
  33853. }
  33854. function taskDebounce(fn) {
  33855. var scheduled = false;
  33856. return function () {
  33857. if (!scheduled) {
  33858. scheduled = true;
  33859. setTimeout(function () {
  33860. scheduled = false;
  33861. fn();
  33862. }, timeoutDuration);
  33863. }
  33864. };
  33865. }
  33866. var supportsMicroTasks = isBrowser && window.Promise;
  33867. /**
  33868. * Create a debounced version of a method, that's asynchronously deferred
  33869. * but called in the minimum time possible.
  33870. *
  33871. * @method
  33872. * @memberof Popper.Utils
  33873. * @argument {Function} fn
  33874. * @returns {Function}
  33875. */
  33876. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  33877. /**
  33878. * Check if the given variable is a function
  33879. * @method
  33880. * @memberof Popper.Utils
  33881. * @argument {Any} functionToCheck - variable to check
  33882. * @returns {Boolean} answer to: is a function?
  33883. */
  33884. function isFunction(functionToCheck) {
  33885. var getType = {};
  33886. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  33887. }
  33888. /**
  33889. * Get CSS computed property of the given element
  33890. * @method
  33891. * @memberof Popper.Utils
  33892. * @argument {Eement} element
  33893. * @argument {String} property
  33894. */
  33895. function getStyleComputedProperty(element, property) {
  33896. if (element.nodeType !== 1) {
  33897. return [];
  33898. }
  33899. // NOTE: 1 DOM access here
  33900. var window = element.ownerDocument.defaultView;
  33901. var css = window.getComputedStyle(element, null);
  33902. return property ? css[property] : css;
  33903. }
  33904. /**
  33905. * Returns the parentNode or the host of the element
  33906. * @method
  33907. * @memberof Popper.Utils
  33908. * @argument {Element} element
  33909. * @returns {Element} parent
  33910. */
  33911. function getParentNode(element) {
  33912. if (element.nodeName === 'HTML') {
  33913. return element;
  33914. }
  33915. return element.parentNode || element.host;
  33916. }
  33917. /**
  33918. * Returns the scrolling parent of the given element
  33919. * @method
  33920. * @memberof Popper.Utils
  33921. * @argument {Element} element
  33922. * @returns {Element} scroll parent
  33923. */
  33924. function getScrollParent(element) {
  33925. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  33926. if (!element) {
  33927. return document.body;
  33928. }
  33929. switch (element.nodeName) {
  33930. case 'HTML':
  33931. case 'BODY':
  33932. return element.ownerDocument.body;
  33933. case '#document':
  33934. return element.body;
  33935. }
  33936. // Firefox want us to check `-x` and `-y` variations as well
  33937. var _getStyleComputedProp = getStyleComputedProperty(element),
  33938. overflow = _getStyleComputedProp.overflow,
  33939. overflowX = _getStyleComputedProp.overflowX,
  33940. overflowY = _getStyleComputedProp.overflowY;
  33941. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  33942. return element;
  33943. }
  33944. return getScrollParent(getParentNode(element));
  33945. }
  33946. /**
  33947. * Returns the reference node of the reference object, or the reference object itself.
  33948. * @method
  33949. * @memberof Popper.Utils
  33950. * @param {Element|Object} reference - the reference element (the popper will be relative to this)
  33951. * @returns {Element} parent
  33952. */
  33953. function getReferenceNode(reference) {
  33954. return reference && reference.referenceNode ? reference.referenceNode : reference;
  33955. }
  33956. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  33957. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  33958. /**
  33959. * Determines if the browser is Internet Explorer
  33960. * @method
  33961. * @memberof Popper.Utils
  33962. * @param {Number} version to check
  33963. * @returns {Boolean} isIE
  33964. */
  33965. function isIE(version) {
  33966. if (version === 11) {
  33967. return isIE11;
  33968. }
  33969. if (version === 10) {
  33970. return isIE10;
  33971. }
  33972. return isIE11 || isIE10;
  33973. }
  33974. /**
  33975. * Returns the offset parent of the given element
  33976. * @method
  33977. * @memberof Popper.Utils
  33978. * @argument {Element} element
  33979. * @returns {Element} offset parent
  33980. */
  33981. function getOffsetParent(element) {
  33982. if (!element) {
  33983. return document.documentElement;
  33984. }
  33985. var noOffsetParent = isIE(10) ? document.body : null;
  33986. // NOTE: 1 DOM access here
  33987. var offsetParent = element.offsetParent || null;
  33988. // Skip hidden elements which don't have an offsetParent
  33989. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  33990. offsetParent = (element = element.nextElementSibling).offsetParent;
  33991. }
  33992. var nodeName = offsetParent && offsetParent.nodeName;
  33993. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  33994. return element ? element.ownerDocument.documentElement : document.documentElement;
  33995. }
  33996. // .offsetParent will return the closest TH, TD or TABLE in case
  33997. // no offsetParent is present, I hate this job...
  33998. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  33999. return getOffsetParent(offsetParent);
  34000. }
  34001. return offsetParent;
  34002. }
  34003. function isOffsetContainer(element) {
  34004. var nodeName = element.nodeName;
  34005. if (nodeName === 'BODY') {
  34006. return false;
  34007. }
  34008. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  34009. }
  34010. /**
  34011. * Finds the root node (document, shadowDOM root) of the given element
  34012. * @method
  34013. * @memberof Popper.Utils
  34014. * @argument {Element} node
  34015. * @returns {Element} root node
  34016. */
  34017. function getRoot(node) {
  34018. if (node.parentNode !== null) {
  34019. return getRoot(node.parentNode);
  34020. }
  34021. return node;
  34022. }
  34023. /**
  34024. * Finds the offset parent common to the two provided nodes
  34025. * @method
  34026. * @memberof Popper.Utils
  34027. * @argument {Element} element1
  34028. * @argument {Element} element2
  34029. * @returns {Element} common offset parent
  34030. */
  34031. function findCommonOffsetParent(element1, element2) {
  34032. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  34033. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  34034. return document.documentElement;
  34035. }
  34036. // Here we make sure to give as "start" the element that comes first in the DOM
  34037. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  34038. var start = order ? element1 : element2;
  34039. var end = order ? element2 : element1;
  34040. // Get common ancestor container
  34041. var range = document.createRange();
  34042. range.setStart(start, 0);
  34043. range.setEnd(end, 0);
  34044. var commonAncestorContainer = range.commonAncestorContainer;
  34045. // Both nodes are inside #document
  34046. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  34047. if (isOffsetContainer(commonAncestorContainer)) {
  34048. return commonAncestorContainer;
  34049. }
  34050. return getOffsetParent(commonAncestorContainer);
  34051. }
  34052. // one of the nodes is inside shadowDOM, find which one
  34053. var element1root = getRoot(element1);
  34054. if (element1root.host) {
  34055. return findCommonOffsetParent(element1root.host, element2);
  34056. } else {
  34057. return findCommonOffsetParent(element1, getRoot(element2).host);
  34058. }
  34059. }
  34060. /**
  34061. * Gets the scroll value of the given element in the given side (top and left)
  34062. * @method
  34063. * @memberof Popper.Utils
  34064. * @argument {Element} element
  34065. * @argument {String} side `top` or `left`
  34066. * @returns {number} amount of scrolled pixels
  34067. */
  34068. function getScroll(element) {
  34069. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  34070. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  34071. var nodeName = element.nodeName;
  34072. if (nodeName === 'BODY' || nodeName === 'HTML') {
  34073. var html = element.ownerDocument.documentElement;
  34074. var scrollingElement = element.ownerDocument.scrollingElement || html;
  34075. return scrollingElement[upperSide];
  34076. }
  34077. return element[upperSide];
  34078. }
  34079. /*
  34080. * Sum or subtract the element scroll values (left and top) from a given rect object
  34081. * @method
  34082. * @memberof Popper.Utils
  34083. * @param {Object} rect - Rect object you want to change
  34084. * @param {HTMLElement} element - The element from the function reads the scroll values
  34085. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  34086. * @return {Object} rect - The modifier rect object
  34087. */
  34088. function includeScroll(rect, element) {
  34089. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  34090. var scrollTop = getScroll(element, 'top');
  34091. var scrollLeft = getScroll(element, 'left');
  34092. var modifier = subtract ? -1 : 1;
  34093. rect.top += scrollTop * modifier;
  34094. rect.bottom += scrollTop * modifier;
  34095. rect.left += scrollLeft * modifier;
  34096. rect.right += scrollLeft * modifier;
  34097. return rect;
  34098. }
  34099. /*
  34100. * Helper to detect borders of a given element
  34101. * @method
  34102. * @memberof Popper.Utils
  34103. * @param {CSSStyleDeclaration} styles
  34104. * Result of `getStyleComputedProperty` on the given element
  34105. * @param {String} axis - `x` or `y`
  34106. * @return {number} borders - The borders size of the given axis
  34107. */
  34108. function getBordersSize(styles, axis) {
  34109. var sideA = axis === 'x' ? 'Left' : 'Top';
  34110. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  34111. return parseFloat(styles['border' + sideA + 'Width']) + parseFloat(styles['border' + sideB + 'Width']);
  34112. }
  34113. function getSize(axis, body, html, computedStyle) {
  34114. 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);
  34115. }
  34116. function getWindowSizes(document) {
  34117. var body = document.body;
  34118. var html = document.documentElement;
  34119. var computedStyle = isIE(10) && getComputedStyle(html);
  34120. return {
  34121. height: getSize('Height', body, html, computedStyle),
  34122. width: getSize('Width', body, html, computedStyle)
  34123. };
  34124. }
  34125. var classCallCheck = function (instance, Constructor) {
  34126. if (!(instance instanceof Constructor)) {
  34127. throw new TypeError("Cannot call a class as a function");
  34128. }
  34129. };
  34130. var createClass = function () {
  34131. function defineProperties(target, props) {
  34132. for (var i = 0; i < props.length; i++) {
  34133. var descriptor = props[i];
  34134. descriptor.enumerable = descriptor.enumerable || false;
  34135. descriptor.configurable = true;
  34136. if ("value" in descriptor) descriptor.writable = true;
  34137. Object.defineProperty(target, descriptor.key, descriptor);
  34138. }
  34139. }
  34140. return function (Constructor, protoProps, staticProps) {
  34141. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  34142. if (staticProps) defineProperties(Constructor, staticProps);
  34143. return Constructor;
  34144. };
  34145. }();
  34146. var defineProperty = function (obj, key, value) {
  34147. if (key in obj) {
  34148. Object.defineProperty(obj, key, {
  34149. value: value,
  34150. enumerable: true,
  34151. configurable: true,
  34152. writable: true
  34153. });
  34154. } else {
  34155. obj[key] = value;
  34156. }
  34157. return obj;
  34158. };
  34159. var _extends = Object.assign || function (target) {
  34160. for (var i = 1; i < arguments.length; i++) {
  34161. var source = arguments[i];
  34162. for (var key in source) {
  34163. if (Object.prototype.hasOwnProperty.call(source, key)) {
  34164. target[key] = source[key];
  34165. }
  34166. }
  34167. }
  34168. return target;
  34169. };
  34170. /**
  34171. * Given element offsets, generate an output similar to getBoundingClientRect
  34172. * @method
  34173. * @memberof Popper.Utils
  34174. * @argument {Object} offsets
  34175. * @returns {Object} ClientRect like output
  34176. */
  34177. function getClientRect(offsets) {
  34178. return _extends({}, offsets, {
  34179. right: offsets.left + offsets.width,
  34180. bottom: offsets.top + offsets.height
  34181. });
  34182. }
  34183. /**
  34184. * Get bounding client rect of given element
  34185. * @method
  34186. * @memberof Popper.Utils
  34187. * @param {HTMLElement} element
  34188. * @return {Object} client rect
  34189. */
  34190. function getBoundingClientRect(element) {
  34191. var rect = {};
  34192. // IE10 10 FIX: Please, don't ask, the element isn't
  34193. // considered in DOM in some circumstances...
  34194. // This isn't reproducible in IE10 compatibility mode of IE11
  34195. try {
  34196. if (isIE(10)) {
  34197. rect = element.getBoundingClientRect();
  34198. var scrollTop = getScroll(element, 'top');
  34199. var scrollLeft = getScroll(element, 'left');
  34200. rect.top += scrollTop;
  34201. rect.left += scrollLeft;
  34202. rect.bottom += scrollTop;
  34203. rect.right += scrollLeft;
  34204. } else {
  34205. rect = element.getBoundingClientRect();
  34206. }
  34207. } catch (e) {}
  34208. var result = {
  34209. left: rect.left,
  34210. top: rect.top,
  34211. width: rect.right - rect.left,
  34212. height: rect.bottom - rect.top
  34213. };
  34214. // subtract scrollbar size from sizes
  34215. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  34216. var width = sizes.width || element.clientWidth || result.width;
  34217. var height = sizes.height || element.clientHeight || result.height;
  34218. var horizScrollbar = element.offsetWidth - width;
  34219. var vertScrollbar = element.offsetHeight - height;
  34220. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  34221. // we make this check conditional for performance reasons
  34222. if (horizScrollbar || vertScrollbar) {
  34223. var styles = getStyleComputedProperty(element);
  34224. horizScrollbar -= getBordersSize(styles, 'x');
  34225. vertScrollbar -= getBordersSize(styles, 'y');
  34226. result.width -= horizScrollbar;
  34227. result.height -= vertScrollbar;
  34228. }
  34229. return getClientRect(result);
  34230. }
  34231. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  34232. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  34233. var isIE10 = isIE(10);
  34234. var isHTML = parent.nodeName === 'HTML';
  34235. var childrenRect = getBoundingClientRect(children);
  34236. var parentRect = getBoundingClientRect(parent);
  34237. var scrollParent = getScrollParent(children);
  34238. var styles = getStyleComputedProperty(parent);
  34239. var borderTopWidth = parseFloat(styles.borderTopWidth);
  34240. var borderLeftWidth = parseFloat(styles.borderLeftWidth);
  34241. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  34242. if (fixedPosition && isHTML) {
  34243. parentRect.top = Math.max(parentRect.top, 0);
  34244. parentRect.left = Math.max(parentRect.left, 0);
  34245. }
  34246. var offsets = getClientRect({
  34247. top: childrenRect.top - parentRect.top - borderTopWidth,
  34248. left: childrenRect.left - parentRect.left - borderLeftWidth,
  34249. width: childrenRect.width,
  34250. height: childrenRect.height
  34251. });
  34252. offsets.marginTop = 0;
  34253. offsets.marginLeft = 0;
  34254. // Subtract margins of documentElement in case it's being used as parent
  34255. // we do this only on HTML because it's the only element that behaves
  34256. // differently when margins are applied to it. The margins are included in
  34257. // the box of the documentElement, in the other cases not.
  34258. if (!isIE10 && isHTML) {
  34259. var marginTop = parseFloat(styles.marginTop);
  34260. var marginLeft = parseFloat(styles.marginLeft);
  34261. offsets.top -= borderTopWidth - marginTop;
  34262. offsets.bottom -= borderTopWidth - marginTop;
  34263. offsets.left -= borderLeftWidth - marginLeft;
  34264. offsets.right -= borderLeftWidth - marginLeft;
  34265. // Attach marginTop and marginLeft because in some circumstances we may need them
  34266. offsets.marginTop = marginTop;
  34267. offsets.marginLeft = marginLeft;
  34268. }
  34269. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  34270. offsets = includeScroll(offsets, parent);
  34271. }
  34272. return offsets;
  34273. }
  34274. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  34275. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  34276. var html = element.ownerDocument.documentElement;
  34277. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  34278. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  34279. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  34280. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  34281. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  34282. var offset = {
  34283. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  34284. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  34285. width: width,
  34286. height: height
  34287. };
  34288. return getClientRect(offset);
  34289. }
  34290. /**
  34291. * Check if the given element is fixed or is inside a fixed parent
  34292. * @method
  34293. * @memberof Popper.Utils
  34294. * @argument {Element} element
  34295. * @argument {Element} customContainer
  34296. * @returns {Boolean} answer to "isFixed?"
  34297. */
  34298. function isFixed(element) {
  34299. var nodeName = element.nodeName;
  34300. if (nodeName === 'BODY' || nodeName === 'HTML') {
  34301. return false;
  34302. }
  34303. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  34304. return true;
  34305. }
  34306. var parentNode = getParentNode(element);
  34307. if (!parentNode) {
  34308. return false;
  34309. }
  34310. return isFixed(parentNode);
  34311. }
  34312. /**
  34313. * Finds the first parent of an element that has a transformed property defined
  34314. * @method
  34315. * @memberof Popper.Utils
  34316. * @argument {Element} element
  34317. * @returns {Element} first transformed parent or documentElement
  34318. */
  34319. function getFixedPositionOffsetParent(element) {
  34320. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  34321. if (!element || !element.parentElement || isIE()) {
  34322. return document.documentElement;
  34323. }
  34324. var el = element.parentElement;
  34325. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  34326. el = el.parentElement;
  34327. }
  34328. return el || document.documentElement;
  34329. }
  34330. /**
  34331. * Computed the boundaries limits and return them
  34332. * @method
  34333. * @memberof Popper.Utils
  34334. * @param {HTMLElement} popper
  34335. * @param {HTMLElement} reference
  34336. * @param {number} padding
  34337. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  34338. * @param {Boolean} fixedPosition - Is in fixed position mode
  34339. * @returns {Object} Coordinates of the boundaries
  34340. */
  34341. function getBoundaries(popper, reference, padding, boundariesElement) {
  34342. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  34343. // NOTE: 1 DOM access here
  34344. var boundaries = { top: 0, left: 0 };
  34345. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  34346. // Handle viewport case
  34347. if (boundariesElement === 'viewport') {
  34348. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  34349. } else {
  34350. // Handle other cases based on DOM element used as boundaries
  34351. var boundariesNode = void 0;
  34352. if (boundariesElement === 'scrollParent') {
  34353. boundariesNode = getScrollParent(getParentNode(reference));
  34354. if (boundariesNode.nodeName === 'BODY') {
  34355. boundariesNode = popper.ownerDocument.documentElement;
  34356. }
  34357. } else if (boundariesElement === 'window') {
  34358. boundariesNode = popper.ownerDocument.documentElement;
  34359. } else {
  34360. boundariesNode = boundariesElement;
  34361. }
  34362. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  34363. // In case of HTML, we need a different computation
  34364. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  34365. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  34366. height = _getWindowSizes.height,
  34367. width = _getWindowSizes.width;
  34368. boundaries.top += offsets.top - offsets.marginTop;
  34369. boundaries.bottom = height + offsets.top;
  34370. boundaries.left += offsets.left - offsets.marginLeft;
  34371. boundaries.right = width + offsets.left;
  34372. } else {
  34373. // for all the other DOM elements, this one is good
  34374. boundaries = offsets;
  34375. }
  34376. }
  34377. // Add paddings
  34378. padding = padding || 0;
  34379. var isPaddingNumber = typeof padding === 'number';
  34380. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  34381. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  34382. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  34383. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  34384. return boundaries;
  34385. }
  34386. function getArea(_ref) {
  34387. var width = _ref.width,
  34388. height = _ref.height;
  34389. return width * height;
  34390. }
  34391. /**
  34392. * Utility used to transform the `auto` placement to the placement with more
  34393. * available space.
  34394. * @method
  34395. * @memberof Popper.Utils
  34396. * @argument {Object} data - The data object generated by update method
  34397. * @argument {Object} options - Modifiers configuration and options
  34398. * @returns {Object} The data object, properly modified
  34399. */
  34400. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  34401. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  34402. if (placement.indexOf('auto') === -1) {
  34403. return placement;
  34404. }
  34405. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  34406. var rects = {
  34407. top: {
  34408. width: boundaries.width,
  34409. height: refRect.top - boundaries.top
  34410. },
  34411. right: {
  34412. width: boundaries.right - refRect.right,
  34413. height: boundaries.height
  34414. },
  34415. bottom: {
  34416. width: boundaries.width,
  34417. height: boundaries.bottom - refRect.bottom
  34418. },
  34419. left: {
  34420. width: refRect.left - boundaries.left,
  34421. height: boundaries.height
  34422. }
  34423. };
  34424. var sortedAreas = Object.keys(rects).map(function (key) {
  34425. return _extends({
  34426. key: key
  34427. }, rects[key], {
  34428. area: getArea(rects[key])
  34429. });
  34430. }).sort(function (a, b) {
  34431. return b.area - a.area;
  34432. });
  34433. var filteredAreas = sortedAreas.filter(function (_ref2) {
  34434. var width = _ref2.width,
  34435. height = _ref2.height;
  34436. return width >= popper.clientWidth && height >= popper.clientHeight;
  34437. });
  34438. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  34439. var variation = placement.split('-')[1];
  34440. return computedPlacement + (variation ? '-' + variation : '');
  34441. }
  34442. /**
  34443. * Get offsets to the reference element
  34444. * @method
  34445. * @memberof Popper.Utils
  34446. * @param {Object} state
  34447. * @param {Element} popper - the popper element
  34448. * @param {Element} reference - the reference element (the popper will be relative to this)
  34449. * @param {Element} fixedPosition - is in fixed position mode
  34450. * @returns {Object} An object containing the offsets which will be applied to the popper
  34451. */
  34452. function getReferenceOffsets(state, popper, reference) {
  34453. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  34454. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, getReferenceNode(reference));
  34455. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  34456. }
  34457. /**
  34458. * Get the outer sizes of the given element (offset size + margins)
  34459. * @method
  34460. * @memberof Popper.Utils
  34461. * @argument {Element} element
  34462. * @returns {Object} object containing width and height properties
  34463. */
  34464. function getOuterSizes(element) {
  34465. var window = element.ownerDocument.defaultView;
  34466. var styles = window.getComputedStyle(element);
  34467. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  34468. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  34469. var result = {
  34470. width: element.offsetWidth + y,
  34471. height: element.offsetHeight + x
  34472. };
  34473. return result;
  34474. }
  34475. /**
  34476. * Get the opposite placement of the given one
  34477. * @method
  34478. * @memberof Popper.Utils
  34479. * @argument {String} placement
  34480. * @returns {String} flipped placement
  34481. */
  34482. function getOppositePlacement(placement) {
  34483. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  34484. return placement.replace(/left|right|bottom|top/g, function (matched) {
  34485. return hash[matched];
  34486. });
  34487. }
  34488. /**
  34489. * Get offsets to the popper
  34490. * @method
  34491. * @memberof Popper.Utils
  34492. * @param {Object} position - CSS position the Popper will get applied
  34493. * @param {HTMLElement} popper - the popper element
  34494. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  34495. * @param {String} placement - one of the valid placement options
  34496. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  34497. */
  34498. function getPopperOffsets(popper, referenceOffsets, placement) {
  34499. placement = placement.split('-')[0];
  34500. // Get popper node sizes
  34501. var popperRect = getOuterSizes(popper);
  34502. // Add position, width and height to our offsets object
  34503. var popperOffsets = {
  34504. width: popperRect.width,
  34505. height: popperRect.height
  34506. };
  34507. // depending by the popper placement we have to compute its offsets slightly differently
  34508. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  34509. var mainSide = isHoriz ? 'top' : 'left';
  34510. var secondarySide = isHoriz ? 'left' : 'top';
  34511. var measurement = isHoriz ? 'height' : 'width';
  34512. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  34513. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  34514. if (placement === secondarySide) {
  34515. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  34516. } else {
  34517. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  34518. }
  34519. return popperOffsets;
  34520. }
  34521. /**
  34522. * Mimics the `find` method of Array
  34523. * @method
  34524. * @memberof Popper.Utils
  34525. * @argument {Array} arr
  34526. * @argument prop
  34527. * @argument value
  34528. * @returns index or -1
  34529. */
  34530. function find(arr, check) {
  34531. // use native find if supported
  34532. if (Array.prototype.find) {
  34533. return arr.find(check);
  34534. }
  34535. // use `filter` to obtain the same behavior of `find`
  34536. return arr.filter(check)[0];
  34537. }
  34538. /**
  34539. * Return the index of the matching object
  34540. * @method
  34541. * @memberof Popper.Utils
  34542. * @argument {Array} arr
  34543. * @argument prop
  34544. * @argument value
  34545. * @returns index or -1
  34546. */
  34547. function findIndex(arr, prop, value) {
  34548. // use native findIndex if supported
  34549. if (Array.prototype.findIndex) {
  34550. return arr.findIndex(function (cur) {
  34551. return cur[prop] === value;
  34552. });
  34553. }
  34554. // use `find` + `indexOf` if `findIndex` isn't supported
  34555. var match = find(arr, function (obj) {
  34556. return obj[prop] === value;
  34557. });
  34558. return arr.indexOf(match);
  34559. }
  34560. /**
  34561. * Loop trough the list of modifiers and run them in order,
  34562. * each of them will then edit the data object.
  34563. * @method
  34564. * @memberof Popper.Utils
  34565. * @param {dataObject} data
  34566. * @param {Array} modifiers
  34567. * @param {String} ends - Optional modifier name used as stopper
  34568. * @returns {dataObject}
  34569. */
  34570. function runModifiers(modifiers, data, ends) {
  34571. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  34572. modifiersToRun.forEach(function (modifier) {
  34573. if (modifier['function']) {
  34574. // eslint-disable-line dot-notation
  34575. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  34576. }
  34577. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  34578. if (modifier.enabled && isFunction(fn)) {
  34579. // Add properties to offsets to make them a complete clientRect object
  34580. // we do this before each modifier to make sure the previous one doesn't
  34581. // mess with these values
  34582. data.offsets.popper = getClientRect(data.offsets.popper);
  34583. data.offsets.reference = getClientRect(data.offsets.reference);
  34584. data = fn(data, modifier);
  34585. }
  34586. });
  34587. return data;
  34588. }
  34589. /**
  34590. * Updates the position of the popper, computing the new offsets and applying
  34591. * the new style.<br />
  34592. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  34593. * @method
  34594. * @memberof Popper
  34595. */
  34596. function update() {
  34597. // if popper is destroyed, don't perform any further update
  34598. if (this.state.isDestroyed) {
  34599. return;
  34600. }
  34601. var data = {
  34602. instance: this,
  34603. styles: {},
  34604. arrowStyles: {},
  34605. attributes: {},
  34606. flipped: false,
  34607. offsets: {}
  34608. };
  34609. // compute reference element offsets
  34610. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  34611. // compute auto placement, store placement inside the data object,
  34612. // modifiers will be able to edit `placement` if needed
  34613. // and refer to originalPlacement to know the original value
  34614. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  34615. // store the computed placement inside `originalPlacement`
  34616. data.originalPlacement = data.placement;
  34617. data.positionFixed = this.options.positionFixed;
  34618. // compute the popper offsets
  34619. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  34620. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  34621. // run the modifiers
  34622. data = runModifiers(this.modifiers, data);
  34623. // the first `update` will call `onCreate` callback
  34624. // the other ones will call `onUpdate` callback
  34625. if (!this.state.isCreated) {
  34626. this.state.isCreated = true;
  34627. this.options.onCreate(data);
  34628. } else {
  34629. this.options.onUpdate(data);
  34630. }
  34631. }
  34632. /**
  34633. * Helper used to know if the given modifier is enabled.
  34634. * @method
  34635. * @memberof Popper.Utils
  34636. * @returns {Boolean}
  34637. */
  34638. function isModifierEnabled(modifiers, modifierName) {
  34639. return modifiers.some(function (_ref) {
  34640. var name = _ref.name,
  34641. enabled = _ref.enabled;
  34642. return enabled && name === modifierName;
  34643. });
  34644. }
  34645. /**
  34646. * Get the prefixed supported property name
  34647. * @method
  34648. * @memberof Popper.Utils
  34649. * @argument {String} property (camelCase)
  34650. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  34651. */
  34652. function getSupportedPropertyName(property) {
  34653. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  34654. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  34655. for (var i = 0; i < prefixes.length; i++) {
  34656. var prefix = prefixes[i];
  34657. var toCheck = prefix ? '' + prefix + upperProp : property;
  34658. if (typeof document.body.style[toCheck] !== 'undefined') {
  34659. return toCheck;
  34660. }
  34661. }
  34662. return null;
  34663. }
  34664. /**
  34665. * Destroys the popper.
  34666. * @method
  34667. * @memberof Popper
  34668. */
  34669. function destroy() {
  34670. this.state.isDestroyed = true;
  34671. // touch DOM only if `applyStyle` modifier is enabled
  34672. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  34673. this.popper.removeAttribute('x-placement');
  34674. this.popper.style.position = '';
  34675. this.popper.style.top = '';
  34676. this.popper.style.left = '';
  34677. this.popper.style.right = '';
  34678. this.popper.style.bottom = '';
  34679. this.popper.style.willChange = '';
  34680. this.popper.style[getSupportedPropertyName('transform')] = '';
  34681. }
  34682. this.disableEventListeners();
  34683. // remove the popper if user explicitly asked for the deletion on destroy
  34684. // do not use `remove` because IE11 doesn't support it
  34685. if (this.options.removeOnDestroy) {
  34686. this.popper.parentNode.removeChild(this.popper);
  34687. }
  34688. return this;
  34689. }
  34690. /**
  34691. * Get the window associated with the element
  34692. * @argument {Element} element
  34693. * @returns {Window}
  34694. */
  34695. function getWindow(element) {
  34696. var ownerDocument = element.ownerDocument;
  34697. return ownerDocument ? ownerDocument.defaultView : window;
  34698. }
  34699. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  34700. var isBody = scrollParent.nodeName === 'BODY';
  34701. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  34702. target.addEventListener(event, callback, { passive: true });
  34703. if (!isBody) {
  34704. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  34705. }
  34706. scrollParents.push(target);
  34707. }
  34708. /**
  34709. * Setup needed event listeners used to update the popper position
  34710. * @method
  34711. * @memberof Popper.Utils
  34712. * @private
  34713. */
  34714. function setupEventListeners(reference, options, state, updateBound) {
  34715. // Resize event listener on window
  34716. state.updateBound = updateBound;
  34717. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  34718. // Scroll event listener on scroll parents
  34719. var scrollElement = getScrollParent(reference);
  34720. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  34721. state.scrollElement = scrollElement;
  34722. state.eventsEnabled = true;
  34723. return state;
  34724. }
  34725. /**
  34726. * It will add resize/scroll events and start recalculating
  34727. * position of the popper element when they are triggered.
  34728. * @method
  34729. * @memberof Popper
  34730. */
  34731. function enableEventListeners() {
  34732. if (!this.state.eventsEnabled) {
  34733. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  34734. }
  34735. }
  34736. /**
  34737. * Remove event listeners used to update the popper position
  34738. * @method
  34739. * @memberof Popper.Utils
  34740. * @private
  34741. */
  34742. function removeEventListeners(reference, state) {
  34743. // Remove resize event listener on window
  34744. getWindow(reference).removeEventListener('resize', state.updateBound);
  34745. // Remove scroll event listener on scroll parents
  34746. state.scrollParents.forEach(function (target) {
  34747. target.removeEventListener('scroll', state.updateBound);
  34748. });
  34749. // Reset state
  34750. state.updateBound = null;
  34751. state.scrollParents = [];
  34752. state.scrollElement = null;
  34753. state.eventsEnabled = false;
  34754. return state;
  34755. }
  34756. /**
  34757. * It will remove resize/scroll events and won't recalculate popper position
  34758. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  34759. * unless you call `update` method manually.
  34760. * @method
  34761. * @memberof Popper
  34762. */
  34763. function disableEventListeners() {
  34764. if (this.state.eventsEnabled) {
  34765. cancelAnimationFrame(this.scheduleUpdate);
  34766. this.state = removeEventListeners(this.reference, this.state);
  34767. }
  34768. }
  34769. /**
  34770. * Tells if a given input is a number
  34771. * @method
  34772. * @memberof Popper.Utils
  34773. * @param {*} input to check
  34774. * @return {Boolean}
  34775. */
  34776. function isNumeric(n) {
  34777. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  34778. }
  34779. /**
  34780. * Set the style to the given popper
  34781. * @method
  34782. * @memberof Popper.Utils
  34783. * @argument {Element} element - Element to apply the style to
  34784. * @argument {Object} styles
  34785. * Object with a list of properties and values which will be applied to the element
  34786. */
  34787. function setStyles(element, styles) {
  34788. Object.keys(styles).forEach(function (prop) {
  34789. var unit = '';
  34790. // add unit if the value is numeric and is one of the following
  34791. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  34792. unit = 'px';
  34793. }
  34794. element.style[prop] = styles[prop] + unit;
  34795. });
  34796. }
  34797. /**
  34798. * Set the attributes to the given popper
  34799. * @method
  34800. * @memberof Popper.Utils
  34801. * @argument {Element} element - Element to apply the attributes to
  34802. * @argument {Object} styles
  34803. * Object with a list of properties and values which will be applied to the element
  34804. */
  34805. function setAttributes(element, attributes) {
  34806. Object.keys(attributes).forEach(function (prop) {
  34807. var value = attributes[prop];
  34808. if (value !== false) {
  34809. element.setAttribute(prop, attributes[prop]);
  34810. } else {
  34811. element.removeAttribute(prop);
  34812. }
  34813. });
  34814. }
  34815. /**
  34816. * @function
  34817. * @memberof Modifiers
  34818. * @argument {Object} data - The data object generated by `update` method
  34819. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  34820. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  34821. * @argument {Object} options - Modifiers configuration and options
  34822. * @returns {Object} The same data object
  34823. */
  34824. function applyStyle(data) {
  34825. // any property present in `data.styles` will be applied to the popper,
  34826. // in this way we can make the 3rd party modifiers add custom styles to it
  34827. // Be aware, modifiers could override the properties defined in the previous
  34828. // lines of this modifier!
  34829. setStyles(data.instance.popper, data.styles);
  34830. // any property present in `data.attributes` will be applied to the popper,
  34831. // they will be set as HTML attributes of the element
  34832. setAttributes(data.instance.popper, data.attributes);
  34833. // if arrowElement is defined and arrowStyles has some properties
  34834. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  34835. setStyles(data.arrowElement, data.arrowStyles);
  34836. }
  34837. return data;
  34838. }
  34839. /**
  34840. * Set the x-placement attribute before everything else because it could be used
  34841. * to add margins to the popper margins needs to be calculated to get the
  34842. * correct popper offsets.
  34843. * @method
  34844. * @memberof Popper.modifiers
  34845. * @param {HTMLElement} reference - The reference element used to position the popper
  34846. * @param {HTMLElement} popper - The HTML element used as popper
  34847. * @param {Object} options - Popper.js options
  34848. */
  34849. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  34850. // compute reference element offsets
  34851. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  34852. // compute auto placement, store placement inside the data object,
  34853. // modifiers will be able to edit `placement` if needed
  34854. // and refer to originalPlacement to know the original value
  34855. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  34856. popper.setAttribute('x-placement', placement);
  34857. // Apply `position` to popper before anything else because
  34858. // without the position applied we can't guarantee correct computations
  34859. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  34860. return options;
  34861. }
  34862. /**
  34863. * @function
  34864. * @memberof Popper.Utils
  34865. * @argument {Object} data - The data object generated by `update` method
  34866. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  34867. * @returns {Object} The popper's position offsets rounded
  34868. *
  34869. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  34870. * good as it can be within reason.
  34871. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  34872. *
  34873. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  34874. * as well on High DPI screens).
  34875. *
  34876. * Firefox prefers no rounding for positioning and does not have blurriness on
  34877. * high DPI screens.
  34878. *
  34879. * Only horizontal placement and left/right values need to be considered.
  34880. */
  34881. function getRoundedOffsets(data, shouldRound) {
  34882. var _data$offsets = data.offsets,
  34883. popper = _data$offsets.popper,
  34884. reference = _data$offsets.reference;
  34885. var round = Math.round,
  34886. floor = Math.floor;
  34887. var noRound = function noRound(v) {
  34888. return v;
  34889. };
  34890. var referenceWidth = round(reference.width);
  34891. var popperWidth = round(popper.width);
  34892. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  34893. var isVariation = data.placement.indexOf('-') !== -1;
  34894. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  34895. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  34896. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  34897. var verticalToInteger = !shouldRound ? noRound : round;
  34898. return {
  34899. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  34900. top: verticalToInteger(popper.top),
  34901. bottom: verticalToInteger(popper.bottom),
  34902. right: horizontalToInteger(popper.right)
  34903. };
  34904. }
  34905. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  34906. /**
  34907. * @function
  34908. * @memberof Modifiers
  34909. * @argument {Object} data - The data object generated by `update` method
  34910. * @argument {Object} options - Modifiers configuration and options
  34911. * @returns {Object} The data object, properly modified
  34912. */
  34913. function computeStyle(data, options) {
  34914. var x = options.x,
  34915. y = options.y;
  34916. var popper = data.offsets.popper;
  34917. // Remove this legacy support in Popper.js v2
  34918. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  34919. return modifier.name === 'applyStyle';
  34920. }).gpuAcceleration;
  34921. if (legacyGpuAccelerationOption !== undefined) {
  34922. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  34923. }
  34924. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  34925. var offsetParent = getOffsetParent(data.instance.popper);
  34926. var offsetParentRect = getBoundingClientRect(offsetParent);
  34927. // Styles
  34928. var styles = {
  34929. position: popper.position
  34930. };
  34931. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  34932. var sideA = x === 'bottom' ? 'top' : 'bottom';
  34933. var sideB = y === 'right' ? 'left' : 'right';
  34934. // if gpuAcceleration is set to `true` and transform is supported,
  34935. // we use `translate3d` to apply the position to the popper we
  34936. // automatically use the supported prefixed version if needed
  34937. var prefixedProperty = getSupportedPropertyName('transform');
  34938. // now, let's make a step back and look at this code closely (wtf?)
  34939. // If the content of the popper grows once it's been positioned, it
  34940. // may happen that the popper gets misplaced because of the new content
  34941. // overflowing its reference element
  34942. // To avoid this problem, we provide two options (x and y), which allow
  34943. // the consumer to define the offset origin.
  34944. // If we position a popper on top of a reference element, we can set
  34945. // `x` to `top` to make the popper grow towards its top instead of
  34946. // its bottom.
  34947. var left = void 0,
  34948. top = void 0;
  34949. if (sideA === 'bottom') {
  34950. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  34951. // and not the bottom of the html element
  34952. if (offsetParent.nodeName === 'HTML') {
  34953. top = -offsetParent.clientHeight + offsets.bottom;
  34954. } else {
  34955. top = -offsetParentRect.height + offsets.bottom;
  34956. }
  34957. } else {
  34958. top = offsets.top;
  34959. }
  34960. if (sideB === 'right') {
  34961. if (offsetParent.nodeName === 'HTML') {
  34962. left = -offsetParent.clientWidth + offsets.right;
  34963. } else {
  34964. left = -offsetParentRect.width + offsets.right;
  34965. }
  34966. } else {
  34967. left = offsets.left;
  34968. }
  34969. if (gpuAcceleration && prefixedProperty) {
  34970. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  34971. styles[sideA] = 0;
  34972. styles[sideB] = 0;
  34973. styles.willChange = 'transform';
  34974. } else {
  34975. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  34976. var invertTop = sideA === 'bottom' ? -1 : 1;
  34977. var invertLeft = sideB === 'right' ? -1 : 1;
  34978. styles[sideA] = top * invertTop;
  34979. styles[sideB] = left * invertLeft;
  34980. styles.willChange = sideA + ', ' + sideB;
  34981. }
  34982. // Attributes
  34983. var attributes = {
  34984. 'x-placement': data.placement
  34985. };
  34986. // Update `data` attributes, styles and arrowStyles
  34987. data.attributes = _extends({}, attributes, data.attributes);
  34988. data.styles = _extends({}, styles, data.styles);
  34989. data.arrowStyles = _extends({}, data.offsets.arrow, data.arrowStyles);
  34990. return data;
  34991. }
  34992. /**
  34993. * Helper used to know if the given modifier depends from another one.<br />
  34994. * It checks if the needed modifier is listed and enabled.
  34995. * @method
  34996. * @memberof Popper.Utils
  34997. * @param {Array} modifiers - list of modifiers
  34998. * @param {String} requestingName - name of requesting modifier
  34999. * @param {String} requestedName - name of requested modifier
  35000. * @returns {Boolean}
  35001. */
  35002. function isModifierRequired(modifiers, requestingName, requestedName) {
  35003. var requesting = find(modifiers, function (_ref) {
  35004. var name = _ref.name;
  35005. return name === requestingName;
  35006. });
  35007. var isRequired = !!requesting && modifiers.some(function (modifier) {
  35008. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  35009. });
  35010. if (!isRequired) {
  35011. var _requesting = '`' + requestingName + '`';
  35012. var requested = '`' + requestedName + '`';
  35013. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  35014. }
  35015. return isRequired;
  35016. }
  35017. /**
  35018. * @function
  35019. * @memberof Modifiers
  35020. * @argument {Object} data - The data object generated by update method
  35021. * @argument {Object} options - Modifiers configuration and options
  35022. * @returns {Object} The data object, properly modified
  35023. */
  35024. function arrow(data, options) {
  35025. var _data$offsets$arrow;
  35026. // arrow depends on keepTogether in order to work
  35027. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  35028. return data;
  35029. }
  35030. var arrowElement = options.element;
  35031. // if arrowElement is a string, suppose it's a CSS selector
  35032. if (typeof arrowElement === 'string') {
  35033. arrowElement = data.instance.popper.querySelector(arrowElement);
  35034. // if arrowElement is not found, don't run the modifier
  35035. if (!arrowElement) {
  35036. return data;
  35037. }
  35038. } else {
  35039. // if the arrowElement isn't a query selector we must check that the
  35040. // provided DOM node is child of its popper node
  35041. if (!data.instance.popper.contains(arrowElement)) {
  35042. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  35043. return data;
  35044. }
  35045. }
  35046. var placement = data.placement.split('-')[0];
  35047. var _data$offsets = data.offsets,
  35048. popper = _data$offsets.popper,
  35049. reference = _data$offsets.reference;
  35050. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  35051. var len = isVertical ? 'height' : 'width';
  35052. var sideCapitalized = isVertical ? 'Top' : 'Left';
  35053. var side = sideCapitalized.toLowerCase();
  35054. var altSide = isVertical ? 'left' : 'top';
  35055. var opSide = isVertical ? 'bottom' : 'right';
  35056. var arrowElementSize = getOuterSizes(arrowElement)[len];
  35057. //
  35058. // extends keepTogether behavior making sure the popper and its
  35059. // reference have enough pixels in conjunction
  35060. //
  35061. // top/left side
  35062. if (reference[opSide] - arrowElementSize < popper[side]) {
  35063. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  35064. }
  35065. // bottom/right side
  35066. if (reference[side] + arrowElementSize > popper[opSide]) {
  35067. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  35068. }
  35069. data.offsets.popper = getClientRect(data.offsets.popper);
  35070. // compute center of the popper
  35071. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  35072. // Compute the sideValue using the updated popper offsets
  35073. // take popper margin in account because we don't have this info available
  35074. var css = getStyleComputedProperty(data.instance.popper);
  35075. var popperMarginSide = parseFloat(css['margin' + sideCapitalized]);
  35076. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width']);
  35077. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  35078. // prevent arrowElement from being placed not contiguously to its popper
  35079. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  35080. data.arrowElement = arrowElement;
  35081. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  35082. return data;
  35083. }
  35084. /**
  35085. * Get the opposite placement variation of the given one
  35086. * @method
  35087. * @memberof Popper.Utils
  35088. * @argument {String} placement variation
  35089. * @returns {String} flipped placement variation
  35090. */
  35091. function getOppositeVariation(variation) {
  35092. if (variation === 'end') {
  35093. return 'start';
  35094. } else if (variation === 'start') {
  35095. return 'end';
  35096. }
  35097. return variation;
  35098. }
  35099. /**
  35100. * List of accepted placements to use as values of the `placement` option.<br />
  35101. * Valid placements are:
  35102. * - `auto`
  35103. * - `top`
  35104. * - `right`
  35105. * - `bottom`
  35106. * - `left`
  35107. *
  35108. * Each placement can have a variation from this list:
  35109. * - `-start`
  35110. * - `-end`
  35111. *
  35112. * Variations are interpreted easily if you think of them as the left to right
  35113. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  35114. * is right.<br />
  35115. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  35116. *
  35117. * Some valid examples are:
  35118. * - `top-end` (on top of reference, right aligned)
  35119. * - `right-start` (on right of reference, top aligned)
  35120. * - `bottom` (on bottom, centered)
  35121. * - `auto-end` (on the side with more space available, alignment depends by placement)
  35122. *
  35123. * @static
  35124. * @type {Array}
  35125. * @enum {String}
  35126. * @readonly
  35127. * @method placements
  35128. * @memberof Popper
  35129. */
  35130. 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'];
  35131. // Get rid of `auto` `auto-start` and `auto-end`
  35132. var validPlacements = placements.slice(3);
  35133. /**
  35134. * Given an initial placement, returns all the subsequent placements
  35135. * clockwise (or counter-clockwise).
  35136. *
  35137. * @method
  35138. * @memberof Popper.Utils
  35139. * @argument {String} placement - A valid placement (it accepts variations)
  35140. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  35141. * @returns {Array} placements including their variations
  35142. */
  35143. function clockwise(placement) {
  35144. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  35145. var index = validPlacements.indexOf(placement);
  35146. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  35147. return counter ? arr.reverse() : arr;
  35148. }
  35149. var BEHAVIORS = {
  35150. FLIP: 'flip',
  35151. CLOCKWISE: 'clockwise',
  35152. COUNTERCLOCKWISE: 'counterclockwise'
  35153. };
  35154. /**
  35155. * @function
  35156. * @memberof Modifiers
  35157. * @argument {Object} data - The data object generated by update method
  35158. * @argument {Object} options - Modifiers configuration and options
  35159. * @returns {Object} The data object, properly modified
  35160. */
  35161. function flip(data, options) {
  35162. // if `inner` modifier is enabled, we can't use the `flip` modifier
  35163. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  35164. return data;
  35165. }
  35166. if (data.flipped && data.placement === data.originalPlacement) {
  35167. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  35168. return data;
  35169. }
  35170. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  35171. var placement = data.placement.split('-')[0];
  35172. var placementOpposite = getOppositePlacement(placement);
  35173. var variation = data.placement.split('-')[1] || '';
  35174. var flipOrder = [];
  35175. switch (options.behavior) {
  35176. case BEHAVIORS.FLIP:
  35177. flipOrder = [placement, placementOpposite];
  35178. break;
  35179. case BEHAVIORS.CLOCKWISE:
  35180. flipOrder = clockwise(placement);
  35181. break;
  35182. case BEHAVIORS.COUNTERCLOCKWISE:
  35183. flipOrder = clockwise(placement, true);
  35184. break;
  35185. default:
  35186. flipOrder = options.behavior;
  35187. }
  35188. flipOrder.forEach(function (step, index) {
  35189. if (placement !== step || flipOrder.length === index + 1) {
  35190. return data;
  35191. }
  35192. placement = data.placement.split('-')[0];
  35193. placementOpposite = getOppositePlacement(placement);
  35194. var popperOffsets = data.offsets.popper;
  35195. var refOffsets = data.offsets.reference;
  35196. // using floor because the reference offsets may contain decimals we are not going to consider here
  35197. var floor = Math.floor;
  35198. 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);
  35199. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  35200. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  35201. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  35202. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  35203. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  35204. // flip the variation if required
  35205. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  35206. // flips variation if reference element overflows boundaries
  35207. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  35208. // flips variation if popper content overflows boundaries
  35209. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  35210. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  35211. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  35212. // this boolean to detect any flip loop
  35213. data.flipped = true;
  35214. if (overlapsRef || overflowsBoundaries) {
  35215. placement = flipOrder[index + 1];
  35216. }
  35217. if (flippedVariation) {
  35218. variation = getOppositeVariation(variation);
  35219. }
  35220. data.placement = placement + (variation ? '-' + variation : '');
  35221. // this object contains `position`, we want to preserve it along with
  35222. // any additional property we may add in the future
  35223. data.offsets.popper = _extends({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  35224. data = runModifiers(data.instance.modifiers, data, 'flip');
  35225. }
  35226. });
  35227. return data;
  35228. }
  35229. /**
  35230. * @function
  35231. * @memberof Modifiers
  35232. * @argument {Object} data - The data object generated by update method
  35233. * @argument {Object} options - Modifiers configuration and options
  35234. * @returns {Object} The data object, properly modified
  35235. */
  35236. function keepTogether(data) {
  35237. var _data$offsets = data.offsets,
  35238. popper = _data$offsets.popper,
  35239. reference = _data$offsets.reference;
  35240. var placement = data.placement.split('-')[0];
  35241. var floor = Math.floor;
  35242. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  35243. var side = isVertical ? 'right' : 'bottom';
  35244. var opSide = isVertical ? 'left' : 'top';
  35245. var measurement = isVertical ? 'width' : 'height';
  35246. if (popper[side] < floor(reference[opSide])) {
  35247. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  35248. }
  35249. if (popper[opSide] > floor(reference[side])) {
  35250. data.offsets.popper[opSide] = floor(reference[side]);
  35251. }
  35252. return data;
  35253. }
  35254. /**
  35255. * Converts a string containing value + unit into a px value number
  35256. * @function
  35257. * @memberof {modifiers~offset}
  35258. * @private
  35259. * @argument {String} str - Value + unit string
  35260. * @argument {String} measurement - `height` or `width`
  35261. * @argument {Object} popperOffsets
  35262. * @argument {Object} referenceOffsets
  35263. * @returns {Number|String}
  35264. * Value in pixels, or original string if no values were extracted
  35265. */
  35266. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  35267. // separate value from unit
  35268. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  35269. var value = +split[1];
  35270. var unit = split[2];
  35271. // If it's not a number it's an operator, I guess
  35272. if (!value) {
  35273. return str;
  35274. }
  35275. if (unit.indexOf('%') === 0) {
  35276. var element = void 0;
  35277. switch (unit) {
  35278. case '%p':
  35279. element = popperOffsets;
  35280. break;
  35281. case '%':
  35282. case '%r':
  35283. default:
  35284. element = referenceOffsets;
  35285. }
  35286. var rect = getClientRect(element);
  35287. return rect[measurement] / 100 * value;
  35288. } else if (unit === 'vh' || unit === 'vw') {
  35289. // if is a vh or vw, we calculate the size based on the viewport
  35290. var size = void 0;
  35291. if (unit === 'vh') {
  35292. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  35293. } else {
  35294. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  35295. }
  35296. return size / 100 * value;
  35297. } else {
  35298. // if is an explicit pixel unit, we get rid of the unit and keep the value
  35299. // if is an implicit unit, it's px, and we return just the value
  35300. return value;
  35301. }
  35302. }
  35303. /**
  35304. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  35305. * @function
  35306. * @memberof {modifiers~offset}
  35307. * @private
  35308. * @argument {String} offset
  35309. * @argument {Object} popperOffsets
  35310. * @argument {Object} referenceOffsets
  35311. * @argument {String} basePlacement
  35312. * @returns {Array} a two cells array with x and y offsets in numbers
  35313. */
  35314. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  35315. var offsets = [0, 0];
  35316. // Use height if placement is left or right and index is 0 otherwise use width
  35317. // in this way the first offset will use an axis and the second one
  35318. // will use the other one
  35319. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  35320. // Split the offset string to obtain a list of values and operands
  35321. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  35322. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  35323. return frag.trim();
  35324. });
  35325. // Detect if the offset string contains a pair of values or a single one
  35326. // they could be separated by comma or space
  35327. var divider = fragments.indexOf(find(fragments, function (frag) {
  35328. return frag.search(/,|\s/) !== -1;
  35329. }));
  35330. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  35331. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  35332. }
  35333. // If divider is found, we divide the list of values and operands to divide
  35334. // them by ofset X and Y.
  35335. var splitRegex = /\s*,\s*|\s+/;
  35336. 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];
  35337. // Convert the values with units to absolute pixels to allow our computations
  35338. ops = ops.map(function (op, index) {
  35339. // Most of the units rely on the orientation of the popper
  35340. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  35341. var mergeWithPrevious = false;
  35342. return op
  35343. // This aggregates any `+` or `-` sign that aren't considered operators
  35344. // e.g.: 10 + +5 => [10, +, +5]
  35345. .reduce(function (a, b) {
  35346. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  35347. a[a.length - 1] = b;
  35348. mergeWithPrevious = true;
  35349. return a;
  35350. } else if (mergeWithPrevious) {
  35351. a[a.length - 1] += b;
  35352. mergeWithPrevious = false;
  35353. return a;
  35354. } else {
  35355. return a.concat(b);
  35356. }
  35357. }, [])
  35358. // Here we convert the string values into number values (in px)
  35359. .map(function (str) {
  35360. return toValue(str, measurement, popperOffsets, referenceOffsets);
  35361. });
  35362. });
  35363. // Loop trough the offsets arrays and execute the operations
  35364. ops.forEach(function (op, index) {
  35365. op.forEach(function (frag, index2) {
  35366. if (isNumeric(frag)) {
  35367. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  35368. }
  35369. });
  35370. });
  35371. return offsets;
  35372. }
  35373. /**
  35374. * @function
  35375. * @memberof Modifiers
  35376. * @argument {Object} data - The data object generated by update method
  35377. * @argument {Object} options - Modifiers configuration and options
  35378. * @argument {Number|String} options.offset=0
  35379. * The offset value as described in the modifier description
  35380. * @returns {Object} The data object, properly modified
  35381. */
  35382. function offset(data, _ref) {
  35383. var offset = _ref.offset;
  35384. var placement = data.placement,
  35385. _data$offsets = data.offsets,
  35386. popper = _data$offsets.popper,
  35387. reference = _data$offsets.reference;
  35388. var basePlacement = placement.split('-')[0];
  35389. var offsets = void 0;
  35390. if (isNumeric(+offset)) {
  35391. offsets = [+offset, 0];
  35392. } else {
  35393. offsets = parseOffset(offset, popper, reference, basePlacement);
  35394. }
  35395. if (basePlacement === 'left') {
  35396. popper.top += offsets[0];
  35397. popper.left -= offsets[1];
  35398. } else if (basePlacement === 'right') {
  35399. popper.top += offsets[0];
  35400. popper.left += offsets[1];
  35401. } else if (basePlacement === 'top') {
  35402. popper.left += offsets[0];
  35403. popper.top -= offsets[1];
  35404. } else if (basePlacement === 'bottom') {
  35405. popper.left += offsets[0];
  35406. popper.top += offsets[1];
  35407. }
  35408. data.popper = popper;
  35409. return data;
  35410. }
  35411. /**
  35412. * @function
  35413. * @memberof Modifiers
  35414. * @argument {Object} data - The data object generated by `update` method
  35415. * @argument {Object} options - Modifiers configuration and options
  35416. * @returns {Object} The data object, properly modified
  35417. */
  35418. function preventOverflow(data, options) {
  35419. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  35420. // If offsetParent is the reference element, we really want to
  35421. // go one step up and use the next offsetParent as reference to
  35422. // avoid to make this modifier completely useless and look like broken
  35423. if (data.instance.reference === boundariesElement) {
  35424. boundariesElement = getOffsetParent(boundariesElement);
  35425. }
  35426. // NOTE: DOM access here
  35427. // resets the popper's position so that the document size can be calculated excluding
  35428. // the size of the popper element itself
  35429. var transformProp = getSupportedPropertyName('transform');
  35430. var popperStyles = data.instance.popper.style; // assignment to help minification
  35431. var top = popperStyles.top,
  35432. left = popperStyles.left,
  35433. transform = popperStyles[transformProp];
  35434. popperStyles.top = '';
  35435. popperStyles.left = '';
  35436. popperStyles[transformProp] = '';
  35437. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  35438. // NOTE: DOM access here
  35439. // restores the original style properties after the offsets have been computed
  35440. popperStyles.top = top;
  35441. popperStyles.left = left;
  35442. popperStyles[transformProp] = transform;
  35443. options.boundaries = boundaries;
  35444. var order = options.priority;
  35445. var popper = data.offsets.popper;
  35446. var check = {
  35447. primary: function primary(placement) {
  35448. var value = popper[placement];
  35449. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  35450. value = Math.max(popper[placement], boundaries[placement]);
  35451. }
  35452. return defineProperty({}, placement, value);
  35453. },
  35454. secondary: function secondary(placement) {
  35455. var mainSide = placement === 'right' ? 'left' : 'top';
  35456. var value = popper[mainSide];
  35457. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  35458. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  35459. }
  35460. return defineProperty({}, mainSide, value);
  35461. }
  35462. };
  35463. order.forEach(function (placement) {
  35464. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  35465. popper = _extends({}, popper, check[side](placement));
  35466. });
  35467. data.offsets.popper = popper;
  35468. return data;
  35469. }
  35470. /**
  35471. * @function
  35472. * @memberof Modifiers
  35473. * @argument {Object} data - The data object generated by `update` method
  35474. * @argument {Object} options - Modifiers configuration and options
  35475. * @returns {Object} The data object, properly modified
  35476. */
  35477. function shift(data) {
  35478. var placement = data.placement;
  35479. var basePlacement = placement.split('-')[0];
  35480. var shiftvariation = placement.split('-')[1];
  35481. // if shift shiftvariation is specified, run the modifier
  35482. if (shiftvariation) {
  35483. var _data$offsets = data.offsets,
  35484. reference = _data$offsets.reference,
  35485. popper = _data$offsets.popper;
  35486. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  35487. var side = isVertical ? 'left' : 'top';
  35488. var measurement = isVertical ? 'width' : 'height';
  35489. var shiftOffsets = {
  35490. start: defineProperty({}, side, reference[side]),
  35491. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  35492. };
  35493. data.offsets.popper = _extends({}, popper, shiftOffsets[shiftvariation]);
  35494. }
  35495. return data;
  35496. }
  35497. /**
  35498. * @function
  35499. * @memberof Modifiers
  35500. * @argument {Object} data - The data object generated by update method
  35501. * @argument {Object} options - Modifiers configuration and options
  35502. * @returns {Object} The data object, properly modified
  35503. */
  35504. function hide(data) {
  35505. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  35506. return data;
  35507. }
  35508. var refRect = data.offsets.reference;
  35509. var bound = find(data.instance.modifiers, function (modifier) {
  35510. return modifier.name === 'preventOverflow';
  35511. }).boundaries;
  35512. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  35513. // Avoid unnecessary DOM access if visibility hasn't changed
  35514. if (data.hide === true) {
  35515. return data;
  35516. }
  35517. data.hide = true;
  35518. data.attributes['x-out-of-boundaries'] = '';
  35519. } else {
  35520. // Avoid unnecessary DOM access if visibility hasn't changed
  35521. if (data.hide === false) {
  35522. return data;
  35523. }
  35524. data.hide = false;
  35525. data.attributes['x-out-of-boundaries'] = false;
  35526. }
  35527. return data;
  35528. }
  35529. /**
  35530. * @function
  35531. * @memberof Modifiers
  35532. * @argument {Object} data - The data object generated by `update` method
  35533. * @argument {Object} options - Modifiers configuration and options
  35534. * @returns {Object} The data object, properly modified
  35535. */
  35536. function inner(data) {
  35537. var placement = data.placement;
  35538. var basePlacement = placement.split('-')[0];
  35539. var _data$offsets = data.offsets,
  35540. popper = _data$offsets.popper,
  35541. reference = _data$offsets.reference;
  35542. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  35543. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  35544. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  35545. data.placement = getOppositePlacement(placement);
  35546. data.offsets.popper = getClientRect(popper);
  35547. return data;
  35548. }
  35549. /**
  35550. * Modifier function, each modifier can have a function of this type assigned
  35551. * to its `fn` property.<br />
  35552. * These functions will be called on each update, this means that you must
  35553. * make sure they are performant enough to avoid performance bottlenecks.
  35554. *
  35555. * @function ModifierFn
  35556. * @argument {dataObject} data - The data object generated by `update` method
  35557. * @argument {Object} options - Modifiers configuration and options
  35558. * @returns {dataObject} The data object, properly modified
  35559. */
  35560. /**
  35561. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  35562. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  35563. * needed by the library.
  35564. *
  35565. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  35566. * All the other properties are configurations that could be tweaked.
  35567. * @namespace modifiers
  35568. */
  35569. var modifiers = {
  35570. /**
  35571. * Modifier used to shift the popper on the start or end of its reference
  35572. * element.<br />
  35573. * It will read the variation of the `placement` property.<br />
  35574. * It can be one either `-end` or `-start`.
  35575. * @memberof modifiers
  35576. * @inner
  35577. */
  35578. shift: {
  35579. /** @prop {number} order=100 - Index used to define the order of execution */
  35580. order: 100,
  35581. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35582. enabled: true,
  35583. /** @prop {ModifierFn} */
  35584. fn: shift
  35585. },
  35586. /**
  35587. * The `offset` modifier can shift your popper on both its axis.
  35588. *
  35589. * It accepts the following units:
  35590. * - `px` or unit-less, interpreted as pixels
  35591. * - `%` or `%r`, percentage relative to the length of the reference element
  35592. * - `%p`, percentage relative to the length of the popper element
  35593. * - `vw`, CSS viewport width unit
  35594. * - `vh`, CSS viewport height unit
  35595. *
  35596. * For length is intended the main axis relative to the placement of the popper.<br />
  35597. * This means that if the placement is `top` or `bottom`, the length will be the
  35598. * `width`. In case of `left` or `right`, it will be the `height`.
  35599. *
  35600. * You can provide a single value (as `Number` or `String`), or a pair of values
  35601. * as `String` divided by a comma or one (or more) white spaces.<br />
  35602. * The latter is a deprecated method because it leads to confusion and will be
  35603. * removed in v2.<br />
  35604. * Additionally, it accepts additions and subtractions between different units.
  35605. * Note that multiplications and divisions aren't supported.
  35606. *
  35607. * Valid examples are:
  35608. * ```
  35609. * 10
  35610. * '10%'
  35611. * '10, 10'
  35612. * '10%, 10'
  35613. * '10 + 10%'
  35614. * '10 - 5vh + 3%'
  35615. * '-10px + 5vh, 5px - 6%'
  35616. * ```
  35617. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  35618. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  35619. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  35620. *
  35621. * @memberof modifiers
  35622. * @inner
  35623. */
  35624. offset: {
  35625. /** @prop {number} order=200 - Index used to define the order of execution */
  35626. order: 200,
  35627. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35628. enabled: true,
  35629. /** @prop {ModifierFn} */
  35630. fn: offset,
  35631. /** @prop {Number|String} offset=0
  35632. * The offset value as described in the modifier description
  35633. */
  35634. offset: 0
  35635. },
  35636. /**
  35637. * Modifier used to prevent the popper from being positioned outside the boundary.
  35638. *
  35639. * A scenario exists where the reference itself is not within the boundaries.<br />
  35640. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  35641. * In this case we need to decide whether the popper should either:
  35642. *
  35643. * - detach from the reference and remain "trapped" in the boundaries, or
  35644. * - if it should ignore the boundary and "escape with its reference"
  35645. *
  35646. * When `escapeWithReference` is set to`true` and reference is completely
  35647. * outside its boundaries, the popper will overflow (or completely leave)
  35648. * the boundaries in order to remain attached to the edge of the reference.
  35649. *
  35650. * @memberof modifiers
  35651. * @inner
  35652. */
  35653. preventOverflow: {
  35654. /** @prop {number} order=300 - Index used to define the order of execution */
  35655. order: 300,
  35656. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35657. enabled: true,
  35658. /** @prop {ModifierFn} */
  35659. fn: preventOverflow,
  35660. /**
  35661. * @prop {Array} [priority=['left','right','top','bottom']]
  35662. * Popper will try to prevent overflow following these priorities by default,
  35663. * then, it could overflow on the left and on top of the `boundariesElement`
  35664. */
  35665. priority: ['left', 'right', 'top', 'bottom'],
  35666. /**
  35667. * @prop {number} padding=5
  35668. * Amount of pixel used to define a minimum distance between the boundaries
  35669. * and the popper. This makes sure the popper always has a little padding
  35670. * between the edges of its container
  35671. */
  35672. padding: 5,
  35673. /**
  35674. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  35675. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  35676. * `viewport` or any DOM element.
  35677. */
  35678. boundariesElement: 'scrollParent'
  35679. },
  35680. /**
  35681. * Modifier used to make sure the reference and its popper stay near each other
  35682. * without leaving any gap between the two. Especially useful when the arrow is
  35683. * enabled and you want to ensure that it points to its reference element.
  35684. * It cares only about the first axis. You can still have poppers with margin
  35685. * between the popper and its reference element.
  35686. * @memberof modifiers
  35687. * @inner
  35688. */
  35689. keepTogether: {
  35690. /** @prop {number} order=400 - Index used to define the order of execution */
  35691. order: 400,
  35692. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35693. enabled: true,
  35694. /** @prop {ModifierFn} */
  35695. fn: keepTogether
  35696. },
  35697. /**
  35698. * This modifier is used to move the `arrowElement` of the popper to make
  35699. * sure it is positioned between the reference element and its popper element.
  35700. * It will read the outer size of the `arrowElement` node to detect how many
  35701. * pixels of conjunction are needed.
  35702. *
  35703. * It has no effect if no `arrowElement` is provided.
  35704. * @memberof modifiers
  35705. * @inner
  35706. */
  35707. arrow: {
  35708. /** @prop {number} order=500 - Index used to define the order of execution */
  35709. order: 500,
  35710. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35711. enabled: true,
  35712. /** @prop {ModifierFn} */
  35713. fn: arrow,
  35714. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  35715. element: '[x-arrow]'
  35716. },
  35717. /**
  35718. * Modifier used to flip the popper's placement when it starts to overlap its
  35719. * reference element.
  35720. *
  35721. * Requires the `preventOverflow` modifier before it in order to work.
  35722. *
  35723. * **NOTE:** this modifier will interrupt the current update cycle and will
  35724. * restart it if it detects the need to flip the placement.
  35725. * @memberof modifiers
  35726. * @inner
  35727. */
  35728. flip: {
  35729. /** @prop {number} order=600 - Index used to define the order of execution */
  35730. order: 600,
  35731. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35732. enabled: true,
  35733. /** @prop {ModifierFn} */
  35734. fn: flip,
  35735. /**
  35736. * @prop {String|Array} behavior='flip'
  35737. * The behavior used to change the popper's placement. It can be one of
  35738. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  35739. * placements (with optional variations)
  35740. */
  35741. behavior: 'flip',
  35742. /**
  35743. * @prop {number} padding=5
  35744. * The popper will flip if it hits the edges of the `boundariesElement`
  35745. */
  35746. padding: 5,
  35747. /**
  35748. * @prop {String|HTMLElement} boundariesElement='viewport'
  35749. * The element which will define the boundaries of the popper position.
  35750. * The popper will never be placed outside of the defined boundaries
  35751. * (except if `keepTogether` is enabled)
  35752. */
  35753. boundariesElement: 'viewport',
  35754. /**
  35755. * @prop {Boolean} flipVariations=false
  35756. * The popper will switch placement variation between `-start` and `-end` when
  35757. * the reference element overlaps its boundaries.
  35758. *
  35759. * The original placement should have a set variation.
  35760. */
  35761. flipVariations: false,
  35762. /**
  35763. * @prop {Boolean} flipVariationsByContent=false
  35764. * The popper will switch placement variation between `-start` and `-end` when
  35765. * the popper element overlaps its reference boundaries.
  35766. *
  35767. * The original placement should have a set variation.
  35768. */
  35769. flipVariationsByContent: false
  35770. },
  35771. /**
  35772. * Modifier used to make the popper flow toward the inner of the reference element.
  35773. * By default, when this modifier is disabled, the popper will be placed outside
  35774. * the reference element.
  35775. * @memberof modifiers
  35776. * @inner
  35777. */
  35778. inner: {
  35779. /** @prop {number} order=700 - Index used to define the order of execution */
  35780. order: 700,
  35781. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  35782. enabled: false,
  35783. /** @prop {ModifierFn} */
  35784. fn: inner
  35785. },
  35786. /**
  35787. * Modifier used to hide the popper when its reference element is outside of the
  35788. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  35789. * be used to hide with a CSS selector the popper when its reference is
  35790. * out of boundaries.
  35791. *
  35792. * Requires the `preventOverflow` modifier before it in order to work.
  35793. * @memberof modifiers
  35794. * @inner
  35795. */
  35796. hide: {
  35797. /** @prop {number} order=800 - Index used to define the order of execution */
  35798. order: 800,
  35799. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35800. enabled: true,
  35801. /** @prop {ModifierFn} */
  35802. fn: hide
  35803. },
  35804. /**
  35805. * Computes the style that will be applied to the popper element to gets
  35806. * properly positioned.
  35807. *
  35808. * Note that this modifier will not touch the DOM, it just prepares the styles
  35809. * so that `applyStyle` modifier can apply it. This separation is useful
  35810. * in case you need to replace `applyStyle` with a custom implementation.
  35811. *
  35812. * This modifier has `850` as `order` value to maintain backward compatibility
  35813. * with previous versions of Popper.js. Expect the modifiers ordering method
  35814. * to change in future major versions of the library.
  35815. *
  35816. * @memberof modifiers
  35817. * @inner
  35818. */
  35819. computeStyle: {
  35820. /** @prop {number} order=850 - Index used to define the order of execution */
  35821. order: 850,
  35822. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35823. enabled: true,
  35824. /** @prop {ModifierFn} */
  35825. fn: computeStyle,
  35826. /**
  35827. * @prop {Boolean} gpuAcceleration=true
  35828. * If true, it uses the CSS 3D transformation to position the popper.
  35829. * Otherwise, it will use the `top` and `left` properties
  35830. */
  35831. gpuAcceleration: true,
  35832. /**
  35833. * @prop {string} [x='bottom']
  35834. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  35835. * Change this if your popper should grow in a direction different from `bottom`
  35836. */
  35837. x: 'bottom',
  35838. /**
  35839. * @prop {string} [x='left']
  35840. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  35841. * Change this if your popper should grow in a direction different from `right`
  35842. */
  35843. y: 'right'
  35844. },
  35845. /**
  35846. * Applies the computed styles to the popper element.
  35847. *
  35848. * All the DOM manipulations are limited to this modifier. This is useful in case
  35849. * you want to integrate Popper.js inside a framework or view library and you
  35850. * want to delegate all the DOM manipulations to it.
  35851. *
  35852. * Note that if you disable this modifier, you must make sure the popper element
  35853. * has its position set to `absolute` before Popper.js can do its work!
  35854. *
  35855. * Just disable this modifier and define your own to achieve the desired effect.
  35856. *
  35857. * @memberof modifiers
  35858. * @inner
  35859. */
  35860. applyStyle: {
  35861. /** @prop {number} order=900 - Index used to define the order of execution */
  35862. order: 900,
  35863. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  35864. enabled: true,
  35865. /** @prop {ModifierFn} */
  35866. fn: applyStyle,
  35867. /** @prop {Function} */
  35868. onLoad: applyStyleOnLoad,
  35869. /**
  35870. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  35871. * @prop {Boolean} gpuAcceleration=true
  35872. * If true, it uses the CSS 3D transformation to position the popper.
  35873. * Otherwise, it will use the `top` and `left` properties
  35874. */
  35875. gpuAcceleration: undefined
  35876. }
  35877. };
  35878. /**
  35879. * The `dataObject` is an object containing all the information used by Popper.js.
  35880. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  35881. * @name dataObject
  35882. * @property {Object} data.instance The Popper.js instance
  35883. * @property {String} data.placement Placement applied to popper
  35884. * @property {String} data.originalPlacement Placement originally defined on init
  35885. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  35886. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  35887. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  35888. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35889. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  35890. * @property {Object} data.boundaries Offsets of the popper boundaries
  35891. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  35892. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  35893. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  35894. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  35895. */
  35896. /**
  35897. * Default options provided to Popper.js constructor.<br />
  35898. * These can be overridden using the `options` argument of Popper.js.<br />
  35899. * To override an option, simply pass an object with the same
  35900. * structure of the `options` object, as the 3rd argument. For example:
  35901. * ```
  35902. * new Popper(ref, pop, {
  35903. * modifiers: {
  35904. * preventOverflow: { enabled: false }
  35905. * }
  35906. * })
  35907. * ```
  35908. * @type {Object}
  35909. * @static
  35910. * @memberof Popper
  35911. */
  35912. var Defaults = {
  35913. /**
  35914. * Popper's placement.
  35915. * @prop {Popper.placements} placement='bottom'
  35916. */
  35917. placement: 'bottom',
  35918. /**
  35919. * Set this to true if you want popper to position it self in 'fixed' mode
  35920. * @prop {Boolean} positionFixed=false
  35921. */
  35922. positionFixed: false,
  35923. /**
  35924. * Whether events (resize, scroll) are initially enabled.
  35925. * @prop {Boolean} eventsEnabled=true
  35926. */
  35927. eventsEnabled: true,
  35928. /**
  35929. * Set to true if you want to automatically remove the popper when
  35930. * you call the `destroy` method.
  35931. * @prop {Boolean} removeOnDestroy=false
  35932. */
  35933. removeOnDestroy: false,
  35934. /**
  35935. * Callback called when the popper is created.<br />
  35936. * By default, it is set to no-op.<br />
  35937. * Access Popper.js instance with `data.instance`.
  35938. * @prop {onCreate}
  35939. */
  35940. onCreate: function onCreate() {},
  35941. /**
  35942. * Callback called when the popper is updated. This callback is not called
  35943. * on the initialization/creation of the popper, but only on subsequent
  35944. * updates.<br />
  35945. * By default, it is set to no-op.<br />
  35946. * Access Popper.js instance with `data.instance`.
  35947. * @prop {onUpdate}
  35948. */
  35949. onUpdate: function onUpdate() {},
  35950. /**
  35951. * List of modifiers used to modify the offsets before they are applied to the popper.
  35952. * They provide most of the functionalities of Popper.js.
  35953. * @prop {modifiers}
  35954. */
  35955. modifiers: modifiers
  35956. };
  35957. /**
  35958. * @callback onCreate
  35959. * @param {dataObject} data
  35960. */
  35961. /**
  35962. * @callback onUpdate
  35963. * @param {dataObject} data
  35964. */
  35965. // Utils
  35966. // Methods
  35967. var Popper = function () {
  35968. /**
  35969. * Creates a new Popper.js instance.
  35970. * @class Popper
  35971. * @param {Element|referenceObject} reference - The reference element used to position the popper
  35972. * @param {Element} popper - The HTML / XML element used as the popper
  35973. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  35974. * @return {Object} instance - The generated Popper.js instance
  35975. */
  35976. function Popper(reference, popper) {
  35977. var _this = this;
  35978. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  35979. classCallCheck(this, Popper);
  35980. this.scheduleUpdate = function () {
  35981. return requestAnimationFrame(_this.update);
  35982. };
  35983. // make update() debounced, so that it only runs at most once-per-tick
  35984. this.update = debounce(this.update.bind(this));
  35985. // with {} we create a new object with the options inside it
  35986. this.options = _extends({}, Popper.Defaults, options);
  35987. // init state
  35988. this.state = {
  35989. isDestroyed: false,
  35990. isCreated: false,
  35991. scrollParents: []
  35992. };
  35993. // get reference and popper elements (allow jQuery wrappers)
  35994. this.reference = reference && reference.jquery ? reference[0] : reference;
  35995. this.popper = popper && popper.jquery ? popper[0] : popper;
  35996. // Deep merge modifiers options
  35997. this.options.modifiers = {};
  35998. Object.keys(_extends({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  35999. _this.options.modifiers[name] = _extends({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  36000. });
  36001. // Refactoring modifiers' list (Object => Array)
  36002. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  36003. return _extends({
  36004. name: name
  36005. }, _this.options.modifiers[name]);
  36006. })
  36007. // sort the modifiers by order
  36008. .sort(function (a, b) {
  36009. return a.order - b.order;
  36010. });
  36011. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  36012. // such code is executed in the same order of its modifier
  36013. // they could add new properties to their options configuration
  36014. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  36015. this.modifiers.forEach(function (modifierOptions) {
  36016. if (modifierOptions.enabled && isFunction(modifierOptions.onLoad)) {
  36017. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  36018. }
  36019. });
  36020. // fire the first update to position the popper in the right place
  36021. this.update();
  36022. var eventsEnabled = this.options.eventsEnabled;
  36023. if (eventsEnabled) {
  36024. // setup event listeners, they will take care of update the position in specific situations
  36025. this.enableEventListeners();
  36026. }
  36027. this.state.eventsEnabled = eventsEnabled;
  36028. }
  36029. // We can't use class properties because they don't get listed in the
  36030. // class prototype and break stuff like Sinon stubs
  36031. createClass(Popper, [{
  36032. key: 'update',
  36033. value: function update$$1() {
  36034. return update.call(this);
  36035. }
  36036. }, {
  36037. key: 'destroy',
  36038. value: function destroy$$1() {
  36039. return destroy.call(this);
  36040. }
  36041. }, {
  36042. key: 'enableEventListeners',
  36043. value: function enableEventListeners$$1() {
  36044. return enableEventListeners.call(this);
  36045. }
  36046. }, {
  36047. key: 'disableEventListeners',
  36048. value: function disableEventListeners$$1() {
  36049. return disableEventListeners.call(this);
  36050. }
  36051. /**
  36052. * Schedules an update. It will run on the next UI update available.
  36053. * @method scheduleUpdate
  36054. * @memberof Popper
  36055. */
  36056. /**
  36057. * Collection of utilities useful when writing custom modifiers.
  36058. * Starting from version 1.7, this method is available only if you
  36059. * include `popper-utils.js` before `popper.js`.
  36060. *
  36061. * **DEPRECATION**: This way to access PopperUtils is deprecated
  36062. * and will be removed in v2! Use the PopperUtils module directly instead.
  36063. * Due to the high instability of the methods contained in Utils, we can't
  36064. * guarantee them to follow semver. Use them at your own risk!
  36065. * @static
  36066. * @private
  36067. * @type {Object}
  36068. * @deprecated since version 1.8
  36069. * @member Utils
  36070. * @memberof Popper
  36071. */
  36072. }]);
  36073. return Popper;
  36074. }();
  36075. /**
  36076. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  36077. * and lets you use it as replacement of a real DOM node.<br />
  36078. * You can use this method to position a popper relatively to a set of coordinates
  36079. * in case you don't have a DOM node to use as reference.
  36080. *
  36081. * ```
  36082. * new Popper(referenceObject, popperNode);
  36083. * ```
  36084. *
  36085. * NB: This feature isn't supported in Internet Explorer 10.
  36086. * @name referenceObject
  36087. * @property {Function} data.getBoundingClientRect
  36088. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  36089. * @property {number} data.clientWidth
  36090. * An ES6 getter that will return the width of the virtual reference element.
  36091. * @property {number} data.clientHeight
  36092. * An ES6 getter that will return the height of the virtual reference element.
  36093. */
  36094. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  36095. Popper.placements = placements;
  36096. Popper.Defaults = Defaults;
  36097. /* harmony default export */ __webpack_exports__["default"] = (Popper);
  36098. //# sourceMappingURL=popper.js.map
  36099. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  36100. /***/ }),
  36101. /***/ "./node_modules/process/browser.js":
  36102. /*!*****************************************!*\
  36103. !*** ./node_modules/process/browser.js ***!
  36104. \*****************************************/
  36105. /*! no static exports found */
  36106. /***/ (function(module, exports) {
  36107. // shim for using process in browser
  36108. var process = module.exports = {};
  36109. // cached from whatever global is present so that test runners that stub it
  36110. // don't break things. But we need to wrap it in a try catch in case it is
  36111. // wrapped in strict mode code which doesn't define any globals. It's inside a
  36112. // function because try/catches deoptimize in certain engines.
  36113. var cachedSetTimeout;
  36114. var cachedClearTimeout;
  36115. function defaultSetTimout() {
  36116. throw new Error('setTimeout has not been defined');
  36117. }
  36118. function defaultClearTimeout () {
  36119. throw new Error('clearTimeout has not been defined');
  36120. }
  36121. (function () {
  36122. try {
  36123. if (typeof setTimeout === 'function') {
  36124. cachedSetTimeout = setTimeout;
  36125. } else {
  36126. cachedSetTimeout = defaultSetTimout;
  36127. }
  36128. } catch (e) {
  36129. cachedSetTimeout = defaultSetTimout;
  36130. }
  36131. try {
  36132. if (typeof clearTimeout === 'function') {
  36133. cachedClearTimeout = clearTimeout;
  36134. } else {
  36135. cachedClearTimeout = defaultClearTimeout;
  36136. }
  36137. } catch (e) {
  36138. cachedClearTimeout = defaultClearTimeout;
  36139. }
  36140. } ())
  36141. function runTimeout(fun) {
  36142. if (cachedSetTimeout === setTimeout) {
  36143. //normal enviroments in sane situations
  36144. return setTimeout(fun, 0);
  36145. }
  36146. // if setTimeout wasn't available but was latter defined
  36147. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  36148. cachedSetTimeout = setTimeout;
  36149. return setTimeout(fun, 0);
  36150. }
  36151. try {
  36152. // when when somebody has screwed with setTimeout but no I.E. maddness
  36153. return cachedSetTimeout(fun, 0);
  36154. } catch(e){
  36155. try {
  36156. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36157. return cachedSetTimeout.call(null, fun, 0);
  36158. } catch(e){
  36159. // 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
  36160. return cachedSetTimeout.call(this, fun, 0);
  36161. }
  36162. }
  36163. }
  36164. function runClearTimeout(marker) {
  36165. if (cachedClearTimeout === clearTimeout) {
  36166. //normal enviroments in sane situations
  36167. return clearTimeout(marker);
  36168. }
  36169. // if clearTimeout wasn't available but was latter defined
  36170. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  36171. cachedClearTimeout = clearTimeout;
  36172. return clearTimeout(marker);
  36173. }
  36174. try {
  36175. // when when somebody has screwed with setTimeout but no I.E. maddness
  36176. return cachedClearTimeout(marker);
  36177. } catch (e){
  36178. try {
  36179. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  36180. return cachedClearTimeout.call(null, marker);
  36181. } catch (e){
  36182. // 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.
  36183. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  36184. return cachedClearTimeout.call(this, marker);
  36185. }
  36186. }
  36187. }
  36188. var queue = [];
  36189. var draining = false;
  36190. var currentQueue;
  36191. var queueIndex = -1;
  36192. function cleanUpNextTick() {
  36193. if (!draining || !currentQueue) {
  36194. return;
  36195. }
  36196. draining = false;
  36197. if (currentQueue.length) {
  36198. queue = currentQueue.concat(queue);
  36199. } else {
  36200. queueIndex = -1;
  36201. }
  36202. if (queue.length) {
  36203. drainQueue();
  36204. }
  36205. }
  36206. function drainQueue() {
  36207. if (draining) {
  36208. return;
  36209. }
  36210. var timeout = runTimeout(cleanUpNextTick);
  36211. draining = true;
  36212. var len = queue.length;
  36213. while(len) {
  36214. currentQueue = queue;
  36215. queue = [];
  36216. while (++queueIndex < len) {
  36217. if (currentQueue) {
  36218. currentQueue[queueIndex].run();
  36219. }
  36220. }
  36221. queueIndex = -1;
  36222. len = queue.length;
  36223. }
  36224. currentQueue = null;
  36225. draining = false;
  36226. runClearTimeout(timeout);
  36227. }
  36228. process.nextTick = function (fun) {
  36229. var args = new Array(arguments.length - 1);
  36230. if (arguments.length > 1) {
  36231. for (var i = 1; i < arguments.length; i++) {
  36232. args[i - 1] = arguments[i];
  36233. }
  36234. }
  36235. queue.push(new Item(fun, args));
  36236. if (queue.length === 1 && !draining) {
  36237. runTimeout(drainQueue);
  36238. }
  36239. };
  36240. // v8 likes predictible objects
  36241. function Item(fun, array) {
  36242. this.fun = fun;
  36243. this.array = array;
  36244. }
  36245. Item.prototype.run = function () {
  36246. this.fun.apply(null, this.array);
  36247. };
  36248. process.title = 'browser';
  36249. process.browser = true;
  36250. process.env = {};
  36251. process.argv = [];
  36252. process.version = ''; // empty string to avoid regexp issues
  36253. process.versions = {};
  36254. function noop() {}
  36255. process.on = noop;
  36256. process.addListener = noop;
  36257. process.once = noop;
  36258. process.off = noop;
  36259. process.removeListener = noop;
  36260. process.removeAllListeners = noop;
  36261. process.emit = noop;
  36262. process.prependListener = noop;
  36263. process.prependOnceListener = noop;
  36264. process.listeners = function (name) { return [] }
  36265. process.binding = function (name) {
  36266. throw new Error('process.binding is not supported');
  36267. };
  36268. process.cwd = function () { return '/' };
  36269. process.chdir = function (dir) {
  36270. throw new Error('process.chdir is not supported');
  36271. };
  36272. process.umask = function() { return 0; };
  36273. /***/ }),
  36274. /***/ "./node_modules/pusher-js/dist/web/pusher.js":
  36275. /*!***************************************************!*\
  36276. !*** ./node_modules/pusher-js/dist/web/pusher.js ***!
  36277. \***************************************************/
  36278. /*! no static exports found */
  36279. /***/ (function(module, exports, __webpack_require__) {
  36280. /* WEBPACK VAR INJECTION */(function(Buffer) {/*!
  36281. * Pusher JavaScript Library v5.0.3
  36282. * https://pusher.com/
  36283. *
  36284. * Copyright 2017, Pusher
  36285. * Released under the MIT licence.
  36286. */
  36287. (function webpackUniversalModuleDefinition(root, factory) {
  36288. if(true)
  36289. module.exports = factory();
  36290. else {}
  36291. })(window, function() {
  36292. return /******/ (function(modules) { // webpackBootstrap
  36293. /******/ // The module cache
  36294. /******/ var installedModules = {};
  36295. /******/
  36296. /******/ // The require function
  36297. /******/ function __webpack_require__(moduleId) {
  36298. /******/
  36299. /******/ // Check if module is in cache
  36300. /******/ if(installedModules[moduleId]) {
  36301. /******/ return installedModules[moduleId].exports;
  36302. /******/ }
  36303. /******/ // Create a new module (and put it into the cache)
  36304. /******/ var module = installedModules[moduleId] = {
  36305. /******/ i: moduleId,
  36306. /******/ l: false,
  36307. /******/ exports: {}
  36308. /******/ };
  36309. /******/
  36310. /******/ // Execute the module function
  36311. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  36312. /******/
  36313. /******/ // Flag the module as loaded
  36314. /******/ module.l = true;
  36315. /******/
  36316. /******/ // Return the exports of the module
  36317. /******/ return module.exports;
  36318. /******/ }
  36319. /******/
  36320. /******/
  36321. /******/ // expose the modules object (__webpack_modules__)
  36322. /******/ __webpack_require__.m = modules;
  36323. /******/
  36324. /******/ // expose the module cache
  36325. /******/ __webpack_require__.c = installedModules;
  36326. /******/
  36327. /******/ // define getter function for harmony exports
  36328. /******/ __webpack_require__.d = function(exports, name, getter) {
  36329. /******/ if(!__webpack_require__.o(exports, name)) {
  36330. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  36331. /******/ }
  36332. /******/ };
  36333. /******/
  36334. /******/ // define __esModule on exports
  36335. /******/ __webpack_require__.r = function(exports) {
  36336. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  36337. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  36338. /******/ }
  36339. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  36340. /******/ };
  36341. /******/
  36342. /******/ // create a fake namespace object
  36343. /******/ // mode & 1: value is a module id, require it
  36344. /******/ // mode & 2: merge all properties of value into the ns
  36345. /******/ // mode & 4: return value when already ns object
  36346. /******/ // mode & 8|1: behave like require
  36347. /******/ __webpack_require__.t = function(value, mode) {
  36348. /******/ if(mode & 1) value = __webpack_require__(value);
  36349. /******/ if(mode & 8) return value;
  36350. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  36351. /******/ var ns = Object.create(null);
  36352. /******/ __webpack_require__.r(ns);
  36353. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  36354. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  36355. /******/ return ns;
  36356. /******/ };
  36357. /******/
  36358. /******/ // getDefaultExport function for compatibility with non-harmony modules
  36359. /******/ __webpack_require__.n = function(module) {
  36360. /******/ var getter = module && module.__esModule ?
  36361. /******/ function getDefault() { return module['default']; } :
  36362. /******/ function getModuleExports() { return module; };
  36363. /******/ __webpack_require__.d(getter, 'a', getter);
  36364. /******/ return getter;
  36365. /******/ };
  36366. /******/
  36367. /******/ // Object.prototype.hasOwnProperty.call
  36368. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  36369. /******/
  36370. /******/ // __webpack_public_path__
  36371. /******/ __webpack_require__.p = "";
  36372. /******/
  36373. /******/
  36374. /******/ // Load entry module and return exports
  36375. /******/ return __webpack_require__(__webpack_require__.s = 2);
  36376. /******/ })
  36377. /************************************************************************/
  36378. /******/ ([
  36379. /* 0 */
  36380. /***/ (function(module, exports, __webpack_require__) {
  36381. (function(nacl) {
  36382. 'use strict';
  36383. // Ported in 2014 by Dmitry Chestnykh and Devi Mandiri.
  36384. // Public domain.
  36385. //
  36386. // Implementation derived from TweetNaCl version 20140427.
  36387. // See for details: http://tweetnacl.cr.yp.to/
  36388. var gf = function(init) {
  36389. var i, r = new Float64Array(16);
  36390. if (init) for (i = 0; i < init.length; i++) r[i] = init[i];
  36391. return r;
  36392. };
  36393. // Pluggable, initialized in high-level API below.
  36394. var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };
  36395. var _0 = new Uint8Array(16);
  36396. var _9 = new Uint8Array(32); _9[0] = 9;
  36397. var gf0 = gf(),
  36398. gf1 = gf([1]),
  36399. _121665 = gf([0xdb41, 1]),
  36400. D = gf([0x78a3, 0x1359, 0x4dca, 0x75eb, 0xd8ab, 0x4141, 0x0a4d, 0x0070, 0xe898, 0x7779, 0x4079, 0x8cc7, 0xfe73, 0x2b6f, 0x6cee, 0x5203]),
  36401. D2 = gf([0xf159, 0x26b2, 0x9b94, 0xebd6, 0xb156, 0x8283, 0x149a, 0x00e0, 0xd130, 0xeef3, 0x80f2, 0x198e, 0xfce7, 0x56df, 0xd9dc, 0x2406]),
  36402. X = gf([0xd51a, 0x8f25, 0x2d60, 0xc956, 0xa7b2, 0x9525, 0xc760, 0x692c, 0xdc5c, 0xfdd6, 0xe231, 0xc0a4, 0x53fe, 0xcd6e, 0x36d3, 0x2169]),
  36403. Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]),
  36404. I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]);
  36405. function ts64(x, i, h, l) {
  36406. x[i] = (h >> 24) & 0xff;
  36407. x[i+1] = (h >> 16) & 0xff;
  36408. x[i+2] = (h >> 8) & 0xff;
  36409. x[i+3] = h & 0xff;
  36410. x[i+4] = (l >> 24) & 0xff;
  36411. x[i+5] = (l >> 16) & 0xff;
  36412. x[i+6] = (l >> 8) & 0xff;
  36413. x[i+7] = l & 0xff;
  36414. }
  36415. function vn(x, xi, y, yi, n) {
  36416. var i,d = 0;
  36417. for (i = 0; i < n; i++) d |= x[xi+i]^y[yi+i];
  36418. return (1 & ((d - 1) >>> 8)) - 1;
  36419. }
  36420. function crypto_verify_16(x, xi, y, yi) {
  36421. return vn(x,xi,y,yi,16);
  36422. }
  36423. function crypto_verify_32(x, xi, y, yi) {
  36424. return vn(x,xi,y,yi,32);
  36425. }
  36426. function core_salsa20(o, p, k, c) {
  36427. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  36428. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  36429. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  36430. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  36431. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  36432. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  36433. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  36434. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  36435. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  36436. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  36437. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  36438. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  36439. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  36440. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  36441. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  36442. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  36443. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  36444. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  36445. x15 = j15, u;
  36446. for (var i = 0; i < 20; i += 2) {
  36447. u = x0 + x12 | 0;
  36448. x4 ^= u<<7 | u>>>(32-7);
  36449. u = x4 + x0 | 0;
  36450. x8 ^= u<<9 | u>>>(32-9);
  36451. u = x8 + x4 | 0;
  36452. x12 ^= u<<13 | u>>>(32-13);
  36453. u = x12 + x8 | 0;
  36454. x0 ^= u<<18 | u>>>(32-18);
  36455. u = x5 + x1 | 0;
  36456. x9 ^= u<<7 | u>>>(32-7);
  36457. u = x9 + x5 | 0;
  36458. x13 ^= u<<9 | u>>>(32-9);
  36459. u = x13 + x9 | 0;
  36460. x1 ^= u<<13 | u>>>(32-13);
  36461. u = x1 + x13 | 0;
  36462. x5 ^= u<<18 | u>>>(32-18);
  36463. u = x10 + x6 | 0;
  36464. x14 ^= u<<7 | u>>>(32-7);
  36465. u = x14 + x10 | 0;
  36466. x2 ^= u<<9 | u>>>(32-9);
  36467. u = x2 + x14 | 0;
  36468. x6 ^= u<<13 | u>>>(32-13);
  36469. u = x6 + x2 | 0;
  36470. x10 ^= u<<18 | u>>>(32-18);
  36471. u = x15 + x11 | 0;
  36472. x3 ^= u<<7 | u>>>(32-7);
  36473. u = x3 + x15 | 0;
  36474. x7 ^= u<<9 | u>>>(32-9);
  36475. u = x7 + x3 | 0;
  36476. x11 ^= u<<13 | u>>>(32-13);
  36477. u = x11 + x7 | 0;
  36478. x15 ^= u<<18 | u>>>(32-18);
  36479. u = x0 + x3 | 0;
  36480. x1 ^= u<<7 | u>>>(32-7);
  36481. u = x1 + x0 | 0;
  36482. x2 ^= u<<9 | u>>>(32-9);
  36483. u = x2 + x1 | 0;
  36484. x3 ^= u<<13 | u>>>(32-13);
  36485. u = x3 + x2 | 0;
  36486. x0 ^= u<<18 | u>>>(32-18);
  36487. u = x5 + x4 | 0;
  36488. x6 ^= u<<7 | u>>>(32-7);
  36489. u = x6 + x5 | 0;
  36490. x7 ^= u<<9 | u>>>(32-9);
  36491. u = x7 + x6 | 0;
  36492. x4 ^= u<<13 | u>>>(32-13);
  36493. u = x4 + x7 | 0;
  36494. x5 ^= u<<18 | u>>>(32-18);
  36495. u = x10 + x9 | 0;
  36496. x11 ^= u<<7 | u>>>(32-7);
  36497. u = x11 + x10 | 0;
  36498. x8 ^= u<<9 | u>>>(32-9);
  36499. u = x8 + x11 | 0;
  36500. x9 ^= u<<13 | u>>>(32-13);
  36501. u = x9 + x8 | 0;
  36502. x10 ^= u<<18 | u>>>(32-18);
  36503. u = x15 + x14 | 0;
  36504. x12 ^= u<<7 | u>>>(32-7);
  36505. u = x12 + x15 | 0;
  36506. x13 ^= u<<9 | u>>>(32-9);
  36507. u = x13 + x12 | 0;
  36508. x14 ^= u<<13 | u>>>(32-13);
  36509. u = x14 + x13 | 0;
  36510. x15 ^= u<<18 | u>>>(32-18);
  36511. }
  36512. x0 = x0 + j0 | 0;
  36513. x1 = x1 + j1 | 0;
  36514. x2 = x2 + j2 | 0;
  36515. x3 = x3 + j3 | 0;
  36516. x4 = x4 + j4 | 0;
  36517. x5 = x5 + j5 | 0;
  36518. x6 = x6 + j6 | 0;
  36519. x7 = x7 + j7 | 0;
  36520. x8 = x8 + j8 | 0;
  36521. x9 = x9 + j9 | 0;
  36522. x10 = x10 + j10 | 0;
  36523. x11 = x11 + j11 | 0;
  36524. x12 = x12 + j12 | 0;
  36525. x13 = x13 + j13 | 0;
  36526. x14 = x14 + j14 | 0;
  36527. x15 = x15 + j15 | 0;
  36528. o[ 0] = x0 >>> 0 & 0xff;
  36529. o[ 1] = x0 >>> 8 & 0xff;
  36530. o[ 2] = x0 >>> 16 & 0xff;
  36531. o[ 3] = x0 >>> 24 & 0xff;
  36532. o[ 4] = x1 >>> 0 & 0xff;
  36533. o[ 5] = x1 >>> 8 & 0xff;
  36534. o[ 6] = x1 >>> 16 & 0xff;
  36535. o[ 7] = x1 >>> 24 & 0xff;
  36536. o[ 8] = x2 >>> 0 & 0xff;
  36537. o[ 9] = x2 >>> 8 & 0xff;
  36538. o[10] = x2 >>> 16 & 0xff;
  36539. o[11] = x2 >>> 24 & 0xff;
  36540. o[12] = x3 >>> 0 & 0xff;
  36541. o[13] = x3 >>> 8 & 0xff;
  36542. o[14] = x3 >>> 16 & 0xff;
  36543. o[15] = x3 >>> 24 & 0xff;
  36544. o[16] = x4 >>> 0 & 0xff;
  36545. o[17] = x4 >>> 8 & 0xff;
  36546. o[18] = x4 >>> 16 & 0xff;
  36547. o[19] = x4 >>> 24 & 0xff;
  36548. o[20] = x5 >>> 0 & 0xff;
  36549. o[21] = x5 >>> 8 & 0xff;
  36550. o[22] = x5 >>> 16 & 0xff;
  36551. o[23] = x5 >>> 24 & 0xff;
  36552. o[24] = x6 >>> 0 & 0xff;
  36553. o[25] = x6 >>> 8 & 0xff;
  36554. o[26] = x6 >>> 16 & 0xff;
  36555. o[27] = x6 >>> 24 & 0xff;
  36556. o[28] = x7 >>> 0 & 0xff;
  36557. o[29] = x7 >>> 8 & 0xff;
  36558. o[30] = x7 >>> 16 & 0xff;
  36559. o[31] = x7 >>> 24 & 0xff;
  36560. o[32] = x8 >>> 0 & 0xff;
  36561. o[33] = x8 >>> 8 & 0xff;
  36562. o[34] = x8 >>> 16 & 0xff;
  36563. o[35] = x8 >>> 24 & 0xff;
  36564. o[36] = x9 >>> 0 & 0xff;
  36565. o[37] = x9 >>> 8 & 0xff;
  36566. o[38] = x9 >>> 16 & 0xff;
  36567. o[39] = x9 >>> 24 & 0xff;
  36568. o[40] = x10 >>> 0 & 0xff;
  36569. o[41] = x10 >>> 8 & 0xff;
  36570. o[42] = x10 >>> 16 & 0xff;
  36571. o[43] = x10 >>> 24 & 0xff;
  36572. o[44] = x11 >>> 0 & 0xff;
  36573. o[45] = x11 >>> 8 & 0xff;
  36574. o[46] = x11 >>> 16 & 0xff;
  36575. o[47] = x11 >>> 24 & 0xff;
  36576. o[48] = x12 >>> 0 & 0xff;
  36577. o[49] = x12 >>> 8 & 0xff;
  36578. o[50] = x12 >>> 16 & 0xff;
  36579. o[51] = x12 >>> 24 & 0xff;
  36580. o[52] = x13 >>> 0 & 0xff;
  36581. o[53] = x13 >>> 8 & 0xff;
  36582. o[54] = x13 >>> 16 & 0xff;
  36583. o[55] = x13 >>> 24 & 0xff;
  36584. o[56] = x14 >>> 0 & 0xff;
  36585. o[57] = x14 >>> 8 & 0xff;
  36586. o[58] = x14 >>> 16 & 0xff;
  36587. o[59] = x14 >>> 24 & 0xff;
  36588. o[60] = x15 >>> 0 & 0xff;
  36589. o[61] = x15 >>> 8 & 0xff;
  36590. o[62] = x15 >>> 16 & 0xff;
  36591. o[63] = x15 >>> 24 & 0xff;
  36592. }
  36593. function core_hsalsa20(o,p,k,c) {
  36594. var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24,
  36595. j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24,
  36596. j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24,
  36597. j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24,
  36598. j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24,
  36599. j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24,
  36600. j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24,
  36601. j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24,
  36602. j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24,
  36603. j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24,
  36604. j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24,
  36605. j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24,
  36606. j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24,
  36607. j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24,
  36608. j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24,
  36609. j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24;
  36610. var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7,
  36611. x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14,
  36612. x15 = j15, u;
  36613. for (var i = 0; i < 20; i += 2) {
  36614. u = x0 + x12 | 0;
  36615. x4 ^= u<<7 | u>>>(32-7);
  36616. u = x4 + x0 | 0;
  36617. x8 ^= u<<9 | u>>>(32-9);
  36618. u = x8 + x4 | 0;
  36619. x12 ^= u<<13 | u>>>(32-13);
  36620. u = x12 + x8 | 0;
  36621. x0 ^= u<<18 | u>>>(32-18);
  36622. u = x5 + x1 | 0;
  36623. x9 ^= u<<7 | u>>>(32-7);
  36624. u = x9 + x5 | 0;
  36625. x13 ^= u<<9 | u>>>(32-9);
  36626. u = x13 + x9 | 0;
  36627. x1 ^= u<<13 | u>>>(32-13);
  36628. u = x1 + x13 | 0;
  36629. x5 ^= u<<18 | u>>>(32-18);
  36630. u = x10 + x6 | 0;
  36631. x14 ^= u<<7 | u>>>(32-7);
  36632. u = x14 + x10 | 0;
  36633. x2 ^= u<<9 | u>>>(32-9);
  36634. u = x2 + x14 | 0;
  36635. x6 ^= u<<13 | u>>>(32-13);
  36636. u = x6 + x2 | 0;
  36637. x10 ^= u<<18 | u>>>(32-18);
  36638. u = x15 + x11 | 0;
  36639. x3 ^= u<<7 | u>>>(32-7);
  36640. u = x3 + x15 | 0;
  36641. x7 ^= u<<9 | u>>>(32-9);
  36642. u = x7 + x3 | 0;
  36643. x11 ^= u<<13 | u>>>(32-13);
  36644. u = x11 + x7 | 0;
  36645. x15 ^= u<<18 | u>>>(32-18);
  36646. u = x0 + x3 | 0;
  36647. x1 ^= u<<7 | u>>>(32-7);
  36648. u = x1 + x0 | 0;
  36649. x2 ^= u<<9 | u>>>(32-9);
  36650. u = x2 + x1 | 0;
  36651. x3 ^= u<<13 | u>>>(32-13);
  36652. u = x3 + x2 | 0;
  36653. x0 ^= u<<18 | u>>>(32-18);
  36654. u = x5 + x4 | 0;
  36655. x6 ^= u<<7 | u>>>(32-7);
  36656. u = x6 + x5 | 0;
  36657. x7 ^= u<<9 | u>>>(32-9);
  36658. u = x7 + x6 | 0;
  36659. x4 ^= u<<13 | u>>>(32-13);
  36660. u = x4 + x7 | 0;
  36661. x5 ^= u<<18 | u>>>(32-18);
  36662. u = x10 + x9 | 0;
  36663. x11 ^= u<<7 | u>>>(32-7);
  36664. u = x11 + x10 | 0;
  36665. x8 ^= u<<9 | u>>>(32-9);
  36666. u = x8 + x11 | 0;
  36667. x9 ^= u<<13 | u>>>(32-13);
  36668. u = x9 + x8 | 0;
  36669. x10 ^= u<<18 | u>>>(32-18);
  36670. u = x15 + x14 | 0;
  36671. x12 ^= u<<7 | u>>>(32-7);
  36672. u = x12 + x15 | 0;
  36673. x13 ^= u<<9 | u>>>(32-9);
  36674. u = x13 + x12 | 0;
  36675. x14 ^= u<<13 | u>>>(32-13);
  36676. u = x14 + x13 | 0;
  36677. x15 ^= u<<18 | u>>>(32-18);
  36678. }
  36679. o[ 0] = x0 >>> 0 & 0xff;
  36680. o[ 1] = x0 >>> 8 & 0xff;
  36681. o[ 2] = x0 >>> 16 & 0xff;
  36682. o[ 3] = x0 >>> 24 & 0xff;
  36683. o[ 4] = x5 >>> 0 & 0xff;
  36684. o[ 5] = x5 >>> 8 & 0xff;
  36685. o[ 6] = x5 >>> 16 & 0xff;
  36686. o[ 7] = x5 >>> 24 & 0xff;
  36687. o[ 8] = x10 >>> 0 & 0xff;
  36688. o[ 9] = x10 >>> 8 & 0xff;
  36689. o[10] = x10 >>> 16 & 0xff;
  36690. o[11] = x10 >>> 24 & 0xff;
  36691. o[12] = x15 >>> 0 & 0xff;
  36692. o[13] = x15 >>> 8 & 0xff;
  36693. o[14] = x15 >>> 16 & 0xff;
  36694. o[15] = x15 >>> 24 & 0xff;
  36695. o[16] = x6 >>> 0 & 0xff;
  36696. o[17] = x6 >>> 8 & 0xff;
  36697. o[18] = x6 >>> 16 & 0xff;
  36698. o[19] = x6 >>> 24 & 0xff;
  36699. o[20] = x7 >>> 0 & 0xff;
  36700. o[21] = x7 >>> 8 & 0xff;
  36701. o[22] = x7 >>> 16 & 0xff;
  36702. o[23] = x7 >>> 24 & 0xff;
  36703. o[24] = x8 >>> 0 & 0xff;
  36704. o[25] = x8 >>> 8 & 0xff;
  36705. o[26] = x8 >>> 16 & 0xff;
  36706. o[27] = x8 >>> 24 & 0xff;
  36707. o[28] = x9 >>> 0 & 0xff;
  36708. o[29] = x9 >>> 8 & 0xff;
  36709. o[30] = x9 >>> 16 & 0xff;
  36710. o[31] = x9 >>> 24 & 0xff;
  36711. }
  36712. function crypto_core_salsa20(out,inp,k,c) {
  36713. core_salsa20(out,inp,k,c);
  36714. }
  36715. function crypto_core_hsalsa20(out,inp,k,c) {
  36716. core_hsalsa20(out,inp,k,c);
  36717. }
  36718. var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
  36719. // "expand 32-byte k"
  36720. function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  36721. var z = new Uint8Array(16), x = new Uint8Array(64);
  36722. var u, i;
  36723. for (i = 0; i < 16; i++) z[i] = 0;
  36724. for (i = 0; i < 8; i++) z[i] = n[i];
  36725. while (b >= 64) {
  36726. crypto_core_salsa20(x,z,k,sigma);
  36727. for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  36728. u = 1;
  36729. for (i = 8; i < 16; i++) {
  36730. u = u + (z[i] & 0xff) | 0;
  36731. z[i] = u & 0xff;
  36732. u >>>= 8;
  36733. }
  36734. b -= 64;
  36735. cpos += 64;
  36736. mpos += 64;
  36737. }
  36738. if (b > 0) {
  36739. crypto_core_salsa20(x,z,k,sigma);
  36740. for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  36741. }
  36742. return 0;
  36743. }
  36744. function crypto_stream_salsa20(c,cpos,b,n,k) {
  36745. var z = new Uint8Array(16), x = new Uint8Array(64);
  36746. var u, i;
  36747. for (i = 0; i < 16; i++) z[i] = 0;
  36748. for (i = 0; i < 8; i++) z[i] = n[i];
  36749. while (b >= 64) {
  36750. crypto_core_salsa20(x,z,k,sigma);
  36751. for (i = 0; i < 64; i++) c[cpos+i] = x[i];
  36752. u = 1;
  36753. for (i = 8; i < 16; i++) {
  36754. u = u + (z[i] & 0xff) | 0;
  36755. z[i] = u & 0xff;
  36756. u >>>= 8;
  36757. }
  36758. b -= 64;
  36759. cpos += 64;
  36760. }
  36761. if (b > 0) {
  36762. crypto_core_salsa20(x,z,k,sigma);
  36763. for (i = 0; i < b; i++) c[cpos+i] = x[i];
  36764. }
  36765. return 0;
  36766. }
  36767. function crypto_stream(c,cpos,d,n,k) {
  36768. var s = new Uint8Array(32);
  36769. crypto_core_hsalsa20(s,n,k,sigma);
  36770. var sn = new Uint8Array(8);
  36771. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  36772. return crypto_stream_salsa20(c,cpos,d,sn,s);
  36773. }
  36774. function crypto_stream_xor(c,cpos,m,mpos,d,n,k) {
  36775. var s = new Uint8Array(32);
  36776. crypto_core_hsalsa20(s,n,k,sigma);
  36777. var sn = new Uint8Array(8);
  36778. for (var i = 0; i < 8; i++) sn[i] = n[i+16];
  36779. return crypto_stream_salsa20_xor(c,cpos,m,mpos,d,sn,s);
  36780. }
  36781. /*
  36782. * Port of Andrew Moon's Poly1305-donna-16. Public domain.
  36783. * https://github.com/floodyberry/poly1305-donna
  36784. */
  36785. var poly1305 = function(key) {
  36786. this.buffer = new Uint8Array(16);
  36787. this.r = new Uint16Array(10);
  36788. this.h = new Uint16Array(10);
  36789. this.pad = new Uint16Array(8);
  36790. this.leftover = 0;
  36791. this.fin = 0;
  36792. var t0, t1, t2, t3, t4, t5, t6, t7;
  36793. t0 = key[ 0] & 0xff | (key[ 1] & 0xff) << 8; this.r[0] = ( t0 ) & 0x1fff;
  36794. t1 = key[ 2] & 0xff | (key[ 3] & 0xff) << 8; this.r[1] = ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  36795. t2 = key[ 4] & 0xff | (key[ 5] & 0xff) << 8; this.r[2] = ((t1 >>> 10) | (t2 << 6)) & 0x1f03;
  36796. t3 = key[ 6] & 0xff | (key[ 7] & 0xff) << 8; this.r[3] = ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  36797. t4 = key[ 8] & 0xff | (key[ 9] & 0xff) << 8; this.r[4] = ((t3 >>> 4) | (t4 << 12)) & 0x00ff;
  36798. this.r[5] = ((t4 >>> 1)) & 0x1ffe;
  36799. t5 = key[10] & 0xff | (key[11] & 0xff) << 8; this.r[6] = ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  36800. t6 = key[12] & 0xff | (key[13] & 0xff) << 8; this.r[7] = ((t5 >>> 11) | (t6 << 5)) & 0x1f81;
  36801. t7 = key[14] & 0xff | (key[15] & 0xff) << 8; this.r[8] = ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  36802. this.r[9] = ((t7 >>> 5)) & 0x007f;
  36803. this.pad[0] = key[16] & 0xff | (key[17] & 0xff) << 8;
  36804. this.pad[1] = key[18] & 0xff | (key[19] & 0xff) << 8;
  36805. this.pad[2] = key[20] & 0xff | (key[21] & 0xff) << 8;
  36806. this.pad[3] = key[22] & 0xff | (key[23] & 0xff) << 8;
  36807. this.pad[4] = key[24] & 0xff | (key[25] & 0xff) << 8;
  36808. this.pad[5] = key[26] & 0xff | (key[27] & 0xff) << 8;
  36809. this.pad[6] = key[28] & 0xff | (key[29] & 0xff) << 8;
  36810. this.pad[7] = key[30] & 0xff | (key[31] & 0xff) << 8;
  36811. };
  36812. poly1305.prototype.blocks = function(m, mpos, bytes) {
  36813. var hibit = this.fin ? 0 : (1 << 11);
  36814. var t0, t1, t2, t3, t4, t5, t6, t7, c;
  36815. var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
  36816. var h0 = this.h[0],
  36817. h1 = this.h[1],
  36818. h2 = this.h[2],
  36819. h3 = this.h[3],
  36820. h4 = this.h[4],
  36821. h5 = this.h[5],
  36822. h6 = this.h[6],
  36823. h7 = this.h[7],
  36824. h8 = this.h[8],
  36825. h9 = this.h[9];
  36826. var r0 = this.r[0],
  36827. r1 = this.r[1],
  36828. r2 = this.r[2],
  36829. r3 = this.r[3],
  36830. r4 = this.r[4],
  36831. r5 = this.r[5],
  36832. r6 = this.r[6],
  36833. r7 = this.r[7],
  36834. r8 = this.r[8],
  36835. r9 = this.r[9];
  36836. while (bytes >= 16) {
  36837. t0 = m[mpos+ 0] & 0xff | (m[mpos+ 1] & 0xff) << 8; h0 += ( t0 ) & 0x1fff;
  36838. t1 = m[mpos+ 2] & 0xff | (m[mpos+ 3] & 0xff) << 8; h1 += ((t0 >>> 13) | (t1 << 3)) & 0x1fff;
  36839. t2 = m[mpos+ 4] & 0xff | (m[mpos+ 5] & 0xff) << 8; h2 += ((t1 >>> 10) | (t2 << 6)) & 0x1fff;
  36840. t3 = m[mpos+ 6] & 0xff | (m[mpos+ 7] & 0xff) << 8; h3 += ((t2 >>> 7) | (t3 << 9)) & 0x1fff;
  36841. t4 = m[mpos+ 8] & 0xff | (m[mpos+ 9] & 0xff) << 8; h4 += ((t3 >>> 4) | (t4 << 12)) & 0x1fff;
  36842. h5 += ((t4 >>> 1)) & 0x1fff;
  36843. t5 = m[mpos+10] & 0xff | (m[mpos+11] & 0xff) << 8; h6 += ((t4 >>> 14) | (t5 << 2)) & 0x1fff;
  36844. t6 = m[mpos+12] & 0xff | (m[mpos+13] & 0xff) << 8; h7 += ((t5 >>> 11) | (t6 << 5)) & 0x1fff;
  36845. t7 = m[mpos+14] & 0xff | (m[mpos+15] & 0xff) << 8; h8 += ((t6 >>> 8) | (t7 << 8)) & 0x1fff;
  36846. h9 += ((t7 >>> 5)) | hibit;
  36847. c = 0;
  36848. d0 = c;
  36849. d0 += h0 * r0;
  36850. d0 += h1 * (5 * r9);
  36851. d0 += h2 * (5 * r8);
  36852. d0 += h3 * (5 * r7);
  36853. d0 += h4 * (5 * r6);
  36854. c = (d0 >>> 13); d0 &= 0x1fff;
  36855. d0 += h5 * (5 * r5);
  36856. d0 += h6 * (5 * r4);
  36857. d0 += h7 * (5 * r3);
  36858. d0 += h8 * (5 * r2);
  36859. d0 += h9 * (5 * r1);
  36860. c += (d0 >>> 13); d0 &= 0x1fff;
  36861. d1 = c;
  36862. d1 += h0 * r1;
  36863. d1 += h1 * r0;
  36864. d1 += h2 * (5 * r9);
  36865. d1 += h3 * (5 * r8);
  36866. d1 += h4 * (5 * r7);
  36867. c = (d1 >>> 13); d1 &= 0x1fff;
  36868. d1 += h5 * (5 * r6);
  36869. d1 += h6 * (5 * r5);
  36870. d1 += h7 * (5 * r4);
  36871. d1 += h8 * (5 * r3);
  36872. d1 += h9 * (5 * r2);
  36873. c += (d1 >>> 13); d1 &= 0x1fff;
  36874. d2 = c;
  36875. d2 += h0 * r2;
  36876. d2 += h1 * r1;
  36877. d2 += h2 * r0;
  36878. d2 += h3 * (5 * r9);
  36879. d2 += h4 * (5 * r8);
  36880. c = (d2 >>> 13); d2 &= 0x1fff;
  36881. d2 += h5 * (5 * r7);
  36882. d2 += h6 * (5 * r6);
  36883. d2 += h7 * (5 * r5);
  36884. d2 += h8 * (5 * r4);
  36885. d2 += h9 * (5 * r3);
  36886. c += (d2 >>> 13); d2 &= 0x1fff;
  36887. d3 = c;
  36888. d3 += h0 * r3;
  36889. d3 += h1 * r2;
  36890. d3 += h2 * r1;
  36891. d3 += h3 * r0;
  36892. d3 += h4 * (5 * r9);
  36893. c = (d3 >>> 13); d3 &= 0x1fff;
  36894. d3 += h5 * (5 * r8);
  36895. d3 += h6 * (5 * r7);
  36896. d3 += h7 * (5 * r6);
  36897. d3 += h8 * (5 * r5);
  36898. d3 += h9 * (5 * r4);
  36899. c += (d3 >>> 13); d3 &= 0x1fff;
  36900. d4 = c;
  36901. d4 += h0 * r4;
  36902. d4 += h1 * r3;
  36903. d4 += h2 * r2;
  36904. d4 += h3 * r1;
  36905. d4 += h4 * r0;
  36906. c = (d4 >>> 13); d4 &= 0x1fff;
  36907. d4 += h5 * (5 * r9);
  36908. d4 += h6 * (5 * r8);
  36909. d4 += h7 * (5 * r7);
  36910. d4 += h8 * (5 * r6);
  36911. d4 += h9 * (5 * r5);
  36912. c += (d4 >>> 13); d4 &= 0x1fff;
  36913. d5 = c;
  36914. d5 += h0 * r5;
  36915. d5 += h1 * r4;
  36916. d5 += h2 * r3;
  36917. d5 += h3 * r2;
  36918. d5 += h4 * r1;
  36919. c = (d5 >>> 13); d5 &= 0x1fff;
  36920. d5 += h5 * r0;
  36921. d5 += h6 * (5 * r9);
  36922. d5 += h7 * (5 * r8);
  36923. d5 += h8 * (5 * r7);
  36924. d5 += h9 * (5 * r6);
  36925. c += (d5 >>> 13); d5 &= 0x1fff;
  36926. d6 = c;
  36927. d6 += h0 * r6;
  36928. d6 += h1 * r5;
  36929. d6 += h2 * r4;
  36930. d6 += h3 * r3;
  36931. d6 += h4 * r2;
  36932. c = (d6 >>> 13); d6 &= 0x1fff;
  36933. d6 += h5 * r1;
  36934. d6 += h6 * r0;
  36935. d6 += h7 * (5 * r9);
  36936. d6 += h8 * (5 * r8);
  36937. d6 += h9 * (5 * r7);
  36938. c += (d6 >>> 13); d6 &= 0x1fff;
  36939. d7 = c;
  36940. d7 += h0 * r7;
  36941. d7 += h1 * r6;
  36942. d7 += h2 * r5;
  36943. d7 += h3 * r4;
  36944. d7 += h4 * r3;
  36945. c = (d7 >>> 13); d7 &= 0x1fff;
  36946. d7 += h5 * r2;
  36947. d7 += h6 * r1;
  36948. d7 += h7 * r0;
  36949. d7 += h8 * (5 * r9);
  36950. d7 += h9 * (5 * r8);
  36951. c += (d7 >>> 13); d7 &= 0x1fff;
  36952. d8 = c;
  36953. d8 += h0 * r8;
  36954. d8 += h1 * r7;
  36955. d8 += h2 * r6;
  36956. d8 += h3 * r5;
  36957. d8 += h4 * r4;
  36958. c = (d8 >>> 13); d8 &= 0x1fff;
  36959. d8 += h5 * r3;
  36960. d8 += h6 * r2;
  36961. d8 += h7 * r1;
  36962. d8 += h8 * r0;
  36963. d8 += h9 * (5 * r9);
  36964. c += (d8 >>> 13); d8 &= 0x1fff;
  36965. d9 = c;
  36966. d9 += h0 * r9;
  36967. d9 += h1 * r8;
  36968. d9 += h2 * r7;
  36969. d9 += h3 * r6;
  36970. d9 += h4 * r5;
  36971. c = (d9 >>> 13); d9 &= 0x1fff;
  36972. d9 += h5 * r4;
  36973. d9 += h6 * r3;
  36974. d9 += h7 * r2;
  36975. d9 += h8 * r1;
  36976. d9 += h9 * r0;
  36977. c += (d9 >>> 13); d9 &= 0x1fff;
  36978. c = (((c << 2) + c)) | 0;
  36979. c = (c + d0) | 0;
  36980. d0 = c & 0x1fff;
  36981. c = (c >>> 13);
  36982. d1 += c;
  36983. h0 = d0;
  36984. h1 = d1;
  36985. h2 = d2;
  36986. h3 = d3;
  36987. h4 = d4;
  36988. h5 = d5;
  36989. h6 = d6;
  36990. h7 = d7;
  36991. h8 = d8;
  36992. h9 = d9;
  36993. mpos += 16;
  36994. bytes -= 16;
  36995. }
  36996. this.h[0] = h0;
  36997. this.h[1] = h1;
  36998. this.h[2] = h2;
  36999. this.h[3] = h3;
  37000. this.h[4] = h4;
  37001. this.h[5] = h5;
  37002. this.h[6] = h6;
  37003. this.h[7] = h7;
  37004. this.h[8] = h8;
  37005. this.h[9] = h9;
  37006. };
  37007. poly1305.prototype.finish = function(mac, macpos) {
  37008. var g = new Uint16Array(10);
  37009. var c, mask, f, i;
  37010. if (this.leftover) {
  37011. i = this.leftover;
  37012. this.buffer[i++] = 1;
  37013. for (; i < 16; i++) this.buffer[i] = 0;
  37014. this.fin = 1;
  37015. this.blocks(this.buffer, 0, 16);
  37016. }
  37017. c = this.h[1] >>> 13;
  37018. this.h[1] &= 0x1fff;
  37019. for (i = 2; i < 10; i++) {
  37020. this.h[i] += c;
  37021. c = this.h[i] >>> 13;
  37022. this.h[i] &= 0x1fff;
  37023. }
  37024. this.h[0] += (c * 5);
  37025. c = this.h[0] >>> 13;
  37026. this.h[0] &= 0x1fff;
  37027. this.h[1] += c;
  37028. c = this.h[1] >>> 13;
  37029. this.h[1] &= 0x1fff;
  37030. this.h[2] += c;
  37031. g[0] = this.h[0] + 5;
  37032. c = g[0] >>> 13;
  37033. g[0] &= 0x1fff;
  37034. for (i = 1; i < 10; i++) {
  37035. g[i] = this.h[i] + c;
  37036. c = g[i] >>> 13;
  37037. g[i] &= 0x1fff;
  37038. }
  37039. g[9] -= (1 << 13);
  37040. mask = (c ^ 1) - 1;
  37041. for (i = 0; i < 10; i++) g[i] &= mask;
  37042. mask = ~mask;
  37043. for (i = 0; i < 10; i++) this.h[i] = (this.h[i] & mask) | g[i];
  37044. this.h[0] = ((this.h[0] ) | (this.h[1] << 13) ) & 0xffff;
  37045. this.h[1] = ((this.h[1] >>> 3) | (this.h[2] << 10) ) & 0xffff;
  37046. this.h[2] = ((this.h[2] >>> 6) | (this.h[3] << 7) ) & 0xffff;
  37047. this.h[3] = ((this.h[3] >>> 9) | (this.h[4] << 4) ) & 0xffff;
  37048. this.h[4] = ((this.h[4] >>> 12) | (this.h[5] << 1) | (this.h[6] << 14)) & 0xffff;
  37049. this.h[5] = ((this.h[6] >>> 2) | (this.h[7] << 11) ) & 0xffff;
  37050. this.h[6] = ((this.h[7] >>> 5) | (this.h[8] << 8) ) & 0xffff;
  37051. this.h[7] = ((this.h[8] >>> 8) | (this.h[9] << 5) ) & 0xffff;
  37052. f = this.h[0] + this.pad[0];
  37053. this.h[0] = f & 0xffff;
  37054. for (i = 1; i < 8; i++) {
  37055. f = (((this.h[i] + this.pad[i]) | 0) + (f >>> 16)) | 0;
  37056. this.h[i] = f & 0xffff;
  37057. }
  37058. mac[macpos+ 0] = (this.h[0] >>> 0) & 0xff;
  37059. mac[macpos+ 1] = (this.h[0] >>> 8) & 0xff;
  37060. mac[macpos+ 2] = (this.h[1] >>> 0) & 0xff;
  37061. mac[macpos+ 3] = (this.h[1] >>> 8) & 0xff;
  37062. mac[macpos+ 4] = (this.h[2] >>> 0) & 0xff;
  37063. mac[macpos+ 5] = (this.h[2] >>> 8) & 0xff;
  37064. mac[macpos+ 6] = (this.h[3] >>> 0) & 0xff;
  37065. mac[macpos+ 7] = (this.h[3] >>> 8) & 0xff;
  37066. mac[macpos+ 8] = (this.h[4] >>> 0) & 0xff;
  37067. mac[macpos+ 9] = (this.h[4] >>> 8) & 0xff;
  37068. mac[macpos+10] = (this.h[5] >>> 0) & 0xff;
  37069. mac[macpos+11] = (this.h[5] >>> 8) & 0xff;
  37070. mac[macpos+12] = (this.h[6] >>> 0) & 0xff;
  37071. mac[macpos+13] = (this.h[6] >>> 8) & 0xff;
  37072. mac[macpos+14] = (this.h[7] >>> 0) & 0xff;
  37073. mac[macpos+15] = (this.h[7] >>> 8) & 0xff;
  37074. };
  37075. poly1305.prototype.update = function(m, mpos, bytes) {
  37076. var i, want;
  37077. if (this.leftover) {
  37078. want = (16 - this.leftover);
  37079. if (want > bytes)
  37080. want = bytes;
  37081. for (i = 0; i < want; i++)
  37082. this.buffer[this.leftover + i] = m[mpos+i];
  37083. bytes -= want;
  37084. mpos += want;
  37085. this.leftover += want;
  37086. if (this.leftover < 16)
  37087. return;
  37088. this.blocks(this.buffer, 0, 16);
  37089. this.leftover = 0;
  37090. }
  37091. if (bytes >= 16) {
  37092. want = bytes - (bytes % 16);
  37093. this.blocks(m, mpos, want);
  37094. mpos += want;
  37095. bytes -= want;
  37096. }
  37097. if (bytes) {
  37098. for (i = 0; i < bytes; i++)
  37099. this.buffer[this.leftover + i] = m[mpos+i];
  37100. this.leftover += bytes;
  37101. }
  37102. };
  37103. function crypto_onetimeauth(out, outpos, m, mpos, n, k) {
  37104. var s = new poly1305(k);
  37105. s.update(m, mpos, n);
  37106. s.finish(out, outpos);
  37107. return 0;
  37108. }
  37109. function crypto_onetimeauth_verify(h, hpos, m, mpos, n, k) {
  37110. var x = new Uint8Array(16);
  37111. crypto_onetimeauth(x,0,m,mpos,n,k);
  37112. return crypto_verify_16(h,hpos,x,0);
  37113. }
  37114. function crypto_secretbox(c,m,d,n,k) {
  37115. var i;
  37116. if (d < 32) return -1;
  37117. crypto_stream_xor(c,0,m,0,d,n,k);
  37118. crypto_onetimeauth(c, 16, c, 32, d - 32, c);
  37119. for (i = 0; i < 16; i++) c[i] = 0;
  37120. return 0;
  37121. }
  37122. function crypto_secretbox_open(m,c,d,n,k) {
  37123. var i;
  37124. var x = new Uint8Array(32);
  37125. if (d < 32) return -1;
  37126. crypto_stream(x,0,32,n,k);
  37127. if (crypto_onetimeauth_verify(c, 16,c, 32,d - 32,x) !== 0) return -1;
  37128. crypto_stream_xor(m,0,c,0,d,n,k);
  37129. for (i = 0; i < 32; i++) m[i] = 0;
  37130. return 0;
  37131. }
  37132. function set25519(r, a) {
  37133. var i;
  37134. for (i = 0; i < 16; i++) r[i] = a[i]|0;
  37135. }
  37136. function car25519(o) {
  37137. var i, v, c = 1;
  37138. for (i = 0; i < 16; i++) {
  37139. v = o[i] + c + 65535;
  37140. c = Math.floor(v / 65536);
  37141. o[i] = v - c * 65536;
  37142. }
  37143. o[0] += c-1 + 37 * (c-1);
  37144. }
  37145. function sel25519(p, q, b) {
  37146. var t, c = ~(b-1);
  37147. for (var i = 0; i < 16; i++) {
  37148. t = c & (p[i] ^ q[i]);
  37149. p[i] ^= t;
  37150. q[i] ^= t;
  37151. }
  37152. }
  37153. function pack25519(o, n) {
  37154. var i, j, b;
  37155. var m = gf(), t = gf();
  37156. for (i = 0; i < 16; i++) t[i] = n[i];
  37157. car25519(t);
  37158. car25519(t);
  37159. car25519(t);
  37160. for (j = 0; j < 2; j++) {
  37161. m[0] = t[0] - 0xffed;
  37162. for (i = 1; i < 15; i++) {
  37163. m[i] = t[i] - 0xffff - ((m[i-1]>>16) & 1);
  37164. m[i-1] &= 0xffff;
  37165. }
  37166. m[15] = t[15] - 0x7fff - ((m[14]>>16) & 1);
  37167. b = (m[15]>>16) & 1;
  37168. m[14] &= 0xffff;
  37169. sel25519(t, m, 1-b);
  37170. }
  37171. for (i = 0; i < 16; i++) {
  37172. o[2*i] = t[i] & 0xff;
  37173. o[2*i+1] = t[i]>>8;
  37174. }
  37175. }
  37176. function neq25519(a, b) {
  37177. var c = new Uint8Array(32), d = new Uint8Array(32);
  37178. pack25519(c, a);
  37179. pack25519(d, b);
  37180. return crypto_verify_32(c, 0, d, 0);
  37181. }
  37182. function par25519(a) {
  37183. var d = new Uint8Array(32);
  37184. pack25519(d, a);
  37185. return d[0] & 1;
  37186. }
  37187. function unpack25519(o, n) {
  37188. var i;
  37189. for (i = 0; i < 16; i++) o[i] = n[2*i] + (n[2*i+1] << 8);
  37190. o[15] &= 0x7fff;
  37191. }
  37192. function A(o, a, b) {
  37193. for (var i = 0; i < 16; i++) o[i] = a[i] + b[i];
  37194. }
  37195. function Z(o, a, b) {
  37196. for (var i = 0; i < 16; i++) o[i] = a[i] - b[i];
  37197. }
  37198. function M(o, a, b) {
  37199. var v, c,
  37200. t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0,
  37201. t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0,
  37202. t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0,
  37203. t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0,
  37204. b0 = b[0],
  37205. b1 = b[1],
  37206. b2 = b[2],
  37207. b3 = b[3],
  37208. b4 = b[4],
  37209. b5 = b[5],
  37210. b6 = b[6],
  37211. b7 = b[7],
  37212. b8 = b[8],
  37213. b9 = b[9],
  37214. b10 = b[10],
  37215. b11 = b[11],
  37216. b12 = b[12],
  37217. b13 = b[13],
  37218. b14 = b[14],
  37219. b15 = b[15];
  37220. v = a[0];
  37221. t0 += v * b0;
  37222. t1 += v * b1;
  37223. t2 += v * b2;
  37224. t3 += v * b3;
  37225. t4 += v * b4;
  37226. t5 += v * b5;
  37227. t6 += v * b6;
  37228. t7 += v * b7;
  37229. t8 += v * b8;
  37230. t9 += v * b9;
  37231. t10 += v * b10;
  37232. t11 += v * b11;
  37233. t12 += v * b12;
  37234. t13 += v * b13;
  37235. t14 += v * b14;
  37236. t15 += v * b15;
  37237. v = a[1];
  37238. t1 += v * b0;
  37239. t2 += v * b1;
  37240. t3 += v * b2;
  37241. t4 += v * b3;
  37242. t5 += v * b4;
  37243. t6 += v * b5;
  37244. t7 += v * b6;
  37245. t8 += v * b7;
  37246. t9 += v * b8;
  37247. t10 += v * b9;
  37248. t11 += v * b10;
  37249. t12 += v * b11;
  37250. t13 += v * b12;
  37251. t14 += v * b13;
  37252. t15 += v * b14;
  37253. t16 += v * b15;
  37254. v = a[2];
  37255. t2 += v * b0;
  37256. t3 += v * b1;
  37257. t4 += v * b2;
  37258. t5 += v * b3;
  37259. t6 += v * b4;
  37260. t7 += v * b5;
  37261. t8 += v * b6;
  37262. t9 += v * b7;
  37263. t10 += v * b8;
  37264. t11 += v * b9;
  37265. t12 += v * b10;
  37266. t13 += v * b11;
  37267. t14 += v * b12;
  37268. t15 += v * b13;
  37269. t16 += v * b14;
  37270. t17 += v * b15;
  37271. v = a[3];
  37272. t3 += v * b0;
  37273. t4 += v * b1;
  37274. t5 += v * b2;
  37275. t6 += v * b3;
  37276. t7 += v * b4;
  37277. t8 += v * b5;
  37278. t9 += v * b6;
  37279. t10 += v * b7;
  37280. t11 += v * b8;
  37281. t12 += v * b9;
  37282. t13 += v * b10;
  37283. t14 += v * b11;
  37284. t15 += v * b12;
  37285. t16 += v * b13;
  37286. t17 += v * b14;
  37287. t18 += v * b15;
  37288. v = a[4];
  37289. t4 += v * b0;
  37290. t5 += v * b1;
  37291. t6 += v * b2;
  37292. t7 += v * b3;
  37293. t8 += v * b4;
  37294. t9 += v * b5;
  37295. t10 += v * b6;
  37296. t11 += v * b7;
  37297. t12 += v * b8;
  37298. t13 += v * b9;
  37299. t14 += v * b10;
  37300. t15 += v * b11;
  37301. t16 += v * b12;
  37302. t17 += v * b13;
  37303. t18 += v * b14;
  37304. t19 += v * b15;
  37305. v = a[5];
  37306. t5 += v * b0;
  37307. t6 += v * b1;
  37308. t7 += v * b2;
  37309. t8 += v * b3;
  37310. t9 += v * b4;
  37311. t10 += v * b5;
  37312. t11 += v * b6;
  37313. t12 += v * b7;
  37314. t13 += v * b8;
  37315. t14 += v * b9;
  37316. t15 += v * b10;
  37317. t16 += v * b11;
  37318. t17 += v * b12;
  37319. t18 += v * b13;
  37320. t19 += v * b14;
  37321. t20 += v * b15;
  37322. v = a[6];
  37323. t6 += v * b0;
  37324. t7 += v * b1;
  37325. t8 += v * b2;
  37326. t9 += v * b3;
  37327. t10 += v * b4;
  37328. t11 += v * b5;
  37329. t12 += v * b6;
  37330. t13 += v * b7;
  37331. t14 += v * b8;
  37332. t15 += v * b9;
  37333. t16 += v * b10;
  37334. t17 += v * b11;
  37335. t18 += v * b12;
  37336. t19 += v * b13;
  37337. t20 += v * b14;
  37338. t21 += v * b15;
  37339. v = a[7];
  37340. t7 += v * b0;
  37341. t8 += v * b1;
  37342. t9 += v * b2;
  37343. t10 += v * b3;
  37344. t11 += v * b4;
  37345. t12 += v * b5;
  37346. t13 += v * b6;
  37347. t14 += v * b7;
  37348. t15 += v * b8;
  37349. t16 += v * b9;
  37350. t17 += v * b10;
  37351. t18 += v * b11;
  37352. t19 += v * b12;
  37353. t20 += v * b13;
  37354. t21 += v * b14;
  37355. t22 += v * b15;
  37356. v = a[8];
  37357. t8 += v * b0;
  37358. t9 += v * b1;
  37359. t10 += v * b2;
  37360. t11 += v * b3;
  37361. t12 += v * b4;
  37362. t13 += v * b5;
  37363. t14 += v * b6;
  37364. t15 += v * b7;
  37365. t16 += v * b8;
  37366. t17 += v * b9;
  37367. t18 += v * b10;
  37368. t19 += v * b11;
  37369. t20 += v * b12;
  37370. t21 += v * b13;
  37371. t22 += v * b14;
  37372. t23 += v * b15;
  37373. v = a[9];
  37374. t9 += v * b0;
  37375. t10 += v * b1;
  37376. t11 += v * b2;
  37377. t12 += v * b3;
  37378. t13 += v * b4;
  37379. t14 += v * b5;
  37380. t15 += v * b6;
  37381. t16 += v * b7;
  37382. t17 += v * b8;
  37383. t18 += v * b9;
  37384. t19 += v * b10;
  37385. t20 += v * b11;
  37386. t21 += v * b12;
  37387. t22 += v * b13;
  37388. t23 += v * b14;
  37389. t24 += v * b15;
  37390. v = a[10];
  37391. t10 += v * b0;
  37392. t11 += v * b1;
  37393. t12 += v * b2;
  37394. t13 += v * b3;
  37395. t14 += v * b4;
  37396. t15 += v * b5;
  37397. t16 += v * b6;
  37398. t17 += v * b7;
  37399. t18 += v * b8;
  37400. t19 += v * b9;
  37401. t20 += v * b10;
  37402. t21 += v * b11;
  37403. t22 += v * b12;
  37404. t23 += v * b13;
  37405. t24 += v * b14;
  37406. t25 += v * b15;
  37407. v = a[11];
  37408. t11 += v * b0;
  37409. t12 += v * b1;
  37410. t13 += v * b2;
  37411. t14 += v * b3;
  37412. t15 += v * b4;
  37413. t16 += v * b5;
  37414. t17 += v * b6;
  37415. t18 += v * b7;
  37416. t19 += v * b8;
  37417. t20 += v * b9;
  37418. t21 += v * b10;
  37419. t22 += v * b11;
  37420. t23 += v * b12;
  37421. t24 += v * b13;
  37422. t25 += v * b14;
  37423. t26 += v * b15;
  37424. v = a[12];
  37425. t12 += v * b0;
  37426. t13 += v * b1;
  37427. t14 += v * b2;
  37428. t15 += v * b3;
  37429. t16 += v * b4;
  37430. t17 += v * b5;
  37431. t18 += v * b6;
  37432. t19 += v * b7;
  37433. t20 += v * b8;
  37434. t21 += v * b9;
  37435. t22 += v * b10;
  37436. t23 += v * b11;
  37437. t24 += v * b12;
  37438. t25 += v * b13;
  37439. t26 += v * b14;
  37440. t27 += v * b15;
  37441. v = a[13];
  37442. t13 += v * b0;
  37443. t14 += v * b1;
  37444. t15 += v * b2;
  37445. t16 += v * b3;
  37446. t17 += v * b4;
  37447. t18 += v * b5;
  37448. t19 += v * b6;
  37449. t20 += v * b7;
  37450. t21 += v * b8;
  37451. t22 += v * b9;
  37452. t23 += v * b10;
  37453. t24 += v * b11;
  37454. t25 += v * b12;
  37455. t26 += v * b13;
  37456. t27 += v * b14;
  37457. t28 += v * b15;
  37458. v = a[14];
  37459. t14 += v * b0;
  37460. t15 += v * b1;
  37461. t16 += v * b2;
  37462. t17 += v * b3;
  37463. t18 += v * b4;
  37464. t19 += v * b5;
  37465. t20 += v * b6;
  37466. t21 += v * b7;
  37467. t22 += v * b8;
  37468. t23 += v * b9;
  37469. t24 += v * b10;
  37470. t25 += v * b11;
  37471. t26 += v * b12;
  37472. t27 += v * b13;
  37473. t28 += v * b14;
  37474. t29 += v * b15;
  37475. v = a[15];
  37476. t15 += v * b0;
  37477. t16 += v * b1;
  37478. t17 += v * b2;
  37479. t18 += v * b3;
  37480. t19 += v * b4;
  37481. t20 += v * b5;
  37482. t21 += v * b6;
  37483. t22 += v * b7;
  37484. t23 += v * b8;
  37485. t24 += v * b9;
  37486. t25 += v * b10;
  37487. t26 += v * b11;
  37488. t27 += v * b12;
  37489. t28 += v * b13;
  37490. t29 += v * b14;
  37491. t30 += v * b15;
  37492. t0 += 38 * t16;
  37493. t1 += 38 * t17;
  37494. t2 += 38 * t18;
  37495. t3 += 38 * t19;
  37496. t4 += 38 * t20;
  37497. t5 += 38 * t21;
  37498. t6 += 38 * t22;
  37499. t7 += 38 * t23;
  37500. t8 += 38 * t24;
  37501. t9 += 38 * t25;
  37502. t10 += 38 * t26;
  37503. t11 += 38 * t27;
  37504. t12 += 38 * t28;
  37505. t13 += 38 * t29;
  37506. t14 += 38 * t30;
  37507. // t15 left as is
  37508. // first car
  37509. c = 1;
  37510. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  37511. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  37512. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  37513. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  37514. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  37515. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  37516. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  37517. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  37518. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  37519. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  37520. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  37521. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  37522. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  37523. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  37524. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  37525. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  37526. t0 += c-1 + 37 * (c-1);
  37527. // second car
  37528. c = 1;
  37529. v = t0 + c + 65535; c = Math.floor(v / 65536); t0 = v - c * 65536;
  37530. v = t1 + c + 65535; c = Math.floor(v / 65536); t1 = v - c * 65536;
  37531. v = t2 + c + 65535; c = Math.floor(v / 65536); t2 = v - c * 65536;
  37532. v = t3 + c + 65535; c = Math.floor(v / 65536); t3 = v - c * 65536;
  37533. v = t4 + c + 65535; c = Math.floor(v / 65536); t4 = v - c * 65536;
  37534. v = t5 + c + 65535; c = Math.floor(v / 65536); t5 = v - c * 65536;
  37535. v = t6 + c + 65535; c = Math.floor(v / 65536); t6 = v - c * 65536;
  37536. v = t7 + c + 65535; c = Math.floor(v / 65536); t7 = v - c * 65536;
  37537. v = t8 + c + 65535; c = Math.floor(v / 65536); t8 = v - c * 65536;
  37538. v = t9 + c + 65535; c = Math.floor(v / 65536); t9 = v - c * 65536;
  37539. v = t10 + c + 65535; c = Math.floor(v / 65536); t10 = v - c * 65536;
  37540. v = t11 + c + 65535; c = Math.floor(v / 65536); t11 = v - c * 65536;
  37541. v = t12 + c + 65535; c = Math.floor(v / 65536); t12 = v - c * 65536;
  37542. v = t13 + c + 65535; c = Math.floor(v / 65536); t13 = v - c * 65536;
  37543. v = t14 + c + 65535; c = Math.floor(v / 65536); t14 = v - c * 65536;
  37544. v = t15 + c + 65535; c = Math.floor(v / 65536); t15 = v - c * 65536;
  37545. t0 += c-1 + 37 * (c-1);
  37546. o[ 0] = t0;
  37547. o[ 1] = t1;
  37548. o[ 2] = t2;
  37549. o[ 3] = t3;
  37550. o[ 4] = t4;
  37551. o[ 5] = t5;
  37552. o[ 6] = t6;
  37553. o[ 7] = t7;
  37554. o[ 8] = t8;
  37555. o[ 9] = t9;
  37556. o[10] = t10;
  37557. o[11] = t11;
  37558. o[12] = t12;
  37559. o[13] = t13;
  37560. o[14] = t14;
  37561. o[15] = t15;
  37562. }
  37563. function S(o, a) {
  37564. M(o, a, a);
  37565. }
  37566. function inv25519(o, i) {
  37567. var c = gf();
  37568. var a;
  37569. for (a = 0; a < 16; a++) c[a] = i[a];
  37570. for (a = 253; a >= 0; a--) {
  37571. S(c, c);
  37572. if(a !== 2 && a !== 4) M(c, c, i);
  37573. }
  37574. for (a = 0; a < 16; a++) o[a] = c[a];
  37575. }
  37576. function pow2523(o, i) {
  37577. var c = gf();
  37578. var a;
  37579. for (a = 0; a < 16; a++) c[a] = i[a];
  37580. for (a = 250; a >= 0; a--) {
  37581. S(c, c);
  37582. if(a !== 1) M(c, c, i);
  37583. }
  37584. for (a = 0; a < 16; a++) o[a] = c[a];
  37585. }
  37586. function crypto_scalarmult(q, n, p) {
  37587. var z = new Uint8Array(32);
  37588. var x = new Float64Array(80), r, i;
  37589. var a = gf(), b = gf(), c = gf(),
  37590. d = gf(), e = gf(), f = gf();
  37591. for (i = 0; i < 31; i++) z[i] = n[i];
  37592. z[31]=(n[31]&127)|64;
  37593. z[0]&=248;
  37594. unpack25519(x,p);
  37595. for (i = 0; i < 16; i++) {
  37596. b[i]=x[i];
  37597. d[i]=a[i]=c[i]=0;
  37598. }
  37599. a[0]=d[0]=1;
  37600. for (i=254; i>=0; --i) {
  37601. r=(z[i>>>3]>>>(i&7))&1;
  37602. sel25519(a,b,r);
  37603. sel25519(c,d,r);
  37604. A(e,a,c);
  37605. Z(a,a,c);
  37606. A(c,b,d);
  37607. Z(b,b,d);
  37608. S(d,e);
  37609. S(f,a);
  37610. M(a,c,a);
  37611. M(c,b,e);
  37612. A(e,a,c);
  37613. Z(a,a,c);
  37614. S(b,a);
  37615. Z(c,d,f);
  37616. M(a,c,_121665);
  37617. A(a,a,d);
  37618. M(c,c,a);
  37619. M(a,d,f);
  37620. M(d,b,x);
  37621. S(b,e);
  37622. sel25519(a,b,r);
  37623. sel25519(c,d,r);
  37624. }
  37625. for (i = 0; i < 16; i++) {
  37626. x[i+16]=a[i];
  37627. x[i+32]=c[i];
  37628. x[i+48]=b[i];
  37629. x[i+64]=d[i];
  37630. }
  37631. var x32 = x.subarray(32);
  37632. var x16 = x.subarray(16);
  37633. inv25519(x32,x32);
  37634. M(x16,x16,x32);
  37635. pack25519(q,x16);
  37636. return 0;
  37637. }
  37638. function crypto_scalarmult_base(q, n) {
  37639. return crypto_scalarmult(q, n, _9);
  37640. }
  37641. function crypto_box_keypair(y, x) {
  37642. randombytes(x, 32);
  37643. return crypto_scalarmult_base(y, x);
  37644. }
  37645. function crypto_box_beforenm(k, y, x) {
  37646. var s = new Uint8Array(32);
  37647. crypto_scalarmult(s, x, y);
  37648. return crypto_core_hsalsa20(k, _0, s, sigma);
  37649. }
  37650. var crypto_box_afternm = crypto_secretbox;
  37651. var crypto_box_open_afternm = crypto_secretbox_open;
  37652. function crypto_box(c, m, d, n, y, x) {
  37653. var k = new Uint8Array(32);
  37654. crypto_box_beforenm(k, y, x);
  37655. return crypto_box_afternm(c, m, d, n, k);
  37656. }
  37657. function crypto_box_open(m, c, d, n, y, x) {
  37658. var k = new Uint8Array(32);
  37659. crypto_box_beforenm(k, y, x);
  37660. return crypto_box_open_afternm(m, c, d, n, k);
  37661. }
  37662. var K = [
  37663. 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd,
  37664. 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc,
  37665. 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019,
  37666. 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118,
  37667. 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe,
  37668. 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2,
  37669. 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1,
  37670. 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694,
  37671. 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3,
  37672. 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65,
  37673. 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483,
  37674. 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5,
  37675. 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210,
  37676. 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4,
  37677. 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725,
  37678. 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70,
  37679. 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926,
  37680. 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df,
  37681. 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8,
  37682. 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b,
  37683. 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001,
  37684. 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30,
  37685. 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910,
  37686. 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8,
  37687. 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53,
  37688. 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8,
  37689. 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb,
  37690. 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3,
  37691. 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60,
  37692. 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec,
  37693. 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9,
  37694. 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b,
  37695. 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207,
  37696. 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178,
  37697. 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6,
  37698. 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b,
  37699. 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493,
  37700. 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c,
  37701. 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a,
  37702. 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817
  37703. ];
  37704. function crypto_hashblocks_hl(hh, hl, m, n) {
  37705. var wh = new Int32Array(16), wl = new Int32Array(16),
  37706. bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7,
  37707. bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7,
  37708. th, tl, i, j, h, l, a, b, c, d;
  37709. var ah0 = hh[0],
  37710. ah1 = hh[1],
  37711. ah2 = hh[2],
  37712. ah3 = hh[3],
  37713. ah4 = hh[4],
  37714. ah5 = hh[5],
  37715. ah6 = hh[6],
  37716. ah7 = hh[7],
  37717. al0 = hl[0],
  37718. al1 = hl[1],
  37719. al2 = hl[2],
  37720. al3 = hl[3],
  37721. al4 = hl[4],
  37722. al5 = hl[5],
  37723. al6 = hl[6],
  37724. al7 = hl[7];
  37725. var pos = 0;
  37726. while (n >= 128) {
  37727. for (i = 0; i < 16; i++) {
  37728. j = 8 * i + pos;
  37729. wh[i] = (m[j+0] << 24) | (m[j+1] << 16) | (m[j+2] << 8) | m[j+3];
  37730. wl[i] = (m[j+4] << 24) | (m[j+5] << 16) | (m[j+6] << 8) | m[j+7];
  37731. }
  37732. for (i = 0; i < 80; i++) {
  37733. bh0 = ah0;
  37734. bh1 = ah1;
  37735. bh2 = ah2;
  37736. bh3 = ah3;
  37737. bh4 = ah4;
  37738. bh5 = ah5;
  37739. bh6 = ah6;
  37740. bh7 = ah7;
  37741. bl0 = al0;
  37742. bl1 = al1;
  37743. bl2 = al2;
  37744. bl3 = al3;
  37745. bl4 = al4;
  37746. bl5 = al5;
  37747. bl6 = al6;
  37748. bl7 = al7;
  37749. // add
  37750. h = ah7;
  37751. l = al7;
  37752. a = l & 0xffff; b = l >>> 16;
  37753. c = h & 0xffff; d = h >>> 16;
  37754. // Sigma1
  37755. h = ((ah4 >>> 14) | (al4 << (32-14))) ^ ((ah4 >>> 18) | (al4 << (32-18))) ^ ((al4 >>> (41-32)) | (ah4 << (32-(41-32))));
  37756. l = ((al4 >>> 14) | (ah4 << (32-14))) ^ ((al4 >>> 18) | (ah4 << (32-18))) ^ ((ah4 >>> (41-32)) | (al4 << (32-(41-32))));
  37757. a += l & 0xffff; b += l >>> 16;
  37758. c += h & 0xffff; d += h >>> 16;
  37759. // Ch
  37760. h = (ah4 & ah5) ^ (~ah4 & ah6);
  37761. l = (al4 & al5) ^ (~al4 & al6);
  37762. a += l & 0xffff; b += l >>> 16;
  37763. c += h & 0xffff; d += h >>> 16;
  37764. // K
  37765. h = K[i*2];
  37766. l = K[i*2+1];
  37767. a += l & 0xffff; b += l >>> 16;
  37768. c += h & 0xffff; d += h >>> 16;
  37769. // w
  37770. h = wh[i%16];
  37771. l = wl[i%16];
  37772. a += l & 0xffff; b += l >>> 16;
  37773. c += h & 0xffff; d += h >>> 16;
  37774. b += a >>> 16;
  37775. c += b >>> 16;
  37776. d += c >>> 16;
  37777. th = c & 0xffff | d << 16;
  37778. tl = a & 0xffff | b << 16;
  37779. // add
  37780. h = th;
  37781. l = tl;
  37782. a = l & 0xffff; b = l >>> 16;
  37783. c = h & 0xffff; d = h >>> 16;
  37784. // Sigma0
  37785. h = ((ah0 >>> 28) | (al0 << (32-28))) ^ ((al0 >>> (34-32)) | (ah0 << (32-(34-32)))) ^ ((al0 >>> (39-32)) | (ah0 << (32-(39-32))));
  37786. l = ((al0 >>> 28) | (ah0 << (32-28))) ^ ((ah0 >>> (34-32)) | (al0 << (32-(34-32)))) ^ ((ah0 >>> (39-32)) | (al0 << (32-(39-32))));
  37787. a += l & 0xffff; b += l >>> 16;
  37788. c += h & 0xffff; d += h >>> 16;
  37789. // Maj
  37790. h = (ah0 & ah1) ^ (ah0 & ah2) ^ (ah1 & ah2);
  37791. l = (al0 & al1) ^ (al0 & al2) ^ (al1 & al2);
  37792. a += l & 0xffff; b += l >>> 16;
  37793. c += h & 0xffff; d += h >>> 16;
  37794. b += a >>> 16;
  37795. c += b >>> 16;
  37796. d += c >>> 16;
  37797. bh7 = (c & 0xffff) | (d << 16);
  37798. bl7 = (a & 0xffff) | (b << 16);
  37799. // add
  37800. h = bh3;
  37801. l = bl3;
  37802. a = l & 0xffff; b = l >>> 16;
  37803. c = h & 0xffff; d = h >>> 16;
  37804. h = th;
  37805. l = tl;
  37806. a += l & 0xffff; b += l >>> 16;
  37807. c += h & 0xffff; d += h >>> 16;
  37808. b += a >>> 16;
  37809. c += b >>> 16;
  37810. d += c >>> 16;
  37811. bh3 = (c & 0xffff) | (d << 16);
  37812. bl3 = (a & 0xffff) | (b << 16);
  37813. ah1 = bh0;
  37814. ah2 = bh1;
  37815. ah3 = bh2;
  37816. ah4 = bh3;
  37817. ah5 = bh4;
  37818. ah6 = bh5;
  37819. ah7 = bh6;
  37820. ah0 = bh7;
  37821. al1 = bl0;
  37822. al2 = bl1;
  37823. al3 = bl2;
  37824. al4 = bl3;
  37825. al5 = bl4;
  37826. al6 = bl5;
  37827. al7 = bl6;
  37828. al0 = bl7;
  37829. if (i%16 === 15) {
  37830. for (j = 0; j < 16; j++) {
  37831. // add
  37832. h = wh[j];
  37833. l = wl[j];
  37834. a = l & 0xffff; b = l >>> 16;
  37835. c = h & 0xffff; d = h >>> 16;
  37836. h = wh[(j+9)%16];
  37837. l = wl[(j+9)%16];
  37838. a += l & 0xffff; b += l >>> 16;
  37839. c += h & 0xffff; d += h >>> 16;
  37840. // sigma0
  37841. th = wh[(j+1)%16];
  37842. tl = wl[(j+1)%16];
  37843. h = ((th >>> 1) | (tl << (32-1))) ^ ((th >>> 8) | (tl << (32-8))) ^ (th >>> 7);
  37844. l = ((tl >>> 1) | (th << (32-1))) ^ ((tl >>> 8) | (th << (32-8))) ^ ((tl >>> 7) | (th << (32-7)));
  37845. a += l & 0xffff; b += l >>> 16;
  37846. c += h & 0xffff; d += h >>> 16;
  37847. // sigma1
  37848. th = wh[(j+14)%16];
  37849. tl = wl[(j+14)%16];
  37850. h = ((th >>> 19) | (tl << (32-19))) ^ ((tl >>> (61-32)) | (th << (32-(61-32)))) ^ (th >>> 6);
  37851. l = ((tl >>> 19) | (th << (32-19))) ^ ((th >>> (61-32)) | (tl << (32-(61-32)))) ^ ((tl >>> 6) | (th << (32-6)));
  37852. a += l & 0xffff; b += l >>> 16;
  37853. c += h & 0xffff; d += h >>> 16;
  37854. b += a >>> 16;
  37855. c += b >>> 16;
  37856. d += c >>> 16;
  37857. wh[j] = (c & 0xffff) | (d << 16);
  37858. wl[j] = (a & 0xffff) | (b << 16);
  37859. }
  37860. }
  37861. }
  37862. // add
  37863. h = ah0;
  37864. l = al0;
  37865. a = l & 0xffff; b = l >>> 16;
  37866. c = h & 0xffff; d = h >>> 16;
  37867. h = hh[0];
  37868. l = hl[0];
  37869. a += l & 0xffff; b += l >>> 16;
  37870. c += h & 0xffff; d += h >>> 16;
  37871. b += a >>> 16;
  37872. c += b >>> 16;
  37873. d += c >>> 16;
  37874. hh[0] = ah0 = (c & 0xffff) | (d << 16);
  37875. hl[0] = al0 = (a & 0xffff) | (b << 16);
  37876. h = ah1;
  37877. l = al1;
  37878. a = l & 0xffff; b = l >>> 16;
  37879. c = h & 0xffff; d = h >>> 16;
  37880. h = hh[1];
  37881. l = hl[1];
  37882. a += l & 0xffff; b += l >>> 16;
  37883. c += h & 0xffff; d += h >>> 16;
  37884. b += a >>> 16;
  37885. c += b >>> 16;
  37886. d += c >>> 16;
  37887. hh[1] = ah1 = (c & 0xffff) | (d << 16);
  37888. hl[1] = al1 = (a & 0xffff) | (b << 16);
  37889. h = ah2;
  37890. l = al2;
  37891. a = l & 0xffff; b = l >>> 16;
  37892. c = h & 0xffff; d = h >>> 16;
  37893. h = hh[2];
  37894. l = hl[2];
  37895. a += l & 0xffff; b += l >>> 16;
  37896. c += h & 0xffff; d += h >>> 16;
  37897. b += a >>> 16;
  37898. c += b >>> 16;
  37899. d += c >>> 16;
  37900. hh[2] = ah2 = (c & 0xffff) | (d << 16);
  37901. hl[2] = al2 = (a & 0xffff) | (b << 16);
  37902. h = ah3;
  37903. l = al3;
  37904. a = l & 0xffff; b = l >>> 16;
  37905. c = h & 0xffff; d = h >>> 16;
  37906. h = hh[3];
  37907. l = hl[3];
  37908. a += l & 0xffff; b += l >>> 16;
  37909. c += h & 0xffff; d += h >>> 16;
  37910. b += a >>> 16;
  37911. c += b >>> 16;
  37912. d += c >>> 16;
  37913. hh[3] = ah3 = (c & 0xffff) | (d << 16);
  37914. hl[3] = al3 = (a & 0xffff) | (b << 16);
  37915. h = ah4;
  37916. l = al4;
  37917. a = l & 0xffff; b = l >>> 16;
  37918. c = h & 0xffff; d = h >>> 16;
  37919. h = hh[4];
  37920. l = hl[4];
  37921. a += l & 0xffff; b += l >>> 16;
  37922. c += h & 0xffff; d += h >>> 16;
  37923. b += a >>> 16;
  37924. c += b >>> 16;
  37925. d += c >>> 16;
  37926. hh[4] = ah4 = (c & 0xffff) | (d << 16);
  37927. hl[4] = al4 = (a & 0xffff) | (b << 16);
  37928. h = ah5;
  37929. l = al5;
  37930. a = l & 0xffff; b = l >>> 16;
  37931. c = h & 0xffff; d = h >>> 16;
  37932. h = hh[5];
  37933. l = hl[5];
  37934. a += l & 0xffff; b += l >>> 16;
  37935. c += h & 0xffff; d += h >>> 16;
  37936. b += a >>> 16;
  37937. c += b >>> 16;
  37938. d += c >>> 16;
  37939. hh[5] = ah5 = (c & 0xffff) | (d << 16);
  37940. hl[5] = al5 = (a & 0xffff) | (b << 16);
  37941. h = ah6;
  37942. l = al6;
  37943. a = l & 0xffff; b = l >>> 16;
  37944. c = h & 0xffff; d = h >>> 16;
  37945. h = hh[6];
  37946. l = hl[6];
  37947. a += l & 0xffff; b += l >>> 16;
  37948. c += h & 0xffff; d += h >>> 16;
  37949. b += a >>> 16;
  37950. c += b >>> 16;
  37951. d += c >>> 16;
  37952. hh[6] = ah6 = (c & 0xffff) | (d << 16);
  37953. hl[6] = al6 = (a & 0xffff) | (b << 16);
  37954. h = ah7;
  37955. l = al7;
  37956. a = l & 0xffff; b = l >>> 16;
  37957. c = h & 0xffff; d = h >>> 16;
  37958. h = hh[7];
  37959. l = hl[7];
  37960. a += l & 0xffff; b += l >>> 16;
  37961. c += h & 0xffff; d += h >>> 16;
  37962. b += a >>> 16;
  37963. c += b >>> 16;
  37964. d += c >>> 16;
  37965. hh[7] = ah7 = (c & 0xffff) | (d << 16);
  37966. hl[7] = al7 = (a & 0xffff) | (b << 16);
  37967. pos += 128;
  37968. n -= 128;
  37969. }
  37970. return n;
  37971. }
  37972. function crypto_hash(out, m, n) {
  37973. var hh = new Int32Array(8),
  37974. hl = new Int32Array(8),
  37975. x = new Uint8Array(256),
  37976. i, b = n;
  37977. hh[0] = 0x6a09e667;
  37978. hh[1] = 0xbb67ae85;
  37979. hh[2] = 0x3c6ef372;
  37980. hh[3] = 0xa54ff53a;
  37981. hh[4] = 0x510e527f;
  37982. hh[5] = 0x9b05688c;
  37983. hh[6] = 0x1f83d9ab;
  37984. hh[7] = 0x5be0cd19;
  37985. hl[0] = 0xf3bcc908;
  37986. hl[1] = 0x84caa73b;
  37987. hl[2] = 0xfe94f82b;
  37988. hl[3] = 0x5f1d36f1;
  37989. hl[4] = 0xade682d1;
  37990. hl[5] = 0x2b3e6c1f;
  37991. hl[6] = 0xfb41bd6b;
  37992. hl[7] = 0x137e2179;
  37993. crypto_hashblocks_hl(hh, hl, m, n);
  37994. n %= 128;
  37995. for (i = 0; i < n; i++) x[i] = m[b-n+i];
  37996. x[n] = 128;
  37997. n = 256-128*(n<112?1:0);
  37998. x[n-9] = 0;
  37999. ts64(x, n-8, (b / 0x20000000) | 0, b << 3);
  38000. crypto_hashblocks_hl(hh, hl, x, n);
  38001. for (i = 0; i < 8; i++) ts64(out, 8*i, hh[i], hl[i]);
  38002. return 0;
  38003. }
  38004. function add(p, q) {
  38005. var a = gf(), b = gf(), c = gf(),
  38006. d = gf(), e = gf(), f = gf(),
  38007. g = gf(), h = gf(), t = gf();
  38008. Z(a, p[1], p[0]);
  38009. Z(t, q[1], q[0]);
  38010. M(a, a, t);
  38011. A(b, p[0], p[1]);
  38012. A(t, q[0], q[1]);
  38013. M(b, b, t);
  38014. M(c, p[3], q[3]);
  38015. M(c, c, D2);
  38016. M(d, p[2], q[2]);
  38017. A(d, d, d);
  38018. Z(e, b, a);
  38019. Z(f, d, c);
  38020. A(g, d, c);
  38021. A(h, b, a);
  38022. M(p[0], e, f);
  38023. M(p[1], h, g);
  38024. M(p[2], g, f);
  38025. M(p[3], e, h);
  38026. }
  38027. function cswap(p, q, b) {
  38028. var i;
  38029. for (i = 0; i < 4; i++) {
  38030. sel25519(p[i], q[i], b);
  38031. }
  38032. }
  38033. function pack(r, p) {
  38034. var tx = gf(), ty = gf(), zi = gf();
  38035. inv25519(zi, p[2]);
  38036. M(tx, p[0], zi);
  38037. M(ty, p[1], zi);
  38038. pack25519(r, ty);
  38039. r[31] ^= par25519(tx) << 7;
  38040. }
  38041. function scalarmult(p, q, s) {
  38042. var b, i;
  38043. set25519(p[0], gf0);
  38044. set25519(p[1], gf1);
  38045. set25519(p[2], gf1);
  38046. set25519(p[3], gf0);
  38047. for (i = 255; i >= 0; --i) {
  38048. b = (s[(i/8)|0] >> (i&7)) & 1;
  38049. cswap(p, q, b);
  38050. add(q, p);
  38051. add(p, p);
  38052. cswap(p, q, b);
  38053. }
  38054. }
  38055. function scalarbase(p, s) {
  38056. var q = [gf(), gf(), gf(), gf()];
  38057. set25519(q[0], X);
  38058. set25519(q[1], Y);
  38059. set25519(q[2], gf1);
  38060. M(q[3], X, Y);
  38061. scalarmult(p, q, s);
  38062. }
  38063. function crypto_sign_keypair(pk, sk, seeded) {
  38064. var d = new Uint8Array(64);
  38065. var p = [gf(), gf(), gf(), gf()];
  38066. var i;
  38067. if (!seeded) randombytes(sk, 32);
  38068. crypto_hash(d, sk, 32);
  38069. d[0] &= 248;
  38070. d[31] &= 127;
  38071. d[31] |= 64;
  38072. scalarbase(p, d);
  38073. pack(pk, p);
  38074. for (i = 0; i < 32; i++) sk[i+32] = pk[i];
  38075. return 0;
  38076. }
  38077. 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]);
  38078. function modL(r, x) {
  38079. var carry, i, j, k;
  38080. for (i = 63; i >= 32; --i) {
  38081. carry = 0;
  38082. for (j = i - 32, k = i - 12; j < k; ++j) {
  38083. x[j] += carry - 16 * x[i] * L[j - (i - 32)];
  38084. carry = (x[j] + 128) >> 8;
  38085. x[j] -= carry * 256;
  38086. }
  38087. x[j] += carry;
  38088. x[i] = 0;
  38089. }
  38090. carry = 0;
  38091. for (j = 0; j < 32; j++) {
  38092. x[j] += carry - (x[31] >> 4) * L[j];
  38093. carry = x[j] >> 8;
  38094. x[j] &= 255;
  38095. }
  38096. for (j = 0; j < 32; j++) x[j] -= carry * L[j];
  38097. for (i = 0; i < 32; i++) {
  38098. x[i+1] += x[i] >> 8;
  38099. r[i] = x[i] & 255;
  38100. }
  38101. }
  38102. function reduce(r) {
  38103. var x = new Float64Array(64), i;
  38104. for (i = 0; i < 64; i++) x[i] = r[i];
  38105. for (i = 0; i < 64; i++) r[i] = 0;
  38106. modL(r, x);
  38107. }
  38108. // Note: difference from C - smlen returned, not passed as argument.
  38109. function crypto_sign(sm, m, n, sk) {
  38110. var d = new Uint8Array(64), h = new Uint8Array(64), r = new Uint8Array(64);
  38111. var i, j, x = new Float64Array(64);
  38112. var p = [gf(), gf(), gf(), gf()];
  38113. crypto_hash(d, sk, 32);
  38114. d[0] &= 248;
  38115. d[31] &= 127;
  38116. d[31] |= 64;
  38117. var smlen = n + 64;
  38118. for (i = 0; i < n; i++) sm[64 + i] = m[i];
  38119. for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
  38120. crypto_hash(r, sm.subarray(32), n+32);
  38121. reduce(r);
  38122. scalarbase(p, r);
  38123. pack(sm, p);
  38124. for (i = 32; i < 64; i++) sm[i] = sk[i];
  38125. crypto_hash(h, sm, n + 64);
  38126. reduce(h);
  38127. for (i = 0; i < 64; i++) x[i] = 0;
  38128. for (i = 0; i < 32; i++) x[i] = r[i];
  38129. for (i = 0; i < 32; i++) {
  38130. for (j = 0; j < 32; j++) {
  38131. x[i+j] += h[i] * d[j];
  38132. }
  38133. }
  38134. modL(sm.subarray(32), x);
  38135. return smlen;
  38136. }
  38137. function unpackneg(r, p) {
  38138. var t = gf(), chk = gf(), num = gf(),
  38139. den = gf(), den2 = gf(), den4 = gf(),
  38140. den6 = gf();
  38141. set25519(r[2], gf1);
  38142. unpack25519(r[1], p);
  38143. S(num, r[1]);
  38144. M(den, num, D);
  38145. Z(num, num, r[2]);
  38146. A(den, r[2], den);
  38147. S(den2, den);
  38148. S(den4, den2);
  38149. M(den6, den4, den2);
  38150. M(t, den6, num);
  38151. M(t, t, den);
  38152. pow2523(t, t);
  38153. M(t, t, num);
  38154. M(t, t, den);
  38155. M(t, t, den);
  38156. M(r[0], t, den);
  38157. S(chk, r[0]);
  38158. M(chk, chk, den);
  38159. if (neq25519(chk, num)) M(r[0], r[0], I);
  38160. S(chk, r[0]);
  38161. M(chk, chk, den);
  38162. if (neq25519(chk, num)) return -1;
  38163. if (par25519(r[0]) === (p[31]>>7)) Z(r[0], gf0, r[0]);
  38164. M(r[3], r[0], r[1]);
  38165. return 0;
  38166. }
  38167. function crypto_sign_open(m, sm, n, pk) {
  38168. var i, mlen;
  38169. var t = new Uint8Array(32), h = new Uint8Array(64);
  38170. var p = [gf(), gf(), gf(), gf()],
  38171. q = [gf(), gf(), gf(), gf()];
  38172. mlen = -1;
  38173. if (n < 64) return -1;
  38174. if (unpackneg(q, pk)) return -1;
  38175. for (i = 0; i < n; i++) m[i] = sm[i];
  38176. for (i = 0; i < 32; i++) m[i+32] = pk[i];
  38177. crypto_hash(h, m, n);
  38178. reduce(h);
  38179. scalarmult(p, q, h);
  38180. scalarbase(q, sm.subarray(32));
  38181. add(p, q);
  38182. pack(t, p);
  38183. n -= 64;
  38184. if (crypto_verify_32(sm, 0, t, 0)) {
  38185. for (i = 0; i < n; i++) m[i] = 0;
  38186. return -1;
  38187. }
  38188. for (i = 0; i < n; i++) m[i] = sm[i + 64];
  38189. mlen = n;
  38190. return mlen;
  38191. }
  38192. var crypto_secretbox_KEYBYTES = 32,
  38193. crypto_secretbox_NONCEBYTES = 24,
  38194. crypto_secretbox_ZEROBYTES = 32,
  38195. crypto_secretbox_BOXZEROBYTES = 16,
  38196. crypto_scalarmult_BYTES = 32,
  38197. crypto_scalarmult_SCALARBYTES = 32,
  38198. crypto_box_PUBLICKEYBYTES = 32,
  38199. crypto_box_SECRETKEYBYTES = 32,
  38200. crypto_box_BEFORENMBYTES = 32,
  38201. crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES,
  38202. crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES,
  38203. crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES,
  38204. crypto_sign_BYTES = 64,
  38205. crypto_sign_PUBLICKEYBYTES = 32,
  38206. crypto_sign_SECRETKEYBYTES = 64,
  38207. crypto_sign_SEEDBYTES = 32,
  38208. crypto_hash_BYTES = 64;
  38209. nacl.lowlevel = {
  38210. crypto_core_hsalsa20: crypto_core_hsalsa20,
  38211. crypto_stream_xor: crypto_stream_xor,
  38212. crypto_stream: crypto_stream,
  38213. crypto_stream_salsa20_xor: crypto_stream_salsa20_xor,
  38214. crypto_stream_salsa20: crypto_stream_salsa20,
  38215. crypto_onetimeauth: crypto_onetimeauth,
  38216. crypto_onetimeauth_verify: crypto_onetimeauth_verify,
  38217. crypto_verify_16: crypto_verify_16,
  38218. crypto_verify_32: crypto_verify_32,
  38219. crypto_secretbox: crypto_secretbox,
  38220. crypto_secretbox_open: crypto_secretbox_open,
  38221. crypto_scalarmult: crypto_scalarmult,
  38222. crypto_scalarmult_base: crypto_scalarmult_base,
  38223. crypto_box_beforenm: crypto_box_beforenm,
  38224. crypto_box_afternm: crypto_box_afternm,
  38225. crypto_box: crypto_box,
  38226. crypto_box_open: crypto_box_open,
  38227. crypto_box_keypair: crypto_box_keypair,
  38228. crypto_hash: crypto_hash,
  38229. crypto_sign: crypto_sign,
  38230. crypto_sign_keypair: crypto_sign_keypair,
  38231. crypto_sign_open: crypto_sign_open,
  38232. crypto_secretbox_KEYBYTES: crypto_secretbox_KEYBYTES,
  38233. crypto_secretbox_NONCEBYTES: crypto_secretbox_NONCEBYTES,
  38234. crypto_secretbox_ZEROBYTES: crypto_secretbox_ZEROBYTES,
  38235. crypto_secretbox_BOXZEROBYTES: crypto_secretbox_BOXZEROBYTES,
  38236. crypto_scalarmult_BYTES: crypto_scalarmult_BYTES,
  38237. crypto_scalarmult_SCALARBYTES: crypto_scalarmult_SCALARBYTES,
  38238. crypto_box_PUBLICKEYBYTES: crypto_box_PUBLICKEYBYTES,
  38239. crypto_box_SECRETKEYBYTES: crypto_box_SECRETKEYBYTES,
  38240. crypto_box_BEFORENMBYTES: crypto_box_BEFORENMBYTES,
  38241. crypto_box_NONCEBYTES: crypto_box_NONCEBYTES,
  38242. crypto_box_ZEROBYTES: crypto_box_ZEROBYTES,
  38243. crypto_box_BOXZEROBYTES: crypto_box_BOXZEROBYTES,
  38244. crypto_sign_BYTES: crypto_sign_BYTES,
  38245. crypto_sign_PUBLICKEYBYTES: crypto_sign_PUBLICKEYBYTES,
  38246. crypto_sign_SECRETKEYBYTES: crypto_sign_SECRETKEYBYTES,
  38247. crypto_sign_SEEDBYTES: crypto_sign_SEEDBYTES,
  38248. crypto_hash_BYTES: crypto_hash_BYTES
  38249. };
  38250. /* High-level API */
  38251. function checkLengths(k, n) {
  38252. if (k.length !== crypto_secretbox_KEYBYTES) throw new Error('bad key size');
  38253. if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error('bad nonce size');
  38254. }
  38255. function checkBoxLengths(pk, sk) {
  38256. if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error('bad public key size');
  38257. if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error('bad secret key size');
  38258. }
  38259. function checkArrayTypes() {
  38260. for (var i = 0; i < arguments.length; i++) {
  38261. if (!(arguments[i] instanceof Uint8Array))
  38262. throw new TypeError('unexpected type, use Uint8Array');
  38263. }
  38264. }
  38265. function cleanup(arr) {
  38266. for (var i = 0; i < arr.length; i++) arr[i] = 0;
  38267. }
  38268. nacl.randomBytes = function(n) {
  38269. var b = new Uint8Array(n);
  38270. randombytes(b, n);
  38271. return b;
  38272. };
  38273. nacl.secretbox = function(msg, nonce, key) {
  38274. checkArrayTypes(msg, nonce, key);
  38275. checkLengths(key, nonce);
  38276. var m = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
  38277. var c = new Uint8Array(m.length);
  38278. for (var i = 0; i < msg.length; i++) m[i+crypto_secretbox_ZEROBYTES] = msg[i];
  38279. crypto_secretbox(c, m, m.length, nonce, key);
  38280. return c.subarray(crypto_secretbox_BOXZEROBYTES);
  38281. };
  38282. nacl.secretbox.open = function(box, nonce, key) {
  38283. checkArrayTypes(box, nonce, key);
  38284. checkLengths(key, nonce);
  38285. var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
  38286. var m = new Uint8Array(c.length);
  38287. for (var i = 0; i < box.length; i++) c[i+crypto_secretbox_BOXZEROBYTES] = box[i];
  38288. if (c.length < 32) return null;
  38289. if (crypto_secretbox_open(m, c, c.length, nonce, key) !== 0) return null;
  38290. return m.subarray(crypto_secretbox_ZEROBYTES);
  38291. };
  38292. nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
  38293. nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
  38294. nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
  38295. nacl.scalarMult = function(n, p) {
  38296. checkArrayTypes(n, p);
  38297. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  38298. if (p.length !== crypto_scalarmult_BYTES) throw new Error('bad p size');
  38299. var q = new Uint8Array(crypto_scalarmult_BYTES);
  38300. crypto_scalarmult(q, n, p);
  38301. return q;
  38302. };
  38303. nacl.scalarMult.base = function(n) {
  38304. checkArrayTypes(n);
  38305. if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error('bad n size');
  38306. var q = new Uint8Array(crypto_scalarmult_BYTES);
  38307. crypto_scalarmult_base(q, n);
  38308. return q;
  38309. };
  38310. nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
  38311. nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
  38312. nacl.box = function(msg, nonce, publicKey, secretKey) {
  38313. var k = nacl.box.before(publicKey, secretKey);
  38314. return nacl.secretbox(msg, nonce, k);
  38315. };
  38316. nacl.box.before = function(publicKey, secretKey) {
  38317. checkArrayTypes(publicKey, secretKey);
  38318. checkBoxLengths(publicKey, secretKey);
  38319. var k = new Uint8Array(crypto_box_BEFORENMBYTES);
  38320. crypto_box_beforenm(k, publicKey, secretKey);
  38321. return k;
  38322. };
  38323. nacl.box.after = nacl.secretbox;
  38324. nacl.box.open = function(msg, nonce, publicKey, secretKey) {
  38325. var k = nacl.box.before(publicKey, secretKey);
  38326. return nacl.secretbox.open(msg, nonce, k);
  38327. };
  38328. nacl.box.open.after = nacl.secretbox.open;
  38329. nacl.box.keyPair = function() {
  38330. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  38331. var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
  38332. crypto_box_keypair(pk, sk);
  38333. return {publicKey: pk, secretKey: sk};
  38334. };
  38335. nacl.box.keyPair.fromSecretKey = function(secretKey) {
  38336. checkArrayTypes(secretKey);
  38337. if (secretKey.length !== crypto_box_SECRETKEYBYTES)
  38338. throw new Error('bad secret key size');
  38339. var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
  38340. crypto_scalarmult_base(pk, secretKey);
  38341. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  38342. };
  38343. nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
  38344. nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
  38345. nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
  38346. nacl.box.nonceLength = crypto_box_NONCEBYTES;
  38347. nacl.box.overheadLength = nacl.secretbox.overheadLength;
  38348. nacl.sign = function(msg, secretKey) {
  38349. checkArrayTypes(msg, secretKey);
  38350. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  38351. throw new Error('bad secret key size');
  38352. var signedMsg = new Uint8Array(crypto_sign_BYTES+msg.length);
  38353. crypto_sign(signedMsg, msg, msg.length, secretKey);
  38354. return signedMsg;
  38355. };
  38356. nacl.sign.open = function(signedMsg, publicKey) {
  38357. checkArrayTypes(signedMsg, publicKey);
  38358. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  38359. throw new Error('bad public key size');
  38360. var tmp = new Uint8Array(signedMsg.length);
  38361. var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
  38362. if (mlen < 0) return null;
  38363. var m = new Uint8Array(mlen);
  38364. for (var i = 0; i < m.length; i++) m[i] = tmp[i];
  38365. return m;
  38366. };
  38367. nacl.sign.detached = function(msg, secretKey) {
  38368. var signedMsg = nacl.sign(msg, secretKey);
  38369. var sig = new Uint8Array(crypto_sign_BYTES);
  38370. for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
  38371. return sig;
  38372. };
  38373. nacl.sign.detached.verify = function(msg, sig, publicKey) {
  38374. checkArrayTypes(msg, sig, publicKey);
  38375. if (sig.length !== crypto_sign_BYTES)
  38376. throw new Error('bad signature size');
  38377. if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
  38378. throw new Error('bad public key size');
  38379. var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
  38380. var m = new Uint8Array(crypto_sign_BYTES + msg.length);
  38381. var i;
  38382. for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
  38383. for (i = 0; i < msg.length; i++) sm[i+crypto_sign_BYTES] = msg[i];
  38384. return (crypto_sign_open(m, sm, sm.length, publicKey) >= 0);
  38385. };
  38386. nacl.sign.keyPair = function() {
  38387. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38388. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  38389. crypto_sign_keypair(pk, sk);
  38390. return {publicKey: pk, secretKey: sk};
  38391. };
  38392. nacl.sign.keyPair.fromSecretKey = function(secretKey) {
  38393. checkArrayTypes(secretKey);
  38394. if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
  38395. throw new Error('bad secret key size');
  38396. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38397. for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32+i];
  38398. return {publicKey: pk, secretKey: new Uint8Array(secretKey)};
  38399. };
  38400. nacl.sign.keyPair.fromSeed = function(seed) {
  38401. checkArrayTypes(seed);
  38402. if (seed.length !== crypto_sign_SEEDBYTES)
  38403. throw new Error('bad seed size');
  38404. var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
  38405. var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
  38406. for (var i = 0; i < 32; i++) sk[i] = seed[i];
  38407. crypto_sign_keypair(pk, sk, true);
  38408. return {publicKey: pk, secretKey: sk};
  38409. };
  38410. nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
  38411. nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
  38412. nacl.sign.seedLength = crypto_sign_SEEDBYTES;
  38413. nacl.sign.signatureLength = crypto_sign_BYTES;
  38414. nacl.hash = function(msg) {
  38415. checkArrayTypes(msg);
  38416. var h = new Uint8Array(crypto_hash_BYTES);
  38417. crypto_hash(h, msg, msg.length);
  38418. return h;
  38419. };
  38420. nacl.hash.hashLength = crypto_hash_BYTES;
  38421. nacl.verify = function(x, y) {
  38422. checkArrayTypes(x, y);
  38423. // Zero length arguments are considered not equal.
  38424. if (x.length === 0 || y.length === 0) return false;
  38425. if (x.length !== y.length) return false;
  38426. return (vn(x, 0, y, 0, x.length) === 0) ? true : false;
  38427. };
  38428. nacl.setPRNG = function(fn) {
  38429. randombytes = fn;
  38430. };
  38431. (function() {
  38432. // Initialize PRNG if environment provides CSPRNG.
  38433. // If not, methods calling randombytes will throw.
  38434. var crypto = typeof self !== 'undefined' ? (self.crypto || self.msCrypto) : null;
  38435. if (crypto && crypto.getRandomValues) {
  38436. // Browsers.
  38437. var QUOTA = 65536;
  38438. nacl.setPRNG(function(x, n) {
  38439. var i, v = new Uint8Array(n);
  38440. for (i = 0; i < n; i += QUOTA) {
  38441. crypto.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
  38442. }
  38443. for (i = 0; i < n; i++) x[i] = v[i];
  38444. cleanup(v);
  38445. });
  38446. } else if (true) {
  38447. // Node.js.
  38448. crypto = __webpack_require__(3);
  38449. if (crypto && crypto.randomBytes) {
  38450. nacl.setPRNG(function(x, n) {
  38451. var i, v = crypto.randomBytes(n);
  38452. for (i = 0; i < n; i++) x[i] = v[i];
  38453. cleanup(v);
  38454. });
  38455. }
  38456. }
  38457. })();
  38458. })( true && module.exports ? module.exports : (self.nacl = self.nacl || {}));
  38459. /***/ }),
  38460. /* 1 */
  38461. /***/ (function(module, exports, __webpack_require__) {
  38462. // Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri.
  38463. // Public domain.
  38464. (function(root, f) {
  38465. 'use strict';
  38466. if ( true && module.exports) module.exports = f();
  38467. else if (root.nacl) root.nacl.util = f();
  38468. else {
  38469. root.nacl = {};
  38470. root.nacl.util = f();
  38471. }
  38472. }(this, function() {
  38473. 'use strict';
  38474. var util = {};
  38475. function validateBase64(s) {
  38476. if (!(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s))) {
  38477. throw new TypeError('invalid encoding');
  38478. }
  38479. }
  38480. util.decodeUTF8 = function(s) {
  38481. if (typeof s !== 'string') throw new TypeError('expected string');
  38482. var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length);
  38483. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  38484. return b;
  38485. };
  38486. util.encodeUTF8 = function(arr) {
  38487. var i, s = [];
  38488. for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i]));
  38489. return decodeURIComponent(escape(s.join('')));
  38490. };
  38491. if (typeof atob === 'undefined') {
  38492. // Node.js
  38493. if (typeof Buffer.from !== 'undefined') {
  38494. // Node v6 and later
  38495. util.encodeBase64 = function (arr) { // v6 and later
  38496. return Buffer.from(arr).toString('base64');
  38497. };
  38498. util.decodeBase64 = function (s) {
  38499. validateBase64(s);
  38500. return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, 'base64'), 0));
  38501. };
  38502. } else {
  38503. // Node earlier than v6
  38504. util.encodeBase64 = function (arr) { // v6 and later
  38505. return (new Buffer(arr)).toString('base64');
  38506. };
  38507. util.decodeBase64 = function(s) {
  38508. validateBase64(s);
  38509. return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0));
  38510. };
  38511. }
  38512. } else {
  38513. // Browsers
  38514. util.encodeBase64 = function(arr) {
  38515. var i, s = [], len = arr.length;
  38516. for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i]));
  38517. return btoa(s.join(''));
  38518. };
  38519. util.decodeBase64 = function(s) {
  38520. validateBase64(s);
  38521. var i, d = atob(s), b = new Uint8Array(d.length);
  38522. for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
  38523. return b;
  38524. };
  38525. }
  38526. return util;
  38527. }));
  38528. /***/ }),
  38529. /* 2 */
  38530. /***/ (function(module, exports, __webpack_require__) {
  38531. // required so we don't have to do require('pusher').default etc.
  38532. module.exports = __webpack_require__(4).default;
  38533. /***/ }),
  38534. /* 3 */
  38535. /***/ (function(module, exports) {
  38536. /* (ignored) */
  38537. /***/ }),
  38538. /* 4 */
  38539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38540. "use strict";
  38541. __webpack_require__.r(__webpack_exports__);
  38542. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_receiver_factory.ts
  38543. var ScriptReceiverFactory = (function () {
  38544. function ScriptReceiverFactory(prefix, name) {
  38545. this.lastId = 0;
  38546. this.prefix = prefix;
  38547. this.name = name;
  38548. }
  38549. ScriptReceiverFactory.prototype.create = function (callback) {
  38550. this.lastId++;
  38551. var number = this.lastId;
  38552. var id = this.prefix + number;
  38553. var name = this.name + "[" + number + "]";
  38554. var called = false;
  38555. var callbackWrapper = function () {
  38556. if (!called) {
  38557. callback.apply(null, arguments);
  38558. called = true;
  38559. }
  38560. };
  38561. this[number] = callbackWrapper;
  38562. return { number: number, id: id, name: name, callback: callbackWrapper };
  38563. };
  38564. ScriptReceiverFactory.prototype.remove = function (receiver) {
  38565. delete this[receiver.number];
  38566. };
  38567. return ScriptReceiverFactory;
  38568. }());
  38569. var ScriptReceivers = new ScriptReceiverFactory("_pusher_script_", "Pusher.ScriptReceivers");
  38570. // CONCATENATED MODULE: ./src/core/defaults.ts
  38571. var Defaults = {
  38572. VERSION: "5.0.3",
  38573. PROTOCOL: 7,
  38574. host: 'ws.pusherapp.com',
  38575. ws_port: 80,
  38576. wss_port: 443,
  38577. ws_path: '',
  38578. sockjs_host: 'sockjs.pusher.com',
  38579. sockjs_http_port: 80,
  38580. sockjs_https_port: 443,
  38581. sockjs_path: '/pusher',
  38582. stats_host: 'stats.pusher.com',
  38583. channel_auth_endpoint: '/pusher/auth',
  38584. channel_auth_transport: 'ajax',
  38585. activity_timeout: 120000,
  38586. pong_timeout: 30000,
  38587. unavailable_timeout: 10000,
  38588. cdn_http: "http://js.pusher.com",
  38589. cdn_https: "https://js.pusher.com",
  38590. dependency_suffix: ""
  38591. };
  38592. /* harmony default export */ var defaults = (Defaults);
  38593. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependency_loader.ts
  38594. var dependency_loader_DependencyLoader = (function () {
  38595. function DependencyLoader(options) {
  38596. this.options = options;
  38597. this.receivers = options.receivers || ScriptReceivers;
  38598. this.loading = {};
  38599. }
  38600. DependencyLoader.prototype.load = function (name, options, callback) {
  38601. var self = this;
  38602. if (self.loading[name] && self.loading[name].length > 0) {
  38603. self.loading[name].push(callback);
  38604. }
  38605. else {
  38606. self.loading[name] = [callback];
  38607. var request = runtime.createScriptRequest(self.getPath(name, options));
  38608. var receiver = self.receivers.create(function (error) {
  38609. self.receivers.remove(receiver);
  38610. if (self.loading[name]) {
  38611. var callbacks = self.loading[name];
  38612. delete self.loading[name];
  38613. var successCallback = function (wasSuccessful) {
  38614. if (!wasSuccessful) {
  38615. request.cleanup();
  38616. }
  38617. };
  38618. for (var i = 0; i < callbacks.length; i++) {
  38619. callbacks[i](error, successCallback);
  38620. }
  38621. }
  38622. });
  38623. request.send(receiver);
  38624. }
  38625. };
  38626. DependencyLoader.prototype.getRoot = function (options) {
  38627. var cdn;
  38628. var protocol = runtime.getDocument().location.protocol;
  38629. if ((options && options.useTLS) || protocol === "https:") {
  38630. cdn = this.options.cdn_https;
  38631. }
  38632. else {
  38633. cdn = this.options.cdn_http;
  38634. }
  38635. return cdn.replace(/\/*$/, "") + "/" + this.options.version;
  38636. };
  38637. DependencyLoader.prototype.getPath = function (name, options) {
  38638. return this.getRoot(options) + '/' + name + this.options.suffix + '.js';
  38639. };
  38640. ;
  38641. return DependencyLoader;
  38642. }());
  38643. /* harmony default export */ var dependency_loader = (dependency_loader_DependencyLoader);
  38644. // CONCATENATED MODULE: ./src/runtimes/web/dom/dependencies.ts
  38645. var DependenciesReceivers = new ScriptReceiverFactory("_pusher_dependencies", "Pusher.DependenciesReceivers");
  38646. var Dependencies = new dependency_loader({
  38647. cdn_http: defaults.cdn_http,
  38648. cdn_https: defaults.cdn_https,
  38649. version: defaults.VERSION,
  38650. suffix: defaults.dependency_suffix,
  38651. receivers: DependenciesReceivers
  38652. });
  38653. // CONCATENATED MODULE: ./src/core/base64.ts
  38654. function encode(s) {
  38655. return btoa(utob(s));
  38656. }
  38657. var fromCharCode = String.fromCharCode;
  38658. var b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  38659. var b64tab = {};
  38660. for (var base64_i = 0, l = b64chars.length; base64_i < l; base64_i++) {
  38661. b64tab[b64chars.charAt(base64_i)] = base64_i;
  38662. }
  38663. var cb_utob = function (c) {
  38664. var cc = c.charCodeAt(0);
  38665. return cc < 0x80
  38666. ? c
  38667. : cc < 0x800
  38668. ? fromCharCode(0xc0 | (cc >>> 6)) + fromCharCode(0x80 | (cc & 0x3f))
  38669. : fromCharCode(0xe0 | ((cc >>> 12) & 0x0f)) +
  38670. fromCharCode(0x80 | ((cc >>> 6) & 0x3f)) +
  38671. fromCharCode(0x80 | (cc & 0x3f));
  38672. };
  38673. var utob = function (u) {
  38674. return u.replace(/[^\x00-\x7F]/g, cb_utob);
  38675. };
  38676. var cb_encode = function (ccc) {
  38677. var padlen = [0, 2, 1][ccc.length % 3];
  38678. var ord = (ccc.charCodeAt(0) << 16) |
  38679. ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8) |
  38680. (ccc.length > 2 ? ccc.charCodeAt(2) : 0);
  38681. var chars = [
  38682. b64chars.charAt(ord >>> 18),
  38683. b64chars.charAt((ord >>> 12) & 63),
  38684. padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
  38685. padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
  38686. ];
  38687. return chars.join('');
  38688. };
  38689. var btoa = window.btoa ||
  38690. function (b) {
  38691. return b.replace(/[\s\S]{1,3}/g, cb_encode);
  38692. };
  38693. // CONCATENATED MODULE: ./src/core/utils/timers/abstract_timer.ts
  38694. var Timer = (function () {
  38695. function Timer(set, clear, delay, callback) {
  38696. var _this = this;
  38697. this.clear = clear;
  38698. this.timer = set(function () {
  38699. if (_this.timer) {
  38700. _this.timer = callback(_this.timer);
  38701. }
  38702. }, delay);
  38703. }
  38704. Timer.prototype.isRunning = function () {
  38705. return this.timer !== null;
  38706. };
  38707. Timer.prototype.ensureAborted = function () {
  38708. if (this.timer) {
  38709. this.clear(this.timer);
  38710. this.timer = null;
  38711. }
  38712. };
  38713. return Timer;
  38714. }());
  38715. /* harmony default export */ var abstract_timer = (Timer);
  38716. // CONCATENATED MODULE: ./src/core/utils/timers/index.ts
  38717. var __extends = (undefined && undefined.__extends) || (function () {
  38718. var extendStatics = function (d, b) {
  38719. extendStatics = Object.setPrototypeOf ||
  38720. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  38721. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  38722. return extendStatics(d, b);
  38723. };
  38724. return function (d, b) {
  38725. extendStatics(d, b);
  38726. function __() { this.constructor = d; }
  38727. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  38728. };
  38729. })();
  38730. function timers_clearTimeout(timer) {
  38731. window.clearTimeout(timer);
  38732. }
  38733. function timers_clearInterval(timer) {
  38734. window.clearInterval(timer);
  38735. }
  38736. var OneOffTimer = (function (_super) {
  38737. __extends(OneOffTimer, _super);
  38738. function OneOffTimer(delay, callback) {
  38739. return _super.call(this, setTimeout, timers_clearTimeout, delay, function (timer) {
  38740. callback();
  38741. return null;
  38742. }) || this;
  38743. }
  38744. return OneOffTimer;
  38745. }(abstract_timer));
  38746. var PeriodicTimer = (function (_super) {
  38747. __extends(PeriodicTimer, _super);
  38748. function PeriodicTimer(delay, callback) {
  38749. return _super.call(this, setInterval, timers_clearInterval, delay, function (timer) {
  38750. callback();
  38751. return timer;
  38752. }) || this;
  38753. }
  38754. return PeriodicTimer;
  38755. }(abstract_timer));
  38756. // CONCATENATED MODULE: ./src/core/util.ts
  38757. var Util = {
  38758. now: function () {
  38759. if (Date.now) {
  38760. return Date.now();
  38761. }
  38762. else {
  38763. return new Date().valueOf();
  38764. }
  38765. },
  38766. defer: function (callback) {
  38767. return new OneOffTimer(0, callback);
  38768. },
  38769. method: function (name) {
  38770. var args = [];
  38771. for (var _i = 1; _i < arguments.length; _i++) {
  38772. args[_i - 1] = arguments[_i];
  38773. }
  38774. var boundArguments = Array.prototype.slice.call(arguments, 1);
  38775. return function (object) {
  38776. return object[name].apply(object, boundArguments.concat(arguments));
  38777. };
  38778. }
  38779. };
  38780. /* harmony default export */ var util = (Util);
  38781. // CONCATENATED MODULE: ./src/core/utils/collections.ts
  38782. function extend(target) {
  38783. var sources = [];
  38784. for (var _i = 1; _i < arguments.length; _i++) {
  38785. sources[_i - 1] = arguments[_i];
  38786. }
  38787. for (var i = 0; i < sources.length; i++) {
  38788. var extensions = sources[i];
  38789. for (var property in extensions) {
  38790. if (extensions[property] && extensions[property].constructor &&
  38791. extensions[property].constructor === Object) {
  38792. target[property] = extend(target[property] || {}, extensions[property]);
  38793. }
  38794. else {
  38795. target[property] = extensions[property];
  38796. }
  38797. }
  38798. }
  38799. return target;
  38800. }
  38801. function stringify() {
  38802. var m = ["Pusher"];
  38803. for (var i = 0; i < arguments.length; i++) {
  38804. if (typeof arguments[i] === "string") {
  38805. m.push(arguments[i]);
  38806. }
  38807. else {
  38808. m.push(safeJSONStringify(arguments[i]));
  38809. }
  38810. }
  38811. return m.join(" : ");
  38812. }
  38813. function arrayIndexOf(array, item) {
  38814. var nativeIndexOf = Array.prototype.indexOf;
  38815. if (array === null) {
  38816. return -1;
  38817. }
  38818. if (nativeIndexOf && array.indexOf === nativeIndexOf) {
  38819. return array.indexOf(item);
  38820. }
  38821. for (var i = 0, l = array.length; i < l; i++) {
  38822. if (array[i] === item) {
  38823. return i;
  38824. }
  38825. }
  38826. return -1;
  38827. }
  38828. function objectApply(object, f) {
  38829. for (var key in object) {
  38830. if (Object.prototype.hasOwnProperty.call(object, key)) {
  38831. f(object[key], key, object);
  38832. }
  38833. }
  38834. }
  38835. function keys(object) {
  38836. var keys = [];
  38837. objectApply(object, function (_, key) {
  38838. keys.push(key);
  38839. });
  38840. return keys;
  38841. }
  38842. function values(object) {
  38843. var values = [];
  38844. objectApply(object, function (value) {
  38845. values.push(value);
  38846. });
  38847. return values;
  38848. }
  38849. function apply(array, f, context) {
  38850. for (var i = 0; i < array.length; i++) {
  38851. f.call(context || window, array[i], i, array);
  38852. }
  38853. }
  38854. function map(array, f) {
  38855. var result = [];
  38856. for (var i = 0; i < array.length; i++) {
  38857. result.push(f(array[i], i, array, result));
  38858. }
  38859. return result;
  38860. }
  38861. function mapObject(object, f) {
  38862. var result = {};
  38863. objectApply(object, function (value, key) {
  38864. result[key] = f(value);
  38865. });
  38866. return result;
  38867. }
  38868. function filter(array, test) {
  38869. test = test || function (value) { return !!value; };
  38870. var result = [];
  38871. for (var i = 0; i < array.length; i++) {
  38872. if (test(array[i], i, array, result)) {
  38873. result.push(array[i]);
  38874. }
  38875. }
  38876. return result;
  38877. }
  38878. function filterObject(object, test) {
  38879. var result = {};
  38880. objectApply(object, function (value, key) {
  38881. if ((test && test(value, key, object, result)) || Boolean(value)) {
  38882. result[key] = value;
  38883. }
  38884. });
  38885. return result;
  38886. }
  38887. function flatten(object) {
  38888. var result = [];
  38889. objectApply(object, function (value, key) {
  38890. result.push([key, value]);
  38891. });
  38892. return result;
  38893. }
  38894. function any(array, test) {
  38895. for (var i = 0; i < array.length; i++) {
  38896. if (test(array[i], i, array)) {
  38897. return true;
  38898. }
  38899. }
  38900. return false;
  38901. }
  38902. function collections_all(array, test) {
  38903. for (var i = 0; i < array.length; i++) {
  38904. if (!test(array[i], i, array)) {
  38905. return false;
  38906. }
  38907. }
  38908. return true;
  38909. }
  38910. function encodeParamsObject(data) {
  38911. return mapObject(data, function (value) {
  38912. if (typeof value === "object") {
  38913. value = safeJSONStringify(value);
  38914. }
  38915. return encodeURIComponent(encode(value.toString()));
  38916. });
  38917. }
  38918. function buildQueryString(data) {
  38919. var params = filterObject(data, function (value) {
  38920. return value !== undefined;
  38921. });
  38922. var query = map(flatten(encodeParamsObject(params)), util.method("join", "=")).join("&");
  38923. return query;
  38924. }
  38925. function decycleObject(object) {
  38926. var objects = [], paths = [];
  38927. return (function derez(value, path) {
  38928. var i, name, nu;
  38929. switch (typeof value) {
  38930. case 'object':
  38931. if (!value) {
  38932. return null;
  38933. }
  38934. for (i = 0; i < objects.length; i += 1) {
  38935. if (objects[i] === value) {
  38936. return { $ref: paths[i] };
  38937. }
  38938. }
  38939. objects.push(value);
  38940. paths.push(path);
  38941. if (Object.prototype.toString.apply(value) === '[object Array]') {
  38942. nu = [];
  38943. for (i = 0; i < value.length; i += 1) {
  38944. nu[i] = derez(value[i], path + '[' + i + ']');
  38945. }
  38946. }
  38947. else {
  38948. nu = {};
  38949. for (name in value) {
  38950. if (Object.prototype.hasOwnProperty.call(value, name)) {
  38951. nu[name] = derez(value[name], path + '[' + JSON.stringify(name) + ']');
  38952. }
  38953. }
  38954. }
  38955. return nu;
  38956. case 'number':
  38957. case 'string':
  38958. case 'boolean':
  38959. return value;
  38960. }
  38961. }(object, '$'));
  38962. }
  38963. function safeJSONStringify(source) {
  38964. try {
  38965. return JSON.stringify(source);
  38966. }
  38967. catch (e) {
  38968. return JSON.stringify(decycleObject(source));
  38969. }
  38970. }
  38971. // CONCATENATED MODULE: ./src/core/logger.ts
  38972. var logger_Logger = (function () {
  38973. function Logger() {
  38974. this.globalLog = function (message) {
  38975. if (window.console && window.console.log) {
  38976. window.console.log(message);
  38977. }
  38978. };
  38979. }
  38980. Logger.prototype.debug = function () {
  38981. var args = [];
  38982. for (var _i = 0; _i < arguments.length; _i++) {
  38983. args[_i] = arguments[_i];
  38984. }
  38985. this.log(this.globalLog, args);
  38986. };
  38987. Logger.prototype.warn = function () {
  38988. var args = [];
  38989. for (var _i = 0; _i < arguments.length; _i++) {
  38990. args[_i] = arguments[_i];
  38991. }
  38992. this.log(this.globalLogWarn, args);
  38993. };
  38994. Logger.prototype.error = function () {
  38995. var args = [];
  38996. for (var _i = 0; _i < arguments.length; _i++) {
  38997. args[_i] = arguments[_i];
  38998. }
  38999. this.log(this.globalLogError, args);
  39000. };
  39001. Logger.prototype.globalLogWarn = function (message) {
  39002. if (window.console && window.console.warn) {
  39003. window.console.warn(message);
  39004. }
  39005. else {
  39006. this.globalLog(message);
  39007. }
  39008. };
  39009. Logger.prototype.globalLogError = function (message) {
  39010. if (window.console && window.console.error) {
  39011. window.console.error(message);
  39012. }
  39013. else {
  39014. this.globalLogWarn(message);
  39015. }
  39016. };
  39017. Logger.prototype.log = function (defaultLoggingFunction) {
  39018. var args = [];
  39019. for (var _i = 1; _i < arguments.length; _i++) {
  39020. args[_i - 1] = arguments[_i];
  39021. }
  39022. var message = stringify.apply(this, arguments);
  39023. if (core_pusher.log) {
  39024. core_pusher.log(message);
  39025. }
  39026. else if (core_pusher.logToConsole) {
  39027. var log = defaultLoggingFunction.bind(this);
  39028. log(message);
  39029. }
  39030. };
  39031. return Logger;
  39032. }());
  39033. /* harmony default export */ var logger = (new logger_Logger());
  39034. // CONCATENATED MODULE: ./src/core/utils/url_store.ts
  39035. var urlStore = {
  39036. baseUrl: "https://pusher.com",
  39037. urls: {
  39038. authenticationEndpoint: {
  39039. path: "/docs/authenticating_users",
  39040. },
  39041. javascriptQuickStart: {
  39042. path: "/docs/javascript_quick_start"
  39043. },
  39044. triggeringClientEvents: {
  39045. path: "/docs/client_api_guide/client_events#trigger-events"
  39046. }
  39047. }
  39048. };
  39049. var buildLogSuffix = function (key) {
  39050. var urlPrefix = "See:";
  39051. var urlObj = urlStore.urls[key];
  39052. if (!urlObj)
  39053. return "";
  39054. var url;
  39055. if (urlObj.fullUrl) {
  39056. url = urlObj.fullUrl;
  39057. }
  39058. else if (urlObj.path) {
  39059. url = urlStore.baseUrl + urlObj.path;
  39060. }
  39061. if (!url)
  39062. return "";
  39063. return urlPrefix + " " + url;
  39064. };
  39065. /* harmony default export */ var url_store = ({ buildLogSuffix: buildLogSuffix });
  39066. // CONCATENATED MODULE: ./src/runtimes/isomorphic/auth/xhr_auth.ts
  39067. var ajax = function (context, socketId, callback) {
  39068. var self = this, xhr;
  39069. xhr = runtime.createXHR();
  39070. xhr.open("POST", self.options.authEndpoint, true);
  39071. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  39072. for (var headerName in this.authOptions.headers) {
  39073. xhr.setRequestHeader(headerName, this.authOptions.headers[headerName]);
  39074. }
  39075. xhr.onreadystatechange = function () {
  39076. if (xhr.readyState === 4) {
  39077. if (xhr.status === 200) {
  39078. var data, parsed = false;
  39079. try {
  39080. data = JSON.parse(xhr.responseText);
  39081. parsed = true;
  39082. }
  39083. catch (e) {
  39084. callback(true, 'JSON returned from auth endpoint was invalid, yet status code was 200. Data was: ' + xhr.responseText);
  39085. }
  39086. if (parsed) {
  39087. callback(false, data);
  39088. }
  39089. }
  39090. else {
  39091. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  39092. logger.error('Unable to retrieve auth string from auth endpoint - ' +
  39093. ("received status " + xhr.status + " from " + self.options.authEndpoint + ". ") +
  39094. ("Clients must be authenticated to join private or presence channels. " + suffix));
  39095. callback(true, xhr.status);
  39096. }
  39097. }
  39098. };
  39099. xhr.send(this.composeQuery(socketId));
  39100. return xhr;
  39101. };
  39102. /* harmony default export */ var xhr_auth = (ajax);
  39103. // CONCATENATED MODULE: ./src/runtimes/web/auth/jsonp_auth.ts
  39104. var jsonp = function (context, socketId, callback) {
  39105. if (this.authOptions.headers !== undefined) {
  39106. logger.warn('To send headers with the auth request, you must use AJAX, rather than JSONP.');
  39107. }
  39108. var callbackName = context.nextAuthCallbackID.toString();
  39109. context.nextAuthCallbackID++;
  39110. var document = context.getDocument();
  39111. var script = document.createElement("script");
  39112. context.auth_callbacks[callbackName] = function (data) {
  39113. callback(false, data);
  39114. };
  39115. var callback_name = "Pusher.auth_callbacks['" + callbackName + "']";
  39116. script.src = this.options.authEndpoint +
  39117. '?callback=' +
  39118. encodeURIComponent(callback_name) +
  39119. '&' +
  39120. this.composeQuery(socketId);
  39121. var head = document.getElementsByTagName("head")[0] || document.documentElement;
  39122. head.insertBefore(script, head.firstChild);
  39123. };
  39124. /* harmony default export */ var jsonp_auth = (jsonp);
  39125. // CONCATENATED MODULE: ./src/runtimes/web/dom/script_request.ts
  39126. var ScriptRequest = (function () {
  39127. function ScriptRequest(src) {
  39128. this.src = src;
  39129. }
  39130. ScriptRequest.prototype.send = function (receiver) {
  39131. var self = this;
  39132. var errorString = "Error loading " + self.src;
  39133. self.script = document.createElement("script");
  39134. self.script.id = receiver.id;
  39135. self.script.src = self.src;
  39136. self.script.type = "text/javascript";
  39137. self.script.charset = "UTF-8";
  39138. if (self.script.addEventListener) {
  39139. self.script.onerror = function () {
  39140. receiver.callback(errorString);
  39141. };
  39142. self.script.onload = function () {
  39143. receiver.callback(null);
  39144. };
  39145. }
  39146. else {
  39147. self.script.onreadystatechange = function () {
  39148. if (self.script.readyState === 'loaded' ||
  39149. self.script.readyState === 'complete') {
  39150. receiver.callback(null);
  39151. }
  39152. };
  39153. }
  39154. if (self.script.async === undefined && document.attachEvent &&
  39155. /opera/i.test(navigator.userAgent)) {
  39156. self.errorScript = document.createElement("script");
  39157. self.errorScript.id = receiver.id + "_error";
  39158. self.errorScript.text = receiver.name + "('" + errorString + "');";
  39159. self.script.async = self.errorScript.async = false;
  39160. }
  39161. else {
  39162. self.script.async = true;
  39163. }
  39164. var head = document.getElementsByTagName('head')[0];
  39165. head.insertBefore(self.script, head.firstChild);
  39166. if (self.errorScript) {
  39167. head.insertBefore(self.errorScript, self.script.nextSibling);
  39168. }
  39169. };
  39170. ScriptRequest.prototype.cleanup = function () {
  39171. if (this.script) {
  39172. this.script.onload = this.script.onerror = null;
  39173. this.script.onreadystatechange = null;
  39174. }
  39175. if (this.script && this.script.parentNode) {
  39176. this.script.parentNode.removeChild(this.script);
  39177. }
  39178. if (this.errorScript && this.errorScript.parentNode) {
  39179. this.errorScript.parentNode.removeChild(this.errorScript);
  39180. }
  39181. this.script = null;
  39182. this.errorScript = null;
  39183. };
  39184. return ScriptRequest;
  39185. }());
  39186. /* harmony default export */ var script_request = (ScriptRequest);
  39187. // CONCATENATED MODULE: ./src/runtimes/web/dom/jsonp_request.ts
  39188. var jsonp_request_JSONPRequest = (function () {
  39189. function JSONPRequest(url, data) {
  39190. this.url = url;
  39191. this.data = data;
  39192. }
  39193. JSONPRequest.prototype.send = function (receiver) {
  39194. if (this.request) {
  39195. return;
  39196. }
  39197. var query = buildQueryString(this.data);
  39198. var url = this.url + "/" + receiver.number + "?" + query;
  39199. this.request = runtime.createScriptRequest(url);
  39200. this.request.send(receiver);
  39201. };
  39202. JSONPRequest.prototype.cleanup = function () {
  39203. if (this.request) {
  39204. this.request.cleanup();
  39205. }
  39206. };
  39207. return JSONPRequest;
  39208. }());
  39209. /* harmony default export */ var jsonp_request = (jsonp_request_JSONPRequest);
  39210. // CONCATENATED MODULE: ./src/runtimes/web/timeline/jsonp_timeline.ts
  39211. var getAgent = function (sender, useTLS) {
  39212. return function (data, callback) {
  39213. var scheme = "http" + (useTLS ? "s" : "") + "://";
  39214. var url = scheme + (sender.host || sender.options.host) + sender.options.path;
  39215. var request = runtime.createJSONPRequest(url, data);
  39216. var receiver = runtime.ScriptReceivers.create(function (error, result) {
  39217. ScriptReceivers.remove(receiver);
  39218. request.cleanup();
  39219. if (result && result.host) {
  39220. sender.host = result.host;
  39221. }
  39222. if (callback) {
  39223. callback(error, result);
  39224. }
  39225. });
  39226. request.send(receiver);
  39227. };
  39228. };
  39229. var jsonp_timeline_jsonp = {
  39230. name: 'jsonp',
  39231. getAgent: getAgent
  39232. };
  39233. /* harmony default export */ var jsonp_timeline = (jsonp_timeline_jsonp);
  39234. // CONCATENATED MODULE: ./src/core/transports/url_schemes.ts
  39235. function getGenericURL(baseScheme, params, path) {
  39236. var scheme = baseScheme + (params.useTLS ? "s" : "");
  39237. var host = params.useTLS ? params.hostTLS : params.hostNonTLS;
  39238. return scheme + "://" + host + path;
  39239. }
  39240. function getGenericPath(key, queryString) {
  39241. var path = "/app/" + key;
  39242. var query = "?protocol=" + defaults.PROTOCOL +
  39243. "&client=js" +
  39244. "&version=" + defaults.VERSION +
  39245. (queryString ? ("&" + queryString) : "");
  39246. return path + query;
  39247. }
  39248. var ws = {
  39249. getInitial: function (key, params) {
  39250. var path = (params.httpPath || "") + getGenericPath(key, "flash=false");
  39251. return getGenericURL("ws", params, path);
  39252. }
  39253. };
  39254. var http = {
  39255. getInitial: function (key, params) {
  39256. var path = (params.httpPath || "/pusher") + getGenericPath(key);
  39257. return getGenericURL("http", params, path);
  39258. }
  39259. };
  39260. var sockjs = {
  39261. getInitial: function (key, params) {
  39262. return getGenericURL("http", params, params.httpPath || "/pusher");
  39263. },
  39264. getPath: function (key, params) {
  39265. return getGenericPath(key);
  39266. }
  39267. };
  39268. // CONCATENATED MODULE: ./src/core/events/callback_registry.ts
  39269. var callback_registry_CallbackRegistry = (function () {
  39270. function CallbackRegistry() {
  39271. this._callbacks = {};
  39272. }
  39273. CallbackRegistry.prototype.get = function (name) {
  39274. return this._callbacks[prefix(name)];
  39275. };
  39276. CallbackRegistry.prototype.add = function (name, callback, context) {
  39277. var prefixedEventName = prefix(name);
  39278. this._callbacks[prefixedEventName] = this._callbacks[prefixedEventName] || [];
  39279. this._callbacks[prefixedEventName].push({
  39280. fn: callback,
  39281. context: context
  39282. });
  39283. };
  39284. CallbackRegistry.prototype.remove = function (name, callback, context) {
  39285. if (!name && !callback && !context) {
  39286. this._callbacks = {};
  39287. return;
  39288. }
  39289. var names = name ? [prefix(name)] : keys(this._callbacks);
  39290. if (callback || context) {
  39291. this.removeCallback(names, callback, context);
  39292. }
  39293. else {
  39294. this.removeAllCallbacks(names);
  39295. }
  39296. };
  39297. CallbackRegistry.prototype.removeCallback = function (names, callback, context) {
  39298. apply(names, function (name) {
  39299. this._callbacks[name] = filter(this._callbacks[name] || [], function (binding) {
  39300. return (callback && callback !== binding.fn) ||
  39301. (context && context !== binding.context);
  39302. });
  39303. if (this._callbacks[name].length === 0) {
  39304. delete this._callbacks[name];
  39305. }
  39306. }, this);
  39307. };
  39308. CallbackRegistry.prototype.removeAllCallbacks = function (names) {
  39309. apply(names, function (name) {
  39310. delete this._callbacks[name];
  39311. }, this);
  39312. };
  39313. return CallbackRegistry;
  39314. }());
  39315. /* harmony default export */ var callback_registry = (callback_registry_CallbackRegistry);
  39316. function prefix(name) {
  39317. return "_" + name;
  39318. }
  39319. // CONCATENATED MODULE: ./src/core/events/dispatcher.ts
  39320. var dispatcher_Dispatcher = (function () {
  39321. function Dispatcher(failThrough) {
  39322. this.callbacks = new callback_registry();
  39323. this.global_callbacks = [];
  39324. this.failThrough = failThrough;
  39325. }
  39326. Dispatcher.prototype.bind = function (eventName, callback, context) {
  39327. this.callbacks.add(eventName, callback, context);
  39328. return this;
  39329. };
  39330. Dispatcher.prototype.bind_global = function (callback) {
  39331. this.global_callbacks.push(callback);
  39332. return this;
  39333. };
  39334. Dispatcher.prototype.unbind = function (eventName, callback, context) {
  39335. this.callbacks.remove(eventName, callback, context);
  39336. return this;
  39337. };
  39338. Dispatcher.prototype.unbind_global = function (callback) {
  39339. if (!callback) {
  39340. this.global_callbacks = [];
  39341. return this;
  39342. }
  39343. this.global_callbacks = filter(this.global_callbacks || [], function (c) { return c !== callback; });
  39344. return this;
  39345. };
  39346. Dispatcher.prototype.unbind_all = function () {
  39347. this.unbind();
  39348. this.unbind_global();
  39349. return this;
  39350. };
  39351. Dispatcher.prototype.emit = function (eventName, data, metadata) {
  39352. for (var i = 0; i < this.global_callbacks.length; i++) {
  39353. this.global_callbacks[i](eventName, data);
  39354. }
  39355. var callbacks = this.callbacks.get(eventName);
  39356. var args = [];
  39357. if (metadata) {
  39358. args.push(data, metadata);
  39359. }
  39360. else if (data) {
  39361. args.push(data);
  39362. }
  39363. if (callbacks && callbacks.length > 0) {
  39364. for (var i = 0; i < callbacks.length; i++) {
  39365. callbacks[i].fn.apply(callbacks[i].context || window, args);
  39366. }
  39367. }
  39368. else if (this.failThrough) {
  39369. this.failThrough(eventName, data);
  39370. }
  39371. return this;
  39372. };
  39373. return Dispatcher;
  39374. }());
  39375. /* harmony default export */ var dispatcher = (dispatcher_Dispatcher);
  39376. // CONCATENATED MODULE: ./src/core/transports/transport_connection.ts
  39377. var transport_connection_extends = (undefined && undefined.__extends) || (function () {
  39378. var extendStatics = function (d, b) {
  39379. extendStatics = Object.setPrototypeOf ||
  39380. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39381. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39382. return extendStatics(d, b);
  39383. };
  39384. return function (d, b) {
  39385. extendStatics(d, b);
  39386. function __() { this.constructor = d; }
  39387. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39388. };
  39389. })();
  39390. var transport_connection_TransportConnection = (function (_super) {
  39391. transport_connection_extends(TransportConnection, _super);
  39392. function TransportConnection(hooks, name, priority, key, options) {
  39393. var _this = _super.call(this) || this;
  39394. _this.initialize = runtime.transportConnectionInitializer;
  39395. _this.hooks = hooks;
  39396. _this.name = name;
  39397. _this.priority = priority;
  39398. _this.key = key;
  39399. _this.options = options;
  39400. _this.state = "new";
  39401. _this.timeline = options.timeline;
  39402. _this.activityTimeout = options.activityTimeout;
  39403. _this.id = _this.timeline.generateUniqueID();
  39404. return _this;
  39405. }
  39406. TransportConnection.prototype.handlesActivityChecks = function () {
  39407. return Boolean(this.hooks.handlesActivityChecks);
  39408. };
  39409. TransportConnection.prototype.supportsPing = function () {
  39410. return Boolean(this.hooks.supportsPing);
  39411. };
  39412. TransportConnection.prototype.connect = function () {
  39413. var _this = this;
  39414. if (this.socket || this.state !== "initialized") {
  39415. return false;
  39416. }
  39417. var url = this.hooks.urls.getInitial(this.key, this.options);
  39418. try {
  39419. this.socket = this.hooks.getSocket(url, this.options);
  39420. }
  39421. catch (e) {
  39422. util.defer(function () {
  39423. _this.onError(e);
  39424. _this.changeState("closed");
  39425. });
  39426. return false;
  39427. }
  39428. this.bindListeners();
  39429. logger.debug("Connecting", { transport: this.name, url: url });
  39430. this.changeState("connecting");
  39431. return true;
  39432. };
  39433. TransportConnection.prototype.close = function () {
  39434. if (this.socket) {
  39435. this.socket.close();
  39436. return true;
  39437. }
  39438. else {
  39439. return false;
  39440. }
  39441. };
  39442. TransportConnection.prototype.send = function (data) {
  39443. var _this = this;
  39444. if (this.state === "open") {
  39445. util.defer(function () {
  39446. if (_this.socket) {
  39447. _this.socket.send(data);
  39448. }
  39449. });
  39450. return true;
  39451. }
  39452. else {
  39453. return false;
  39454. }
  39455. };
  39456. TransportConnection.prototype.ping = function () {
  39457. if (this.state === "open" && this.supportsPing()) {
  39458. this.socket.ping();
  39459. }
  39460. };
  39461. TransportConnection.prototype.onOpen = function () {
  39462. if (this.hooks.beforeOpen) {
  39463. this.hooks.beforeOpen(this.socket, this.hooks.urls.getPath(this.key, this.options));
  39464. }
  39465. this.changeState("open");
  39466. this.socket.onopen = undefined;
  39467. };
  39468. TransportConnection.prototype.onError = function (error) {
  39469. this.emit("error", { type: 'WebSocketError', error: error });
  39470. this.timeline.error(this.buildTimelineMessage({ error: error.toString() }));
  39471. };
  39472. TransportConnection.prototype.onClose = function (closeEvent) {
  39473. if (closeEvent) {
  39474. this.changeState("closed", {
  39475. code: closeEvent.code,
  39476. reason: closeEvent.reason,
  39477. wasClean: closeEvent.wasClean
  39478. });
  39479. }
  39480. else {
  39481. this.changeState("closed");
  39482. }
  39483. this.unbindListeners();
  39484. this.socket = undefined;
  39485. };
  39486. TransportConnection.prototype.onMessage = function (message) {
  39487. this.emit("message", message);
  39488. };
  39489. TransportConnection.prototype.onActivity = function () {
  39490. this.emit("activity");
  39491. };
  39492. TransportConnection.prototype.bindListeners = function () {
  39493. var _this = this;
  39494. this.socket.onopen = function () {
  39495. _this.onOpen();
  39496. };
  39497. this.socket.onerror = function (error) {
  39498. _this.onError(error);
  39499. };
  39500. this.socket.onclose = function (closeEvent) {
  39501. _this.onClose(closeEvent);
  39502. };
  39503. this.socket.onmessage = function (message) {
  39504. _this.onMessage(message);
  39505. };
  39506. if (this.supportsPing()) {
  39507. this.socket.onactivity = function () { _this.onActivity(); };
  39508. }
  39509. };
  39510. TransportConnection.prototype.unbindListeners = function () {
  39511. if (this.socket) {
  39512. this.socket.onopen = undefined;
  39513. this.socket.onerror = undefined;
  39514. this.socket.onclose = undefined;
  39515. this.socket.onmessage = undefined;
  39516. if (this.supportsPing()) {
  39517. this.socket.onactivity = undefined;
  39518. }
  39519. }
  39520. };
  39521. TransportConnection.prototype.changeState = function (state, params) {
  39522. this.state = state;
  39523. this.timeline.info(this.buildTimelineMessage({
  39524. state: state,
  39525. params: params
  39526. }));
  39527. this.emit(state, params);
  39528. };
  39529. TransportConnection.prototype.buildTimelineMessage = function (message) {
  39530. return extend({ cid: this.id }, message);
  39531. };
  39532. return TransportConnection;
  39533. }(dispatcher));
  39534. /* harmony default export */ var transport_connection = (transport_connection_TransportConnection);
  39535. // CONCATENATED MODULE: ./src/core/transports/transport.ts
  39536. var transport_Transport = (function () {
  39537. function Transport(hooks) {
  39538. this.hooks = hooks;
  39539. }
  39540. Transport.prototype.isSupported = function (environment) {
  39541. return this.hooks.isSupported(environment);
  39542. };
  39543. Transport.prototype.createConnection = function (name, priority, key, options) {
  39544. return new transport_connection(this.hooks, name, priority, key, options);
  39545. };
  39546. return Transport;
  39547. }());
  39548. /* harmony default export */ var transports_transport = (transport_Transport);
  39549. // CONCATENATED MODULE: ./src/runtimes/isomorphic/transports/transports.ts
  39550. var WSTransport = new transports_transport({
  39551. urls: ws,
  39552. handlesActivityChecks: false,
  39553. supportsPing: false,
  39554. isInitialized: function () {
  39555. return Boolean(runtime.getWebSocketAPI());
  39556. },
  39557. isSupported: function () {
  39558. return Boolean(runtime.getWebSocketAPI());
  39559. },
  39560. getSocket: function (url) {
  39561. return runtime.createWebSocket(url);
  39562. }
  39563. });
  39564. var httpConfiguration = {
  39565. urls: http,
  39566. handlesActivityChecks: false,
  39567. supportsPing: true,
  39568. isInitialized: function () {
  39569. return true;
  39570. }
  39571. };
  39572. var streamingConfiguration = extend({ getSocket: function (url) {
  39573. return runtime.HTTPFactory.createStreamingSocket(url);
  39574. }
  39575. }, httpConfiguration);
  39576. var pollingConfiguration = extend({ getSocket: function (url) {
  39577. return runtime.HTTPFactory.createPollingSocket(url);
  39578. }
  39579. }, httpConfiguration);
  39580. var xhrConfiguration = {
  39581. isSupported: function () {
  39582. return runtime.isXHRSupported();
  39583. }
  39584. };
  39585. var XHRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xhrConfiguration));
  39586. var XHRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xhrConfiguration));
  39587. var Transports = {
  39588. ws: WSTransport,
  39589. xhr_streaming: XHRStreamingTransport,
  39590. xhr_polling: XHRPollingTransport
  39591. };
  39592. /* harmony default export */ var transports = (Transports);
  39593. // CONCATENATED MODULE: ./src/runtimes/web/transports/transports.ts
  39594. var SockJSTransport = new transports_transport({
  39595. file: "sockjs",
  39596. urls: sockjs,
  39597. handlesActivityChecks: true,
  39598. supportsPing: false,
  39599. isSupported: function () {
  39600. return true;
  39601. },
  39602. isInitialized: function () {
  39603. return window.SockJS !== undefined;
  39604. },
  39605. getSocket: function (url, options) {
  39606. return new window.SockJS(url, null, {
  39607. js_path: Dependencies.getPath("sockjs", {
  39608. useTLS: options.useTLS
  39609. }),
  39610. ignore_null_origin: options.ignoreNullOrigin
  39611. });
  39612. },
  39613. beforeOpen: function (socket, path) {
  39614. socket.send(JSON.stringify({
  39615. path: path
  39616. }));
  39617. }
  39618. });
  39619. var xdrConfiguration = {
  39620. isSupported: function (environment) {
  39621. var yes = runtime.isXDRSupported(environment.useTLS);
  39622. return yes;
  39623. }
  39624. };
  39625. var XDRStreamingTransport = new transports_transport(extend({}, streamingConfiguration, xdrConfiguration));
  39626. var XDRPollingTransport = new transports_transport(extend({}, pollingConfiguration, xdrConfiguration));
  39627. transports.xdr_streaming = XDRStreamingTransport;
  39628. transports.xdr_polling = XDRPollingTransport;
  39629. transports.sockjs = SockJSTransport;
  39630. /* harmony default export */ var transports_transports = (transports);
  39631. // CONCATENATED MODULE: ./src/runtimes/web/net_info.ts
  39632. var net_info_extends = (undefined && undefined.__extends) || (function () {
  39633. var extendStatics = function (d, b) {
  39634. extendStatics = Object.setPrototypeOf ||
  39635. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39636. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39637. return extendStatics(d, b);
  39638. };
  39639. return function (d, b) {
  39640. extendStatics(d, b);
  39641. function __() { this.constructor = d; }
  39642. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39643. };
  39644. })();
  39645. var NetInfo = (function (_super) {
  39646. net_info_extends(NetInfo, _super);
  39647. function NetInfo() {
  39648. var _this = _super.call(this) || this;
  39649. var self = _this;
  39650. if (window.addEventListener !== undefined) {
  39651. window.addEventListener("online", function () {
  39652. self.emit('online');
  39653. }, false);
  39654. window.addEventListener("offline", function () {
  39655. self.emit('offline');
  39656. }, false);
  39657. }
  39658. return _this;
  39659. }
  39660. NetInfo.prototype.isOnline = function () {
  39661. if (window.navigator.onLine === undefined) {
  39662. return true;
  39663. }
  39664. else {
  39665. return window.navigator.onLine;
  39666. }
  39667. };
  39668. return NetInfo;
  39669. }(dispatcher));
  39670. var net_info_Network = new NetInfo();
  39671. // CONCATENATED MODULE: ./src/core/transports/assistant_to_the_transport_manager.ts
  39672. var assistant_to_the_transport_manager_AssistantToTheTransportManager = (function () {
  39673. function AssistantToTheTransportManager(manager, transport, options) {
  39674. this.manager = manager;
  39675. this.transport = transport;
  39676. this.minPingDelay = options.minPingDelay;
  39677. this.maxPingDelay = options.maxPingDelay;
  39678. this.pingDelay = undefined;
  39679. }
  39680. AssistantToTheTransportManager.prototype.createConnection = function (name, priority, key, options) {
  39681. var _this = this;
  39682. options = extend({}, options, {
  39683. activityTimeout: this.pingDelay
  39684. });
  39685. var connection = this.transport.createConnection(name, priority, key, options);
  39686. var openTimestamp = null;
  39687. var onOpen = function () {
  39688. connection.unbind("open", onOpen);
  39689. connection.bind("closed", onClosed);
  39690. openTimestamp = util.now();
  39691. };
  39692. var onClosed = function (closeEvent) {
  39693. connection.unbind("closed", onClosed);
  39694. if (closeEvent.code === 1002 || closeEvent.code === 1003) {
  39695. _this.manager.reportDeath();
  39696. }
  39697. else if (!closeEvent.wasClean && openTimestamp) {
  39698. var lifespan = util.now() - openTimestamp;
  39699. if (lifespan < 2 * _this.maxPingDelay) {
  39700. _this.manager.reportDeath();
  39701. _this.pingDelay = Math.max(lifespan / 2, _this.minPingDelay);
  39702. }
  39703. }
  39704. };
  39705. connection.bind("open", onOpen);
  39706. return connection;
  39707. };
  39708. AssistantToTheTransportManager.prototype.isSupported = function (environment) {
  39709. return this.manager.isAlive() && this.transport.isSupported(environment);
  39710. };
  39711. return AssistantToTheTransportManager;
  39712. }());
  39713. /* harmony default export */ var assistant_to_the_transport_manager = (assistant_to_the_transport_manager_AssistantToTheTransportManager);
  39714. // CONCATENATED MODULE: ./src/core/connection/protocol/protocol.ts
  39715. var Protocol = {
  39716. decodeMessage: function (messageEvent) {
  39717. try {
  39718. var messageData = JSON.parse(messageEvent.data);
  39719. var pusherEventData = messageData.data;
  39720. if (typeof pusherEventData === 'string') {
  39721. try {
  39722. pusherEventData = JSON.parse(messageData.data);
  39723. }
  39724. catch (e) { }
  39725. }
  39726. var pusherEvent = {
  39727. event: messageData.event,
  39728. channel: messageData.channel,
  39729. data: pusherEventData,
  39730. };
  39731. if (messageData.user_id) {
  39732. pusherEvent.user_id = messageData.user_id;
  39733. }
  39734. return pusherEvent;
  39735. }
  39736. catch (e) {
  39737. throw { type: 'MessageParseError', error: e, data: messageEvent.data };
  39738. }
  39739. },
  39740. encodeMessage: function (event) {
  39741. return JSON.stringify(event);
  39742. },
  39743. processHandshake: function (messageEvent) {
  39744. var message = Protocol.decodeMessage(messageEvent);
  39745. if (message.event === "pusher:connection_established") {
  39746. if (!message.data.activity_timeout) {
  39747. throw "No activity timeout specified in handshake";
  39748. }
  39749. return {
  39750. action: "connected",
  39751. id: message.data.socket_id,
  39752. activityTimeout: message.data.activity_timeout * 1000
  39753. };
  39754. }
  39755. else if (message.event === "pusher:error") {
  39756. return {
  39757. action: this.getCloseAction(message.data),
  39758. error: this.getCloseError(message.data)
  39759. };
  39760. }
  39761. else {
  39762. throw "Invalid handshake";
  39763. }
  39764. },
  39765. getCloseAction: function (closeEvent) {
  39766. if (closeEvent.code < 4000) {
  39767. if (closeEvent.code >= 1002 && closeEvent.code <= 1004) {
  39768. return "backoff";
  39769. }
  39770. else {
  39771. return null;
  39772. }
  39773. }
  39774. else if (closeEvent.code === 4000) {
  39775. return "tls_only";
  39776. }
  39777. else if (closeEvent.code < 4100) {
  39778. return "refused";
  39779. }
  39780. else if (closeEvent.code < 4200) {
  39781. return "backoff";
  39782. }
  39783. else if (closeEvent.code < 4300) {
  39784. return "retry";
  39785. }
  39786. else {
  39787. return "refused";
  39788. }
  39789. },
  39790. getCloseError: function (closeEvent) {
  39791. if (closeEvent.code !== 1000 && closeEvent.code !== 1001) {
  39792. return {
  39793. type: 'PusherError',
  39794. data: {
  39795. code: closeEvent.code,
  39796. message: closeEvent.reason || closeEvent.message
  39797. }
  39798. };
  39799. }
  39800. else {
  39801. return null;
  39802. }
  39803. }
  39804. };
  39805. /* harmony default export */ var protocol_protocol = (Protocol);
  39806. // CONCATENATED MODULE: ./src/core/connection/connection.ts
  39807. var connection_extends = (undefined && undefined.__extends) || (function () {
  39808. var extendStatics = function (d, b) {
  39809. extendStatics = Object.setPrototypeOf ||
  39810. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  39811. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39812. return extendStatics(d, b);
  39813. };
  39814. return function (d, b) {
  39815. extendStatics(d, b);
  39816. function __() { this.constructor = d; }
  39817. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39818. };
  39819. })();
  39820. var connection_Connection = (function (_super) {
  39821. connection_extends(Connection, _super);
  39822. function Connection(id, transport) {
  39823. var _this = _super.call(this) || this;
  39824. _this.id = id;
  39825. _this.transport = transport;
  39826. _this.activityTimeout = transport.activityTimeout;
  39827. _this.bindListeners();
  39828. return _this;
  39829. }
  39830. Connection.prototype.handlesActivityChecks = function () {
  39831. return this.transport.handlesActivityChecks();
  39832. };
  39833. Connection.prototype.send = function (data) {
  39834. return this.transport.send(data);
  39835. };
  39836. Connection.prototype.send_event = function (name, data, channel) {
  39837. var event = { event: name, data: data };
  39838. if (channel) {
  39839. event.channel = channel;
  39840. }
  39841. logger.debug('Event sent', event);
  39842. return this.send(protocol_protocol.encodeMessage(event));
  39843. };
  39844. Connection.prototype.ping = function () {
  39845. if (this.transport.supportsPing()) {
  39846. this.transport.ping();
  39847. }
  39848. else {
  39849. this.send_event('pusher:ping', {});
  39850. }
  39851. };
  39852. Connection.prototype.close = function () {
  39853. this.transport.close();
  39854. };
  39855. Connection.prototype.bindListeners = function () {
  39856. var _this = this;
  39857. var listeners = {
  39858. message: function (messageEvent) {
  39859. var pusherEvent;
  39860. try {
  39861. pusherEvent = protocol_protocol.decodeMessage(messageEvent);
  39862. }
  39863. catch (e) {
  39864. _this.emit('error', {
  39865. type: 'MessageParseError',
  39866. error: e,
  39867. data: messageEvent.data
  39868. });
  39869. }
  39870. if (pusherEvent !== undefined) {
  39871. logger.debug('Event recd', pusherEvent);
  39872. switch (pusherEvent.event) {
  39873. case 'pusher:error':
  39874. _this.emit('error', { type: 'PusherError', data: pusherEvent.data });
  39875. break;
  39876. case 'pusher:ping':
  39877. _this.emit("ping");
  39878. break;
  39879. case 'pusher:pong':
  39880. _this.emit("pong");
  39881. break;
  39882. }
  39883. _this.emit('message', pusherEvent);
  39884. }
  39885. },
  39886. activity: function () {
  39887. _this.emit("activity");
  39888. },
  39889. error: function (error) {
  39890. _this.emit("error", { type: "WebSocketError", error: error });
  39891. },
  39892. closed: function (closeEvent) {
  39893. unbindListeners();
  39894. if (closeEvent && closeEvent.code) {
  39895. _this.handleCloseEvent(closeEvent);
  39896. }
  39897. _this.transport = null;
  39898. _this.emit("closed");
  39899. }
  39900. };
  39901. var unbindListeners = function () {
  39902. objectApply(listeners, function (listener, event) {
  39903. _this.transport.unbind(event, listener);
  39904. });
  39905. };
  39906. objectApply(listeners, function (listener, event) {
  39907. _this.transport.bind(event, listener);
  39908. });
  39909. };
  39910. Connection.prototype.handleCloseEvent = function (closeEvent) {
  39911. var action = protocol_protocol.getCloseAction(closeEvent);
  39912. var error = protocol_protocol.getCloseError(closeEvent);
  39913. if (error) {
  39914. this.emit('error', error);
  39915. }
  39916. if (action) {
  39917. this.emit(action, { action: action, error: error });
  39918. }
  39919. };
  39920. return Connection;
  39921. }(dispatcher));
  39922. /* harmony default export */ var connection_connection = (connection_Connection);
  39923. // CONCATENATED MODULE: ./src/core/connection/handshake/index.ts
  39924. var handshake_Handshake = (function () {
  39925. function Handshake(transport, callback) {
  39926. this.transport = transport;
  39927. this.callback = callback;
  39928. this.bindListeners();
  39929. }
  39930. Handshake.prototype.close = function () {
  39931. this.unbindListeners();
  39932. this.transport.close();
  39933. };
  39934. Handshake.prototype.bindListeners = function () {
  39935. var _this = this;
  39936. this.onMessage = function (m) {
  39937. _this.unbindListeners();
  39938. var result;
  39939. try {
  39940. result = protocol_protocol.processHandshake(m);
  39941. }
  39942. catch (e) {
  39943. _this.finish("error", { error: e });
  39944. _this.transport.close();
  39945. return;
  39946. }
  39947. if (result.action === "connected") {
  39948. _this.finish("connected", {
  39949. connection: new connection_connection(result.id, _this.transport),
  39950. activityTimeout: result.activityTimeout
  39951. });
  39952. }
  39953. else {
  39954. _this.finish(result.action, { error: result.error });
  39955. _this.transport.close();
  39956. }
  39957. };
  39958. this.onClosed = function (closeEvent) {
  39959. _this.unbindListeners();
  39960. var action = protocol_protocol.getCloseAction(closeEvent) || "backoff";
  39961. var error = protocol_protocol.getCloseError(closeEvent);
  39962. _this.finish(action, { error: error });
  39963. };
  39964. this.transport.bind("message", this.onMessage);
  39965. this.transport.bind("closed", this.onClosed);
  39966. };
  39967. Handshake.prototype.unbindListeners = function () {
  39968. this.transport.unbind("message", this.onMessage);
  39969. this.transport.unbind("closed", this.onClosed);
  39970. };
  39971. Handshake.prototype.finish = function (action, params) {
  39972. this.callback(extend({ transport: this.transport, action: action }, params));
  39973. };
  39974. return Handshake;
  39975. }());
  39976. /* harmony default export */ var connection_handshake = (handshake_Handshake);
  39977. // CONCATENATED MODULE: ./src/core/auth/pusher_authorizer.ts
  39978. var pusher_authorizer_PusherAuthorizer = (function () {
  39979. function PusherAuthorizer(channel, options) {
  39980. this.channel = channel;
  39981. var authTransport = options.authTransport;
  39982. if (typeof runtime.getAuthorizers()[authTransport] === "undefined") {
  39983. throw "'" + authTransport + "' is not a recognized auth transport";
  39984. }
  39985. this.type = authTransport;
  39986. this.options = options;
  39987. this.authOptions = (options || {}).auth || {};
  39988. }
  39989. PusherAuthorizer.prototype.composeQuery = function (socketId) {
  39990. var query = 'socket_id=' + encodeURIComponent(socketId) +
  39991. '&channel_name=' + encodeURIComponent(this.channel.name);
  39992. for (var i in this.authOptions.params) {
  39993. query += "&" + encodeURIComponent(i) + "=" + encodeURIComponent(this.authOptions.params[i]);
  39994. }
  39995. return query;
  39996. };
  39997. PusherAuthorizer.prototype.authorize = function (socketId, callback) {
  39998. PusherAuthorizer.authorizers = PusherAuthorizer.authorizers || runtime.getAuthorizers();
  39999. return PusherAuthorizer.authorizers[this.type].call(this, runtime, socketId, callback);
  40000. };
  40001. return PusherAuthorizer;
  40002. }());
  40003. /* harmony default export */ var pusher_authorizer = (pusher_authorizer_PusherAuthorizer);
  40004. // CONCATENATED MODULE: ./src/core/timeline/timeline_sender.ts
  40005. var timeline_sender_TimelineSender = (function () {
  40006. function TimelineSender(timeline, options) {
  40007. this.timeline = timeline;
  40008. this.options = options || {};
  40009. }
  40010. TimelineSender.prototype.send = function (useTLS, callback) {
  40011. if (this.timeline.isEmpty()) {
  40012. return;
  40013. }
  40014. this.timeline.send(runtime.TimelineTransport.getAgent(this, useTLS), callback);
  40015. };
  40016. return TimelineSender;
  40017. }());
  40018. /* harmony default export */ var timeline_sender = (timeline_sender_TimelineSender);
  40019. // CONCATENATED MODULE: ./src/core/errors.ts
  40020. var errors_extends = (undefined && undefined.__extends) || (function () {
  40021. var extendStatics = function (d, b) {
  40022. extendStatics = Object.setPrototypeOf ||
  40023. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40024. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40025. return extendStatics(d, b);
  40026. };
  40027. return function (d, b) {
  40028. extendStatics(d, b);
  40029. function __() { this.constructor = d; }
  40030. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40031. };
  40032. })();
  40033. var BadEventName = (function (_super) {
  40034. errors_extends(BadEventName, _super);
  40035. function BadEventName(msg) {
  40036. var _newTarget = this.constructor;
  40037. var _this = _super.call(this, msg) || this;
  40038. Object.setPrototypeOf(_this, _newTarget.prototype);
  40039. return _this;
  40040. }
  40041. return BadEventName;
  40042. }(Error));
  40043. var RequestTimedOut = (function (_super) {
  40044. errors_extends(RequestTimedOut, _super);
  40045. function RequestTimedOut(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 RequestTimedOut;
  40052. }(Error));
  40053. var TransportPriorityTooLow = (function (_super) {
  40054. errors_extends(TransportPriorityTooLow, _super);
  40055. function TransportPriorityTooLow(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 TransportPriorityTooLow;
  40062. }(Error));
  40063. var TransportClosed = (function (_super) {
  40064. errors_extends(TransportClosed, _super);
  40065. function TransportClosed(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 TransportClosed;
  40072. }(Error));
  40073. var UnsupportedFeature = (function (_super) {
  40074. errors_extends(UnsupportedFeature, _super);
  40075. function UnsupportedFeature(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 UnsupportedFeature;
  40082. }(Error));
  40083. var UnsupportedTransport = (function (_super) {
  40084. errors_extends(UnsupportedTransport, _super);
  40085. function UnsupportedTransport(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 UnsupportedTransport;
  40092. }(Error));
  40093. var UnsupportedStrategy = (function (_super) {
  40094. errors_extends(UnsupportedStrategy, _super);
  40095. function UnsupportedStrategy(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 UnsupportedStrategy;
  40102. }(Error));
  40103. // CONCATENATED MODULE: ./src/core/channels/channel.ts
  40104. var channel_extends = (undefined && undefined.__extends) || (function () {
  40105. var extendStatics = function (d, b) {
  40106. extendStatics = Object.setPrototypeOf ||
  40107. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40108. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40109. return extendStatics(d, b);
  40110. };
  40111. return function (d, b) {
  40112. extendStatics(d, b);
  40113. function __() { this.constructor = d; }
  40114. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40115. };
  40116. })();
  40117. var channel_Channel = (function (_super) {
  40118. channel_extends(Channel, _super);
  40119. function Channel(name, pusher) {
  40120. var _this = _super.call(this, function (event, data) {
  40121. logger.debug('No callbacks on ' + name + ' for ' + event);
  40122. }) || this;
  40123. _this.name = name;
  40124. _this.pusher = pusher;
  40125. _this.subscribed = false;
  40126. _this.subscriptionPending = false;
  40127. _this.subscriptionCancelled = false;
  40128. return _this;
  40129. }
  40130. Channel.prototype.authorize = function (socketId, callback) {
  40131. return callback(false, {});
  40132. };
  40133. Channel.prototype.trigger = function (event, data) {
  40134. if (event.indexOf("client-") !== 0) {
  40135. throw new BadEventName("Event '" + event + "' does not start with 'client-'");
  40136. }
  40137. if (!this.subscribed) {
  40138. var suffix = url_store.buildLogSuffix("triggeringClientEvents");
  40139. logger.warn("Client event triggered before channel 'subscription_succeeded' event . " + suffix);
  40140. }
  40141. return this.pusher.send_event(event, data, this.name);
  40142. };
  40143. Channel.prototype.disconnect = function () {
  40144. this.subscribed = false;
  40145. this.subscriptionPending = false;
  40146. };
  40147. Channel.prototype.handleEvent = function (event) {
  40148. var eventName = event.event;
  40149. var data = event.data;
  40150. if (eventName === "pusher_internal:subscription_succeeded") {
  40151. this.handleSubscriptionSucceededEvent(event);
  40152. }
  40153. else if (eventName.indexOf("pusher_internal:") !== 0) {
  40154. var metadata = {};
  40155. this.emit(eventName, data, metadata);
  40156. }
  40157. };
  40158. Channel.prototype.handleSubscriptionSucceededEvent = function (event) {
  40159. this.subscriptionPending = false;
  40160. this.subscribed = true;
  40161. if (this.subscriptionCancelled) {
  40162. this.pusher.unsubscribe(this.name);
  40163. }
  40164. else {
  40165. this.emit("pusher:subscription_succeeded", event.data);
  40166. }
  40167. };
  40168. Channel.prototype.subscribe = function () {
  40169. var _this = this;
  40170. if (this.subscribed) {
  40171. return;
  40172. }
  40173. this.subscriptionPending = true;
  40174. this.subscriptionCancelled = false;
  40175. this.authorize(this.pusher.connection.socket_id, function (error, data) {
  40176. if (error) {
  40177. logger.error(data);
  40178. _this.emit('pusher:subscription_error', data);
  40179. }
  40180. else {
  40181. _this.pusher.send_event('pusher:subscribe', {
  40182. auth: data.auth,
  40183. channel_data: data.channel_data,
  40184. channel: _this.name
  40185. });
  40186. }
  40187. });
  40188. };
  40189. Channel.prototype.unsubscribe = function () {
  40190. this.subscribed = false;
  40191. this.pusher.send_event('pusher:unsubscribe', {
  40192. channel: this.name
  40193. });
  40194. };
  40195. Channel.prototype.cancelSubscription = function () {
  40196. this.subscriptionCancelled = true;
  40197. };
  40198. Channel.prototype.reinstateSubscription = function () {
  40199. this.subscriptionCancelled = false;
  40200. };
  40201. return Channel;
  40202. }(dispatcher));
  40203. /* harmony default export */ var channels_channel = (channel_Channel);
  40204. // CONCATENATED MODULE: ./src/core/channels/private_channel.ts
  40205. var private_channel_extends = (undefined && undefined.__extends) || (function () {
  40206. var extendStatics = function (d, b) {
  40207. extendStatics = Object.setPrototypeOf ||
  40208. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40209. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40210. return extendStatics(d, b);
  40211. };
  40212. return function (d, b) {
  40213. extendStatics(d, b);
  40214. function __() { this.constructor = d; }
  40215. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40216. };
  40217. })();
  40218. var private_channel_PrivateChannel = (function (_super) {
  40219. private_channel_extends(PrivateChannel, _super);
  40220. function PrivateChannel() {
  40221. return _super !== null && _super.apply(this, arguments) || this;
  40222. }
  40223. PrivateChannel.prototype.authorize = function (socketId, callback) {
  40224. var authorizer = factory.createAuthorizer(this, this.pusher.config);
  40225. return authorizer.authorize(socketId, callback);
  40226. };
  40227. return PrivateChannel;
  40228. }(channels_channel));
  40229. /* harmony default export */ var private_channel = (private_channel_PrivateChannel);
  40230. // CONCATENATED MODULE: ./src/core/channels/members.ts
  40231. var members_Members = (function () {
  40232. function Members() {
  40233. this.reset();
  40234. }
  40235. Members.prototype.get = function (id) {
  40236. if (Object.prototype.hasOwnProperty.call(this.members, id)) {
  40237. return {
  40238. id: id,
  40239. info: this.members[id]
  40240. };
  40241. }
  40242. else {
  40243. return null;
  40244. }
  40245. };
  40246. Members.prototype.each = function (callback) {
  40247. var _this = this;
  40248. objectApply(this.members, function (member, id) {
  40249. callback(_this.get(id));
  40250. });
  40251. };
  40252. Members.prototype.setMyID = function (id) {
  40253. this.myID = id;
  40254. };
  40255. Members.prototype.onSubscription = function (subscriptionData) {
  40256. this.members = subscriptionData.presence.hash;
  40257. this.count = subscriptionData.presence.count;
  40258. this.me = this.get(this.myID);
  40259. };
  40260. Members.prototype.addMember = function (memberData) {
  40261. if (this.get(memberData.user_id) === null) {
  40262. this.count++;
  40263. }
  40264. this.members[memberData.user_id] = memberData.user_info;
  40265. return this.get(memberData.user_id);
  40266. };
  40267. Members.prototype.removeMember = function (memberData) {
  40268. var member = this.get(memberData.user_id);
  40269. if (member) {
  40270. delete this.members[memberData.user_id];
  40271. this.count--;
  40272. }
  40273. return member;
  40274. };
  40275. Members.prototype.reset = function () {
  40276. this.members = {};
  40277. this.count = 0;
  40278. this.myID = null;
  40279. this.me = null;
  40280. };
  40281. return Members;
  40282. }());
  40283. /* harmony default export */ var members = (members_Members);
  40284. // CONCATENATED MODULE: ./src/core/channels/presence_channel.ts
  40285. var presence_channel_extends = (undefined && undefined.__extends) || (function () {
  40286. var extendStatics = function (d, b) {
  40287. extendStatics = Object.setPrototypeOf ||
  40288. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40289. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40290. return extendStatics(d, b);
  40291. };
  40292. return function (d, b) {
  40293. extendStatics(d, b);
  40294. function __() { this.constructor = d; }
  40295. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40296. };
  40297. })();
  40298. var presence_channel_PresenceChannel = (function (_super) {
  40299. presence_channel_extends(PresenceChannel, _super);
  40300. function PresenceChannel(name, pusher) {
  40301. var _this = _super.call(this, name, pusher) || this;
  40302. _this.members = new members();
  40303. return _this;
  40304. }
  40305. PresenceChannel.prototype.authorize = function (socketId, callback) {
  40306. var _this = this;
  40307. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  40308. if (!error) {
  40309. if (authData.channel_data === undefined) {
  40310. var suffix = url_store.buildLogSuffix("authenticationEndpoint");
  40311. logger.error("Invalid auth response for channel '" + _this.name + "'," +
  40312. ("expected 'channel_data' field. " + suffix));
  40313. callback("Invalid auth response");
  40314. return;
  40315. }
  40316. var channelData = JSON.parse(authData.channel_data);
  40317. _this.members.setMyID(channelData.user_id);
  40318. }
  40319. callback(error, authData);
  40320. });
  40321. };
  40322. PresenceChannel.prototype.handleEvent = function (event) {
  40323. var eventName = event.event;
  40324. if (eventName.indexOf("pusher_internal:") === 0) {
  40325. this.handleInternalEvent(event);
  40326. }
  40327. else {
  40328. var data = event.data;
  40329. var metadata = {};
  40330. if (event.user_id) {
  40331. metadata.user_id = event.user_id;
  40332. }
  40333. this.emit(eventName, data, metadata);
  40334. }
  40335. };
  40336. PresenceChannel.prototype.handleInternalEvent = function (event) {
  40337. var eventName = event.event;
  40338. var data = event.data;
  40339. switch (eventName) {
  40340. case "pusher_internal:subscription_succeeded":
  40341. this.handleSubscriptionSucceededEvent(event);
  40342. break;
  40343. case "pusher_internal:member_added":
  40344. var addedMember = this.members.addMember(data);
  40345. this.emit('pusher:member_added', addedMember);
  40346. break;
  40347. case "pusher_internal:member_removed":
  40348. var removedMember = this.members.removeMember(data);
  40349. if (removedMember) {
  40350. this.emit('pusher:member_removed', removedMember);
  40351. }
  40352. break;
  40353. }
  40354. };
  40355. PresenceChannel.prototype.handleSubscriptionSucceededEvent = function (event) {
  40356. this.subscriptionPending = false;
  40357. this.subscribed = true;
  40358. if (this.subscriptionCancelled) {
  40359. this.pusher.unsubscribe(this.name);
  40360. }
  40361. else {
  40362. this.members.onSubscription(event.data);
  40363. this.emit("pusher:subscription_succeeded", this.members);
  40364. }
  40365. };
  40366. PresenceChannel.prototype.disconnect = function () {
  40367. this.members.reset();
  40368. _super.prototype.disconnect.call(this);
  40369. };
  40370. return PresenceChannel;
  40371. }(private_channel));
  40372. /* harmony default export */ var presence_channel = (presence_channel_PresenceChannel);
  40373. // EXTERNAL MODULE: ./node_modules/tweetnacl/nacl-fast.js
  40374. var nacl_fast = __webpack_require__(0);
  40375. // EXTERNAL MODULE: ./node_modules/tweetnacl-util/nacl-util.js
  40376. var nacl_util = __webpack_require__(1);
  40377. // CONCATENATED MODULE: ./src/core/channels/encrypted_channel.ts
  40378. var encrypted_channel_extends = (undefined && undefined.__extends) || (function () {
  40379. var extendStatics = function (d, b) {
  40380. extendStatics = Object.setPrototypeOf ||
  40381. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40382. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40383. return extendStatics(d, b);
  40384. };
  40385. return function (d, b) {
  40386. extendStatics(d, b);
  40387. function __() { this.constructor = d; }
  40388. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40389. };
  40390. })();
  40391. var encrypted_channel_EncryptedChannel = (function (_super) {
  40392. encrypted_channel_extends(EncryptedChannel, _super);
  40393. function EncryptedChannel() {
  40394. var _this = _super !== null && _super.apply(this, arguments) || this;
  40395. _this.key = null;
  40396. return _this;
  40397. }
  40398. EncryptedChannel.prototype.authorize = function (socketId, callback) {
  40399. var _this = this;
  40400. _super.prototype.authorize.call(this, socketId, function (error, authData) {
  40401. if (error) {
  40402. callback(true, authData);
  40403. return;
  40404. }
  40405. var sharedSecret = authData["shared_secret"];
  40406. if (!sharedSecret) {
  40407. var errorMsg = "No shared_secret key in auth payload for encrypted channel: " + _this.name;
  40408. callback(true, errorMsg);
  40409. return;
  40410. }
  40411. _this.key = Object(nacl_util["decodeBase64"])(sharedSecret);
  40412. delete authData["shared_secret"];
  40413. callback(false, authData);
  40414. });
  40415. };
  40416. EncryptedChannel.prototype.trigger = function (event, data) {
  40417. throw new UnsupportedFeature('Client events are not currently supported for encrypted channels');
  40418. };
  40419. EncryptedChannel.prototype.handleEvent = function (event) {
  40420. var eventName = event.event;
  40421. var data = event.data;
  40422. if (eventName.indexOf("pusher_internal:") === 0 || eventName.indexOf("pusher:") === 0) {
  40423. _super.prototype.handleEvent.call(this, event);
  40424. return;
  40425. }
  40426. this.handleEncryptedEvent(eventName, data);
  40427. };
  40428. EncryptedChannel.prototype.handleEncryptedEvent = function (event, data) {
  40429. var _this = this;
  40430. if (!this.key) {
  40431. logger.debug('Received encrypted event before key has been retrieved from the authEndpoint');
  40432. return;
  40433. }
  40434. if (!data.ciphertext || !data.nonce) {
  40435. logger.error('Unexpected format for encrypted event, expected object with `ciphertext` and `nonce` fields, got: ' + data);
  40436. return;
  40437. }
  40438. var cipherText = Object(nacl_util["decodeBase64"])(data.ciphertext);
  40439. if (cipherText.length < nacl_fast["secretbox"].overheadLength) {
  40440. logger.error("Expected encrypted event ciphertext length to be " + nacl_fast["secretbox"].overheadLength + ", got: " + cipherText.length);
  40441. return;
  40442. }
  40443. var nonce = Object(nacl_util["decodeBase64"])(data.nonce);
  40444. if (nonce.length < nacl_fast["secretbox"].nonceLength) {
  40445. logger.error("Expected encrypted event nonce length to be " + nacl_fast["secretbox"].nonceLength + ", got: " + nonce.length);
  40446. return;
  40447. }
  40448. var bytes = nacl_fast["secretbox"].open(cipherText, nonce, this.key);
  40449. if (bytes === null) {
  40450. logger.debug('Failed to decrypt an event, probably because it was encrypted with a different key. Fetching a new key from the authEndpoint...');
  40451. this.authorize(this.pusher.connection.socket_id, function (error, authData) {
  40452. if (error) {
  40453. logger.error("Failed to make a request to the authEndpoint: " + authData + ". Unable to fetch new key, so dropping encrypted event");
  40454. return;
  40455. }
  40456. bytes = nacl_fast["secretbox"].open(cipherText, nonce, _this.key);
  40457. if (bytes === null) {
  40458. logger.error("Failed to decrypt event with new key. Dropping encrypted event");
  40459. return;
  40460. }
  40461. _this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  40462. return;
  40463. });
  40464. return;
  40465. }
  40466. this.emitJSON(event, Object(nacl_util["encodeUTF8"])(bytes));
  40467. };
  40468. EncryptedChannel.prototype.emitJSON = function (eventName, data) {
  40469. try {
  40470. this.emit(eventName, JSON.parse(data));
  40471. }
  40472. catch (e) {
  40473. this.emit(eventName, data);
  40474. }
  40475. return this;
  40476. };
  40477. return EncryptedChannel;
  40478. }(private_channel));
  40479. /* harmony default export */ var encrypted_channel = (encrypted_channel_EncryptedChannel);
  40480. // CONCATENATED MODULE: ./src/core/connection/connection_manager.ts
  40481. var connection_manager_extends = (undefined && undefined.__extends) || (function () {
  40482. var extendStatics = function (d, b) {
  40483. extendStatics = Object.setPrototypeOf ||
  40484. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  40485. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40486. return extendStatics(d, b);
  40487. };
  40488. return function (d, b) {
  40489. extendStatics(d, b);
  40490. function __() { this.constructor = d; }
  40491. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40492. };
  40493. })();
  40494. var connection_manager_ConnectionManager = (function (_super) {
  40495. connection_manager_extends(ConnectionManager, _super);
  40496. function ConnectionManager(key, options) {
  40497. var _this = _super.call(this) || this;
  40498. _this.key = key;
  40499. _this.options = options || {};
  40500. _this.state = "initialized";
  40501. _this.connection = null;
  40502. _this.usingTLS = !!options.useTLS;
  40503. _this.timeline = _this.options.timeline;
  40504. _this.errorCallbacks = _this.buildErrorCallbacks();
  40505. _this.connectionCallbacks = _this.buildConnectionCallbacks(_this.errorCallbacks);
  40506. _this.handshakeCallbacks = _this.buildHandshakeCallbacks(_this.errorCallbacks);
  40507. var Network = runtime.getNetwork();
  40508. Network.bind("online", function () {
  40509. _this.timeline.info({ netinfo: "online" });
  40510. if (_this.state === "connecting" || _this.state === "unavailable") {
  40511. _this.retryIn(0);
  40512. }
  40513. });
  40514. Network.bind("offline", function () {
  40515. _this.timeline.info({ netinfo: "offline" });
  40516. if (_this.connection) {
  40517. _this.sendActivityCheck();
  40518. }
  40519. });
  40520. _this.updateStrategy();
  40521. return _this;
  40522. }
  40523. ConnectionManager.prototype.connect = function () {
  40524. if (this.connection || this.runner) {
  40525. return;
  40526. }
  40527. if (!this.strategy.isSupported()) {
  40528. this.updateState("failed");
  40529. return;
  40530. }
  40531. this.updateState("connecting");
  40532. this.startConnecting();
  40533. this.setUnavailableTimer();
  40534. };
  40535. ;
  40536. ConnectionManager.prototype.send = function (data) {
  40537. if (this.connection) {
  40538. return this.connection.send(data);
  40539. }
  40540. else {
  40541. return false;
  40542. }
  40543. };
  40544. ;
  40545. ConnectionManager.prototype.send_event = function (name, data, channel) {
  40546. if (this.connection) {
  40547. return this.connection.send_event(name, data, channel);
  40548. }
  40549. else {
  40550. return false;
  40551. }
  40552. };
  40553. ;
  40554. ConnectionManager.prototype.disconnect = function () {
  40555. this.disconnectInternally();
  40556. this.updateState("disconnected");
  40557. };
  40558. ;
  40559. ConnectionManager.prototype.isUsingTLS = function () {
  40560. return this.usingTLS;
  40561. };
  40562. ;
  40563. ConnectionManager.prototype.startConnecting = function () {
  40564. var _this = this;
  40565. var callback = function (error, handshake) {
  40566. if (error) {
  40567. _this.runner = _this.strategy.connect(0, callback);
  40568. }
  40569. else {
  40570. if (handshake.action === "error") {
  40571. _this.emit("error", { type: "HandshakeError", error: handshake.error });
  40572. _this.timeline.error({ handshakeError: handshake.error });
  40573. }
  40574. else {
  40575. _this.abortConnecting();
  40576. _this.handshakeCallbacks[handshake.action](handshake);
  40577. }
  40578. }
  40579. };
  40580. this.runner = this.strategy.connect(0, callback);
  40581. };
  40582. ;
  40583. ConnectionManager.prototype.abortConnecting = function () {
  40584. if (this.runner) {
  40585. this.runner.abort();
  40586. this.runner = null;
  40587. }
  40588. };
  40589. ;
  40590. ConnectionManager.prototype.disconnectInternally = function () {
  40591. this.abortConnecting();
  40592. this.clearRetryTimer();
  40593. this.clearUnavailableTimer();
  40594. if (this.connection) {
  40595. var connection = this.abandonConnection();
  40596. connection.close();
  40597. }
  40598. };
  40599. ;
  40600. ConnectionManager.prototype.updateStrategy = function () {
  40601. this.strategy = this.options.getStrategy({
  40602. key: this.key,
  40603. timeline: this.timeline,
  40604. useTLS: this.usingTLS
  40605. });
  40606. };
  40607. ;
  40608. ConnectionManager.prototype.retryIn = function (delay) {
  40609. var _this = this;
  40610. this.timeline.info({ action: "retry", delay: delay });
  40611. if (delay > 0) {
  40612. this.emit("connecting_in", Math.round(delay / 1000));
  40613. }
  40614. this.retryTimer = new OneOffTimer(delay || 0, function () {
  40615. _this.disconnectInternally();
  40616. _this.connect();
  40617. });
  40618. };
  40619. ;
  40620. ConnectionManager.prototype.clearRetryTimer = function () {
  40621. if (this.retryTimer) {
  40622. this.retryTimer.ensureAborted();
  40623. this.retryTimer = null;
  40624. }
  40625. };
  40626. ;
  40627. ConnectionManager.prototype.setUnavailableTimer = function () {
  40628. var _this = this;
  40629. this.unavailableTimer = new OneOffTimer(this.options.unavailableTimeout, function () {
  40630. _this.updateState("unavailable");
  40631. });
  40632. };
  40633. ;
  40634. ConnectionManager.prototype.clearUnavailableTimer = function () {
  40635. if (this.unavailableTimer) {
  40636. this.unavailableTimer.ensureAborted();
  40637. }
  40638. };
  40639. ;
  40640. ConnectionManager.prototype.sendActivityCheck = function () {
  40641. var _this = this;
  40642. this.stopActivityCheck();
  40643. this.connection.ping();
  40644. this.activityTimer = new OneOffTimer(this.options.pongTimeout, function () {
  40645. _this.timeline.error({ pong_timed_out: _this.options.pongTimeout });
  40646. _this.retryIn(0);
  40647. });
  40648. };
  40649. ;
  40650. ConnectionManager.prototype.resetActivityCheck = function () {
  40651. var _this = this;
  40652. this.stopActivityCheck();
  40653. if (this.connection && !this.connection.handlesActivityChecks()) {
  40654. this.activityTimer = new OneOffTimer(this.activityTimeout, function () {
  40655. _this.sendActivityCheck();
  40656. });
  40657. }
  40658. };
  40659. ;
  40660. ConnectionManager.prototype.stopActivityCheck = function () {
  40661. if (this.activityTimer) {
  40662. this.activityTimer.ensureAborted();
  40663. }
  40664. };
  40665. ;
  40666. ConnectionManager.prototype.buildConnectionCallbacks = function (errorCallbacks) {
  40667. var _this = this;
  40668. return extend({}, errorCallbacks, {
  40669. message: function (message) {
  40670. _this.resetActivityCheck();
  40671. _this.emit('message', message);
  40672. },
  40673. ping: function () {
  40674. _this.send_event('pusher:pong', {});
  40675. },
  40676. activity: function () {
  40677. _this.resetActivityCheck();
  40678. },
  40679. error: function (error) {
  40680. _this.emit("error", { type: "WebSocketError", error: error });
  40681. },
  40682. closed: function () {
  40683. _this.abandonConnection();
  40684. if (_this.shouldRetry()) {
  40685. _this.retryIn(1000);
  40686. }
  40687. }
  40688. });
  40689. };
  40690. ;
  40691. ConnectionManager.prototype.buildHandshakeCallbacks = function (errorCallbacks) {
  40692. var _this = this;
  40693. return extend({}, errorCallbacks, {
  40694. connected: function (handshake) {
  40695. _this.activityTimeout = Math.min(_this.options.activityTimeout, handshake.activityTimeout, handshake.connection.activityTimeout || Infinity);
  40696. _this.clearUnavailableTimer();
  40697. _this.setConnection(handshake.connection);
  40698. _this.socket_id = _this.connection.id;
  40699. _this.updateState("connected", { socket_id: _this.socket_id });
  40700. }
  40701. });
  40702. };
  40703. ;
  40704. ConnectionManager.prototype.buildErrorCallbacks = function () {
  40705. var _this = this;
  40706. var withErrorEmitted = function (callback) {
  40707. return function (result) {
  40708. if (result.error) {
  40709. _this.emit("error", { type: "WebSocketError", error: result.error });
  40710. }
  40711. callback(result);
  40712. };
  40713. };
  40714. return {
  40715. tls_only: withErrorEmitted(function () {
  40716. _this.usingTLS = true;
  40717. _this.updateStrategy();
  40718. _this.retryIn(0);
  40719. }),
  40720. refused: withErrorEmitted(function () {
  40721. _this.disconnect();
  40722. }),
  40723. backoff: withErrorEmitted(function () {
  40724. _this.retryIn(1000);
  40725. }),
  40726. retry: withErrorEmitted(function () {
  40727. _this.retryIn(0);
  40728. })
  40729. };
  40730. };
  40731. ;
  40732. ConnectionManager.prototype.setConnection = function (connection) {
  40733. this.connection = connection;
  40734. for (var event in this.connectionCallbacks) {
  40735. this.connection.bind(event, this.connectionCallbacks[event]);
  40736. }
  40737. this.resetActivityCheck();
  40738. };
  40739. ;
  40740. ConnectionManager.prototype.abandonConnection = function () {
  40741. if (!this.connection) {
  40742. return;
  40743. }
  40744. this.stopActivityCheck();
  40745. for (var event in this.connectionCallbacks) {
  40746. this.connection.unbind(event, this.connectionCallbacks[event]);
  40747. }
  40748. var connection = this.connection;
  40749. this.connection = null;
  40750. return connection;
  40751. };
  40752. ConnectionManager.prototype.updateState = function (newState, data) {
  40753. var previousState = this.state;
  40754. this.state = newState;
  40755. if (previousState !== newState) {
  40756. var newStateDescription = newState;
  40757. if (newStateDescription === "connected") {
  40758. newStateDescription += " with new socket ID " + data.socket_id;
  40759. }
  40760. logger.debug('State changed', previousState + ' -> ' + newStateDescription);
  40761. this.timeline.info({ state: newState, params: data });
  40762. this.emit('state_change', { previous: previousState, current: newState });
  40763. this.emit(newState, data);
  40764. }
  40765. };
  40766. ConnectionManager.prototype.shouldRetry = function () {
  40767. return this.state === "connecting" || this.state === "connected";
  40768. };
  40769. return ConnectionManager;
  40770. }(dispatcher));
  40771. /* harmony default export */ var connection_manager = (connection_manager_ConnectionManager);
  40772. // CONCATENATED MODULE: ./src/core/channels/channels.ts
  40773. var channels_Channels = (function () {
  40774. function Channels() {
  40775. this.channels = {};
  40776. }
  40777. Channels.prototype.add = function (name, pusher) {
  40778. if (!this.channels[name]) {
  40779. this.channels[name] = createChannel(name, pusher);
  40780. }
  40781. return this.channels[name];
  40782. };
  40783. Channels.prototype.all = function () {
  40784. return values(this.channels);
  40785. };
  40786. Channels.prototype.find = function (name) {
  40787. return this.channels[name];
  40788. };
  40789. Channels.prototype.remove = function (name) {
  40790. var channel = this.channels[name];
  40791. delete this.channels[name];
  40792. return channel;
  40793. };
  40794. Channels.prototype.disconnect = function () {
  40795. objectApply(this.channels, function (channel) {
  40796. channel.disconnect();
  40797. });
  40798. };
  40799. return Channels;
  40800. }());
  40801. /* harmony default export */ var channels = (channels_Channels);
  40802. function createChannel(name, pusher) {
  40803. if (name.indexOf('private-encrypted-') === 0) {
  40804. if (false) { var errorMsg; }
  40805. return factory.createEncryptedChannel(name, pusher);
  40806. }
  40807. else if (name.indexOf('private-') === 0) {
  40808. return factory.createPrivateChannel(name, pusher);
  40809. }
  40810. else if (name.indexOf('presence-') === 0) {
  40811. return factory.createPresenceChannel(name, pusher);
  40812. }
  40813. else {
  40814. return factory.createChannel(name, pusher);
  40815. }
  40816. }
  40817. // CONCATENATED MODULE: ./src/core/utils/factory.ts
  40818. var Factory = {
  40819. createChannels: function () {
  40820. return new channels();
  40821. },
  40822. createConnectionManager: function (key, options) {
  40823. return new connection_manager(key, options);
  40824. },
  40825. createChannel: function (name, pusher) {
  40826. return new channels_channel(name, pusher);
  40827. },
  40828. createPrivateChannel: function (name, pusher) {
  40829. return new private_channel(name, pusher);
  40830. },
  40831. createPresenceChannel: function (name, pusher) {
  40832. return new presence_channel(name, pusher);
  40833. },
  40834. createEncryptedChannel: function (name, pusher) {
  40835. return new encrypted_channel(name, pusher);
  40836. },
  40837. createTimelineSender: function (timeline, options) {
  40838. return new timeline_sender(timeline, options);
  40839. },
  40840. createAuthorizer: function (channel, options) {
  40841. if (options.authorizer) {
  40842. return options.authorizer(channel, options);
  40843. }
  40844. return new pusher_authorizer(channel, options);
  40845. },
  40846. createHandshake: function (transport, callback) {
  40847. return new connection_handshake(transport, callback);
  40848. },
  40849. createAssistantToTheTransportManager: function (manager, transport, options) {
  40850. return new assistant_to_the_transport_manager(manager, transport, options);
  40851. }
  40852. };
  40853. /* harmony default export */ var factory = (Factory);
  40854. // CONCATENATED MODULE: ./src/core/transports/transport_manager.ts
  40855. var transport_manager_TransportManager = (function () {
  40856. function TransportManager(options) {
  40857. this.options = options || {};
  40858. this.livesLeft = this.options.lives || Infinity;
  40859. }
  40860. TransportManager.prototype.getAssistant = function (transport) {
  40861. return factory.createAssistantToTheTransportManager(this, transport, {
  40862. minPingDelay: this.options.minPingDelay,
  40863. maxPingDelay: this.options.maxPingDelay
  40864. });
  40865. };
  40866. TransportManager.prototype.isAlive = function () {
  40867. return this.livesLeft > 0;
  40868. };
  40869. TransportManager.prototype.reportDeath = function () {
  40870. this.livesLeft -= 1;
  40871. };
  40872. return TransportManager;
  40873. }());
  40874. /* harmony default export */ var transport_manager = (transport_manager_TransportManager);
  40875. // CONCATENATED MODULE: ./src/core/strategies/sequential_strategy.ts
  40876. var sequential_strategy_SequentialStrategy = (function () {
  40877. function SequentialStrategy(strategies, options) {
  40878. this.strategies = strategies;
  40879. this.loop = Boolean(options.loop);
  40880. this.failFast = Boolean(options.failFast);
  40881. this.timeout = options.timeout;
  40882. this.timeoutLimit = options.timeoutLimit;
  40883. }
  40884. SequentialStrategy.prototype.isSupported = function () {
  40885. return any(this.strategies, util.method("isSupported"));
  40886. };
  40887. SequentialStrategy.prototype.connect = function (minPriority, callback) {
  40888. var _this = this;
  40889. var strategies = this.strategies;
  40890. var current = 0;
  40891. var timeout = this.timeout;
  40892. var runner = null;
  40893. var tryNextStrategy = function (error, handshake) {
  40894. if (handshake) {
  40895. callback(null, handshake);
  40896. }
  40897. else {
  40898. current = current + 1;
  40899. if (_this.loop) {
  40900. current = current % strategies.length;
  40901. }
  40902. if (current < strategies.length) {
  40903. if (timeout) {
  40904. timeout = timeout * 2;
  40905. if (_this.timeoutLimit) {
  40906. timeout = Math.min(timeout, _this.timeoutLimit);
  40907. }
  40908. }
  40909. runner = _this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: _this.failFast }, tryNextStrategy);
  40910. }
  40911. else {
  40912. callback(true);
  40913. }
  40914. }
  40915. };
  40916. runner = this.tryStrategy(strategies[current], minPriority, { timeout: timeout, failFast: this.failFast }, tryNextStrategy);
  40917. return {
  40918. abort: function () {
  40919. runner.abort();
  40920. },
  40921. forceMinPriority: function (p) {
  40922. minPriority = p;
  40923. if (runner) {
  40924. runner.forceMinPriority(p);
  40925. }
  40926. }
  40927. };
  40928. };
  40929. SequentialStrategy.prototype.tryStrategy = function (strategy, minPriority, options, callback) {
  40930. var timer = null;
  40931. var runner = null;
  40932. if (options.timeout > 0) {
  40933. timer = new OneOffTimer(options.timeout, function () {
  40934. runner.abort();
  40935. callback(true);
  40936. });
  40937. }
  40938. runner = strategy.connect(minPriority, function (error, handshake) {
  40939. if (error && timer && timer.isRunning() && !options.failFast) {
  40940. return;
  40941. }
  40942. if (timer) {
  40943. timer.ensureAborted();
  40944. }
  40945. callback(error, handshake);
  40946. });
  40947. return {
  40948. abort: function () {
  40949. if (timer) {
  40950. timer.ensureAborted();
  40951. }
  40952. runner.abort();
  40953. },
  40954. forceMinPriority: function (p) {
  40955. runner.forceMinPriority(p);
  40956. }
  40957. };
  40958. };
  40959. return SequentialStrategy;
  40960. }());
  40961. /* harmony default export */ var sequential_strategy = (sequential_strategy_SequentialStrategy);
  40962. // CONCATENATED MODULE: ./src/core/strategies/best_connected_ever_strategy.ts
  40963. var best_connected_ever_strategy_BestConnectedEverStrategy = (function () {
  40964. function BestConnectedEverStrategy(strategies) {
  40965. this.strategies = strategies;
  40966. }
  40967. BestConnectedEverStrategy.prototype.isSupported = function () {
  40968. return any(this.strategies, util.method("isSupported"));
  40969. };
  40970. BestConnectedEverStrategy.prototype.connect = function (minPriority, callback) {
  40971. return connect(this.strategies, minPriority, function (i, runners) {
  40972. return function (error, handshake) {
  40973. runners[i].error = error;
  40974. if (error) {
  40975. if (allRunnersFailed(runners)) {
  40976. callback(true);
  40977. }
  40978. return;
  40979. }
  40980. apply(runners, function (runner) {
  40981. runner.forceMinPriority(handshake.transport.priority);
  40982. });
  40983. callback(null, handshake);
  40984. };
  40985. });
  40986. };
  40987. return BestConnectedEverStrategy;
  40988. }());
  40989. /* harmony default export */ var best_connected_ever_strategy = (best_connected_ever_strategy_BestConnectedEverStrategy);
  40990. function connect(strategies, minPriority, callbackBuilder) {
  40991. var runners = map(strategies, function (strategy, i, _, rs) {
  40992. return strategy.connect(minPriority, callbackBuilder(i, rs));
  40993. });
  40994. return {
  40995. abort: function () {
  40996. apply(runners, abortRunner);
  40997. },
  40998. forceMinPriority: function (p) {
  40999. apply(runners, function (runner) {
  41000. runner.forceMinPriority(p);
  41001. });
  41002. }
  41003. };
  41004. }
  41005. function allRunnersFailed(runners) {
  41006. return collections_all(runners, function (runner) {
  41007. return Boolean(runner.error);
  41008. });
  41009. }
  41010. function abortRunner(runner) {
  41011. if (!runner.error && !runner.aborted) {
  41012. runner.abort();
  41013. runner.aborted = true;
  41014. }
  41015. }
  41016. // CONCATENATED MODULE: ./src/core/strategies/cached_strategy.ts
  41017. var cached_strategy_CachedStrategy = (function () {
  41018. function CachedStrategy(strategy, transports, options) {
  41019. this.strategy = strategy;
  41020. this.transports = transports;
  41021. this.ttl = options.ttl || 1800 * 1000;
  41022. this.usingTLS = options.useTLS;
  41023. this.timeline = options.timeline;
  41024. }
  41025. CachedStrategy.prototype.isSupported = function () {
  41026. return this.strategy.isSupported();
  41027. };
  41028. CachedStrategy.prototype.connect = function (minPriority, callback) {
  41029. var usingTLS = this.usingTLS;
  41030. var info = fetchTransportCache(usingTLS);
  41031. var strategies = [this.strategy];
  41032. if (info && info.timestamp + this.ttl >= util.now()) {
  41033. var transport = this.transports[info.transport];
  41034. if (transport) {
  41035. this.timeline.info({
  41036. cached: true,
  41037. transport: info.transport,
  41038. latency: info.latency
  41039. });
  41040. strategies.push(new sequential_strategy([transport], {
  41041. timeout: info.latency * 2 + 1000,
  41042. failFast: true
  41043. }));
  41044. }
  41045. }
  41046. var startTimestamp = util.now();
  41047. var runner = strategies.pop().connect(minPriority, function cb(error, handshake) {
  41048. if (error) {
  41049. flushTransportCache(usingTLS);
  41050. if (strategies.length > 0) {
  41051. startTimestamp = util.now();
  41052. runner = strategies.pop().connect(minPriority, cb);
  41053. }
  41054. else {
  41055. callback(error);
  41056. }
  41057. }
  41058. else {
  41059. storeTransportCache(usingTLS, handshake.transport.name, util.now() - startTimestamp);
  41060. callback(null, handshake);
  41061. }
  41062. });
  41063. return {
  41064. abort: function () {
  41065. runner.abort();
  41066. },
  41067. forceMinPriority: function (p) {
  41068. minPriority = p;
  41069. if (runner) {
  41070. runner.forceMinPriority(p);
  41071. }
  41072. }
  41073. };
  41074. };
  41075. return CachedStrategy;
  41076. }());
  41077. /* harmony default export */ var cached_strategy = (cached_strategy_CachedStrategy);
  41078. function getTransportCacheKey(usingTLS) {
  41079. return "pusherTransport" + (usingTLS ? "TLS" : "NonTLS");
  41080. }
  41081. function fetchTransportCache(usingTLS) {
  41082. var storage = runtime.getLocalStorage();
  41083. if (storage) {
  41084. try {
  41085. var serializedCache = storage[getTransportCacheKey(usingTLS)];
  41086. if (serializedCache) {
  41087. return JSON.parse(serializedCache);
  41088. }
  41089. }
  41090. catch (e) {
  41091. flushTransportCache(usingTLS);
  41092. }
  41093. }
  41094. return null;
  41095. }
  41096. function storeTransportCache(usingTLS, transport, latency) {
  41097. var storage = runtime.getLocalStorage();
  41098. if (storage) {
  41099. try {
  41100. storage[getTransportCacheKey(usingTLS)] = safeJSONStringify({
  41101. timestamp: util.now(),
  41102. transport: transport,
  41103. latency: latency
  41104. });
  41105. }
  41106. catch (e) {
  41107. }
  41108. }
  41109. }
  41110. function flushTransportCache(usingTLS) {
  41111. var storage = runtime.getLocalStorage();
  41112. if (storage) {
  41113. try {
  41114. delete storage[getTransportCacheKey(usingTLS)];
  41115. }
  41116. catch (e) {
  41117. }
  41118. }
  41119. }
  41120. // CONCATENATED MODULE: ./src/core/strategies/delayed_strategy.ts
  41121. var delayed_strategy_DelayedStrategy = (function () {
  41122. function DelayedStrategy(strategy, _a) {
  41123. var number = _a.delay;
  41124. this.strategy = strategy;
  41125. this.options = { delay: number };
  41126. }
  41127. DelayedStrategy.prototype.isSupported = function () {
  41128. return this.strategy.isSupported();
  41129. };
  41130. DelayedStrategy.prototype.connect = function (minPriority, callback) {
  41131. var strategy = this.strategy;
  41132. var runner;
  41133. var timer = new OneOffTimer(this.options.delay, function () {
  41134. runner = strategy.connect(minPriority, callback);
  41135. });
  41136. return {
  41137. abort: function () {
  41138. timer.ensureAborted();
  41139. if (runner) {
  41140. runner.abort();
  41141. }
  41142. },
  41143. forceMinPriority: function (p) {
  41144. minPriority = p;
  41145. if (runner) {
  41146. runner.forceMinPriority(p);
  41147. }
  41148. }
  41149. };
  41150. };
  41151. return DelayedStrategy;
  41152. }());
  41153. /* harmony default export */ var delayed_strategy = (delayed_strategy_DelayedStrategy);
  41154. // CONCATENATED MODULE: ./src/core/strategies/if_strategy.ts
  41155. var IfStrategy = (function () {
  41156. function IfStrategy(test, trueBranch, falseBranch) {
  41157. this.test = test;
  41158. this.trueBranch = trueBranch;
  41159. this.falseBranch = falseBranch;
  41160. }
  41161. IfStrategy.prototype.isSupported = function () {
  41162. var branch = this.test() ? this.trueBranch : this.falseBranch;
  41163. return branch.isSupported();
  41164. };
  41165. IfStrategy.prototype.connect = function (minPriority, callback) {
  41166. var branch = this.test() ? this.trueBranch : this.falseBranch;
  41167. return branch.connect(minPriority, callback);
  41168. };
  41169. return IfStrategy;
  41170. }());
  41171. /* harmony default export */ var if_strategy = (IfStrategy);
  41172. // CONCATENATED MODULE: ./src/core/strategies/first_connected_strategy.ts
  41173. var FirstConnectedStrategy = (function () {
  41174. function FirstConnectedStrategy(strategy) {
  41175. this.strategy = strategy;
  41176. }
  41177. FirstConnectedStrategy.prototype.isSupported = function () {
  41178. return this.strategy.isSupported();
  41179. };
  41180. FirstConnectedStrategy.prototype.connect = function (minPriority, callback) {
  41181. var runner = this.strategy.connect(minPriority, function (error, handshake) {
  41182. if (handshake) {
  41183. runner.abort();
  41184. }
  41185. callback(error, handshake);
  41186. });
  41187. return runner;
  41188. };
  41189. return FirstConnectedStrategy;
  41190. }());
  41191. /* harmony default export */ var first_connected_strategy = (FirstConnectedStrategy);
  41192. // CONCATENATED MODULE: ./src/runtimes/web/default_strategy.ts
  41193. function testSupportsStrategy(strategy) {
  41194. return function () {
  41195. return strategy.isSupported();
  41196. };
  41197. }
  41198. var getDefaultStrategy = function (config, defineTransport) {
  41199. var definedTransports = {};
  41200. function defineTransportStrategy(name, type, priority, options, manager) {
  41201. var transport = defineTransport(config, name, type, priority, options, manager);
  41202. definedTransports[name] = transport;
  41203. return transport;
  41204. }
  41205. var ws_options = {
  41206. hostNonTLS: config.wsHost + ":" + config.wsPort,
  41207. hostTLS: config.wsHost + ":" + config.wssPort,
  41208. httpPath: config.wsPath
  41209. };
  41210. var wss_options = extend({}, ws_options, {
  41211. useTLS: true
  41212. });
  41213. var sockjs_options = {
  41214. hostNonTLS: config.httpHost + ":" + config.httpPort,
  41215. hostTLS: config.httpHost + ":" + config.httpsPort,
  41216. httpPath: config.httpPath
  41217. };
  41218. var timeouts = {
  41219. loop: true,
  41220. timeout: 15000,
  41221. timeoutLimit: 60000
  41222. };
  41223. var ws_manager = new transport_manager({
  41224. lives: 2,
  41225. minPingDelay: 10000,
  41226. maxPingDelay: config.activity_timeout
  41227. });
  41228. var streaming_manager = new transport_manager({
  41229. lives: 2,
  41230. minPingDelay: 10000,
  41231. maxPingDelay: config.activity_timeout
  41232. });
  41233. var ws_transport = defineTransportStrategy("ws", "ws", 3, ws_options, ws_manager);
  41234. var wss_transport = defineTransportStrategy("wss", "ws", 3, wss_options, ws_manager);
  41235. var sockjs_transport = defineTransportStrategy("sockjs", "sockjs", 1, sockjs_options);
  41236. var xhr_streaming_transport = defineTransportStrategy("xhr_streaming", "xhr_streaming", 1, sockjs_options, streaming_manager);
  41237. var xdr_streaming_transport = defineTransportStrategy("xdr_streaming", "xdr_streaming", 1, sockjs_options, streaming_manager);
  41238. var xhr_polling_transport = defineTransportStrategy("xhr_polling", "xhr_polling", 1, sockjs_options);
  41239. var xdr_polling_transport = defineTransportStrategy("xdr_polling", "xdr_polling", 1, sockjs_options);
  41240. var ws_loop = new sequential_strategy([ws_transport], timeouts);
  41241. var wss_loop = new sequential_strategy([wss_transport], timeouts);
  41242. var sockjs_loop = new sequential_strategy([sockjs_transport], timeouts);
  41243. var streaming_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_streaming_transport), xhr_streaming_transport, xdr_streaming_transport)], timeouts);
  41244. var polling_loop = new sequential_strategy([new if_strategy(testSupportsStrategy(xhr_polling_transport), xhr_polling_transport, xdr_polling_transport)], timeouts);
  41245. 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);
  41246. var http_fallback_loop = new if_strategy(testSupportsStrategy(http_loop), http_loop, sockjs_loop);
  41247. var wsStrategy;
  41248. if (config.useTLS) {
  41249. wsStrategy = new best_connected_ever_strategy([ws_loop, new delayed_strategy(http_fallback_loop, { delay: 2000 })]);
  41250. }
  41251. else {
  41252. wsStrategy = new best_connected_ever_strategy([
  41253. ws_loop,
  41254. new delayed_strategy(wss_loop, { delay: 2000 }),
  41255. new delayed_strategy(http_fallback_loop, { delay: 5000 })
  41256. ]);
  41257. }
  41258. return new cached_strategy(new first_connected_strategy(new if_strategy(testSupportsStrategy(ws_transport), wsStrategy, http_fallback_loop)), definedTransports, {
  41259. ttl: 1800000,
  41260. timeline: config.timeline,
  41261. useTLS: config.useTLS
  41262. });
  41263. };
  41264. /* harmony default export */ var default_strategy = (getDefaultStrategy);
  41265. // CONCATENATED MODULE: ./src/runtimes/web/transports/transport_connection_initializer.ts
  41266. /* harmony default export */ var transport_connection_initializer = (function () {
  41267. var self = this;
  41268. self.timeline.info(self.buildTimelineMessage({
  41269. transport: self.name + (self.options.useTLS ? "s" : "")
  41270. }));
  41271. if (self.hooks.isInitialized()) {
  41272. self.changeState("initialized");
  41273. }
  41274. else if (self.hooks.file) {
  41275. self.changeState("initializing");
  41276. Dependencies.load(self.hooks.file, { useTLS: self.options.useTLS }, function (error, callback) {
  41277. if (self.hooks.isInitialized()) {
  41278. self.changeState("initialized");
  41279. callback(true);
  41280. }
  41281. else {
  41282. if (error) {
  41283. self.onError(error);
  41284. }
  41285. self.onClose();
  41286. callback(false);
  41287. }
  41288. });
  41289. }
  41290. else {
  41291. self.onClose();
  41292. }
  41293. });
  41294. // CONCATENATED MODULE: ./src/runtimes/web/http/http_xdomain_request.ts
  41295. var http_xdomain_request_hooks = {
  41296. getRequest: function (socket) {
  41297. var xdr = new window.XDomainRequest();
  41298. xdr.ontimeout = function () {
  41299. socket.emit("error", new RequestTimedOut());
  41300. socket.close();
  41301. };
  41302. xdr.onerror = function (e) {
  41303. socket.emit("error", e);
  41304. socket.close();
  41305. };
  41306. xdr.onprogress = function () {
  41307. if (xdr.responseText && xdr.responseText.length > 0) {
  41308. socket.onChunk(200, xdr.responseText);
  41309. }
  41310. };
  41311. xdr.onload = function () {
  41312. if (xdr.responseText && xdr.responseText.length > 0) {
  41313. socket.onChunk(200, xdr.responseText);
  41314. }
  41315. socket.emit("finished", 200);
  41316. socket.close();
  41317. };
  41318. return xdr;
  41319. },
  41320. abortRequest: function (xdr) {
  41321. xdr.ontimeout = xdr.onerror = xdr.onprogress = xdr.onload = null;
  41322. xdr.abort();
  41323. }
  41324. };
  41325. /* harmony default export */ var http_xdomain_request = (http_xdomain_request_hooks);
  41326. // CONCATENATED MODULE: ./src/core/http/http_request.ts
  41327. var http_request_extends = (undefined && undefined.__extends) || (function () {
  41328. var extendStatics = function (d, b) {
  41329. extendStatics = Object.setPrototypeOf ||
  41330. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  41331. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41332. return extendStatics(d, b);
  41333. };
  41334. return function (d, b) {
  41335. extendStatics(d, b);
  41336. function __() { this.constructor = d; }
  41337. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41338. };
  41339. })();
  41340. var MAX_BUFFER_LENGTH = 256 * 1024;
  41341. var http_request_HTTPRequest = (function (_super) {
  41342. http_request_extends(HTTPRequest, _super);
  41343. function HTTPRequest(hooks, method, url) {
  41344. var _this = _super.call(this) || this;
  41345. _this.hooks = hooks;
  41346. _this.method = method;
  41347. _this.url = url;
  41348. return _this;
  41349. }
  41350. HTTPRequest.prototype.start = function (payload) {
  41351. var _this = this;
  41352. this.position = 0;
  41353. this.xhr = this.hooks.getRequest(this);
  41354. this.unloader = function () {
  41355. _this.close();
  41356. };
  41357. runtime.addUnloadListener(this.unloader);
  41358. this.xhr.open(this.method, this.url, true);
  41359. if (this.xhr.setRequestHeader) {
  41360. this.xhr.setRequestHeader("Content-Type", "application/json");
  41361. }
  41362. this.xhr.send(payload);
  41363. };
  41364. HTTPRequest.prototype.close = function () {
  41365. if (this.unloader) {
  41366. runtime.removeUnloadListener(this.unloader);
  41367. this.unloader = null;
  41368. }
  41369. if (this.xhr) {
  41370. this.hooks.abortRequest(this.xhr);
  41371. this.xhr = null;
  41372. }
  41373. };
  41374. HTTPRequest.prototype.onChunk = function (status, data) {
  41375. while (true) {
  41376. var chunk = this.advanceBuffer(data);
  41377. if (chunk) {
  41378. this.emit("chunk", { status: status, data: chunk });
  41379. }
  41380. else {
  41381. break;
  41382. }
  41383. }
  41384. if (this.isBufferTooLong(data)) {
  41385. this.emit("buffer_too_long");
  41386. }
  41387. };
  41388. HTTPRequest.prototype.advanceBuffer = function (buffer) {
  41389. var unreadData = buffer.slice(this.position);
  41390. var endOfLinePosition = unreadData.indexOf("\n");
  41391. if (endOfLinePosition !== -1) {
  41392. this.position += endOfLinePosition + 1;
  41393. return unreadData.slice(0, endOfLinePosition);
  41394. }
  41395. else {
  41396. return null;
  41397. }
  41398. };
  41399. HTTPRequest.prototype.isBufferTooLong = function (buffer) {
  41400. return this.position === buffer.length && buffer.length > MAX_BUFFER_LENGTH;
  41401. };
  41402. return HTTPRequest;
  41403. }(dispatcher));
  41404. /* harmony default export */ var http_request = (http_request_HTTPRequest);
  41405. // CONCATENATED MODULE: ./src/core/http/state.ts
  41406. var State;
  41407. (function (State) {
  41408. State[State["CONNECTING"] = 0] = "CONNECTING";
  41409. State[State["OPEN"] = 1] = "OPEN";
  41410. State[State["CLOSED"] = 3] = "CLOSED";
  41411. })(State || (State = {}));
  41412. /* harmony default export */ var state = (State);
  41413. // CONCATENATED MODULE: ./src/core/http/http_socket.ts
  41414. var autoIncrement = 1;
  41415. var http_socket_HTTPSocket = (function () {
  41416. function HTTPSocket(hooks, url) {
  41417. this.hooks = hooks;
  41418. this.session = randomNumber(1000) + "/" + randomString(8);
  41419. this.location = getLocation(url);
  41420. this.readyState = state.CONNECTING;
  41421. this.openStream();
  41422. }
  41423. HTTPSocket.prototype.send = function (payload) {
  41424. return this.sendRaw(JSON.stringify([payload]));
  41425. };
  41426. HTTPSocket.prototype.ping = function () {
  41427. this.hooks.sendHeartbeat(this);
  41428. };
  41429. HTTPSocket.prototype.close = function (code, reason) {
  41430. this.onClose(code, reason, true);
  41431. };
  41432. HTTPSocket.prototype.sendRaw = function (payload) {
  41433. if (this.readyState === state.OPEN) {
  41434. try {
  41435. runtime.createSocketRequest("POST", getUniqueURL(getSendURL(this.location, this.session))).start(payload);
  41436. return true;
  41437. }
  41438. catch (e) {
  41439. return false;
  41440. }
  41441. }
  41442. else {
  41443. return false;
  41444. }
  41445. };
  41446. HTTPSocket.prototype.reconnect = function () {
  41447. this.closeStream();
  41448. this.openStream();
  41449. };
  41450. ;
  41451. HTTPSocket.prototype.onClose = function (code, reason, wasClean) {
  41452. this.closeStream();
  41453. this.readyState = state.CLOSED;
  41454. if (this.onclose) {
  41455. this.onclose({
  41456. code: code,
  41457. reason: reason,
  41458. wasClean: wasClean
  41459. });
  41460. }
  41461. };
  41462. HTTPSocket.prototype.onChunk = function (chunk) {
  41463. if (chunk.status !== 200) {
  41464. return;
  41465. }
  41466. if (this.readyState === state.OPEN) {
  41467. this.onActivity();
  41468. }
  41469. var payload;
  41470. var type = chunk.data.slice(0, 1);
  41471. switch (type) {
  41472. case 'o':
  41473. payload = JSON.parse(chunk.data.slice(1) || '{}');
  41474. this.onOpen(payload);
  41475. break;
  41476. case 'a':
  41477. payload = JSON.parse(chunk.data.slice(1) || '[]');
  41478. for (var i = 0; i < payload.length; i++) {
  41479. this.onEvent(payload[i]);
  41480. }
  41481. break;
  41482. case 'm':
  41483. payload = JSON.parse(chunk.data.slice(1) || 'null');
  41484. this.onEvent(payload);
  41485. break;
  41486. case 'h':
  41487. this.hooks.onHeartbeat(this);
  41488. break;
  41489. case 'c':
  41490. payload = JSON.parse(chunk.data.slice(1) || '[]');
  41491. this.onClose(payload[0], payload[1], true);
  41492. break;
  41493. }
  41494. };
  41495. HTTPSocket.prototype.onOpen = function (options) {
  41496. if (this.readyState === state.CONNECTING) {
  41497. if (options && options.hostname) {
  41498. this.location.base = replaceHost(this.location.base, options.hostname);
  41499. }
  41500. this.readyState = state.OPEN;
  41501. if (this.onopen) {
  41502. this.onopen();
  41503. }
  41504. }
  41505. else {
  41506. this.onClose(1006, "Server lost session", true);
  41507. }
  41508. };
  41509. HTTPSocket.prototype.onEvent = function (event) {
  41510. if (this.readyState === state.OPEN && this.onmessage) {
  41511. this.onmessage({ data: event });
  41512. }
  41513. };
  41514. HTTPSocket.prototype.onActivity = function () {
  41515. if (this.onactivity) {
  41516. this.onactivity();
  41517. }
  41518. };
  41519. HTTPSocket.prototype.onError = function (error) {
  41520. if (this.onerror) {
  41521. this.onerror(error);
  41522. }
  41523. };
  41524. HTTPSocket.prototype.openStream = function () {
  41525. var _this = this;
  41526. this.stream = runtime.createSocketRequest("POST", getUniqueURL(this.hooks.getReceiveURL(this.location, this.session)));
  41527. this.stream.bind("chunk", function (chunk) {
  41528. _this.onChunk(chunk);
  41529. });
  41530. this.stream.bind("finished", function (status) {
  41531. _this.hooks.onFinished(_this, status);
  41532. });
  41533. this.stream.bind("buffer_too_long", function () {
  41534. _this.reconnect();
  41535. });
  41536. try {
  41537. this.stream.start();
  41538. }
  41539. catch (error) {
  41540. util.defer(function () {
  41541. _this.onError(error);
  41542. _this.onClose(1006, "Could not start streaming", false);
  41543. });
  41544. }
  41545. };
  41546. HTTPSocket.prototype.closeStream = function () {
  41547. if (this.stream) {
  41548. this.stream.unbind_all();
  41549. this.stream.close();
  41550. this.stream = null;
  41551. }
  41552. };
  41553. return HTTPSocket;
  41554. }());
  41555. function getLocation(url) {
  41556. var parts = /([^\?]*)\/*(\??.*)/.exec(url);
  41557. return {
  41558. base: parts[1],
  41559. queryString: parts[2]
  41560. };
  41561. }
  41562. function getSendURL(url, session) {
  41563. return url.base + "/" + session + "/xhr_send";
  41564. }
  41565. function getUniqueURL(url) {
  41566. var separator = (url.indexOf('?') === -1) ? "?" : "&";
  41567. return url + separator + "t=" + (+new Date()) + "&n=" + autoIncrement++;
  41568. }
  41569. function replaceHost(url, hostname) {
  41570. var urlParts = /(https?:\/\/)([^\/:]+)((\/|:)?.*)/.exec(url);
  41571. return urlParts[1] + hostname + urlParts[3];
  41572. }
  41573. function randomNumber(max) {
  41574. return Math.floor(Math.random() * max);
  41575. }
  41576. function randomString(length) {
  41577. var result = [];
  41578. for (var i = 0; i < length; i++) {
  41579. result.push(randomNumber(32).toString(32));
  41580. }
  41581. return result.join('');
  41582. }
  41583. /* harmony default export */ var http_socket = (http_socket_HTTPSocket);
  41584. // CONCATENATED MODULE: ./src/core/http/http_streaming_socket.ts
  41585. var http_streaming_socket_hooks = {
  41586. getReceiveURL: function (url, session) {
  41587. return url.base + "/" + session + "/xhr_streaming" + url.queryString;
  41588. },
  41589. onHeartbeat: function (socket) {
  41590. socket.sendRaw("[]");
  41591. },
  41592. sendHeartbeat: function (socket) {
  41593. socket.sendRaw("[]");
  41594. },
  41595. onFinished: function (socket, status) {
  41596. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  41597. }
  41598. };
  41599. /* harmony default export */ var http_streaming_socket = (http_streaming_socket_hooks);
  41600. // CONCATENATED MODULE: ./src/core/http/http_polling_socket.ts
  41601. var http_polling_socket_hooks = {
  41602. getReceiveURL: function (url, session) {
  41603. return url.base + "/" + session + "/xhr" + url.queryString;
  41604. },
  41605. onHeartbeat: function () {
  41606. },
  41607. sendHeartbeat: function (socket) {
  41608. socket.sendRaw("[]");
  41609. },
  41610. onFinished: function (socket, status) {
  41611. if (status === 200) {
  41612. socket.reconnect();
  41613. }
  41614. else {
  41615. socket.onClose(1006, "Connection interrupted (" + status + ")", false);
  41616. }
  41617. }
  41618. };
  41619. /* harmony default export */ var http_polling_socket = (http_polling_socket_hooks);
  41620. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http_xhr_request.ts
  41621. var http_xhr_request_hooks = {
  41622. getRequest: function (socket) {
  41623. var Constructor = runtime.getXHRAPI();
  41624. var xhr = new Constructor();
  41625. xhr.onreadystatechange = xhr.onprogress = function () {
  41626. switch (xhr.readyState) {
  41627. case 3:
  41628. if (xhr.responseText && xhr.responseText.length > 0) {
  41629. socket.onChunk(xhr.status, xhr.responseText);
  41630. }
  41631. break;
  41632. case 4:
  41633. if (xhr.responseText && xhr.responseText.length > 0) {
  41634. socket.onChunk(xhr.status, xhr.responseText);
  41635. }
  41636. socket.emit("finished", xhr.status);
  41637. socket.close();
  41638. break;
  41639. }
  41640. };
  41641. return xhr;
  41642. },
  41643. abortRequest: function (xhr) {
  41644. xhr.onreadystatechange = null;
  41645. xhr.abort();
  41646. }
  41647. };
  41648. /* harmony default export */ var http_xhr_request = (http_xhr_request_hooks);
  41649. // CONCATENATED MODULE: ./src/runtimes/isomorphic/http/http.ts
  41650. var HTTP = {
  41651. createStreamingSocket: function (url) {
  41652. return this.createSocket(http_streaming_socket, url);
  41653. },
  41654. createPollingSocket: function (url) {
  41655. return this.createSocket(http_polling_socket, url);
  41656. },
  41657. createSocket: function (hooks, url) {
  41658. return new http_socket(hooks, url);
  41659. },
  41660. createXHR: function (method, url) {
  41661. return this.createRequest(http_xhr_request, method, url);
  41662. },
  41663. createRequest: function (hooks, method, url) {
  41664. return new http_request(hooks, method, url);
  41665. }
  41666. };
  41667. /* harmony default export */ var http_http = (HTTP);
  41668. // CONCATENATED MODULE: ./src/runtimes/web/http/http.ts
  41669. http_http.createXDR = function (method, url) {
  41670. return this.createRequest(http_xdomain_request, method, url);
  41671. };
  41672. /* harmony default export */ var web_http_http = (http_http);
  41673. // CONCATENATED MODULE: ./src/runtimes/web/runtime.ts
  41674. var Runtime = {
  41675. nextAuthCallbackID: 1,
  41676. auth_callbacks: {},
  41677. ScriptReceivers: ScriptReceivers,
  41678. DependenciesReceivers: DependenciesReceivers,
  41679. getDefaultStrategy: default_strategy,
  41680. Transports: transports_transports,
  41681. transportConnectionInitializer: transport_connection_initializer,
  41682. HTTPFactory: web_http_http,
  41683. TimelineTransport: jsonp_timeline,
  41684. getXHRAPI: function () {
  41685. return window.XMLHttpRequest;
  41686. },
  41687. getWebSocketAPI: function () {
  41688. return window.WebSocket || window.MozWebSocket;
  41689. },
  41690. setup: function (PusherClass) {
  41691. var _this = this;
  41692. window.Pusher = PusherClass;
  41693. var initializeOnDocumentBody = function () {
  41694. _this.onDocumentBody(PusherClass.ready);
  41695. };
  41696. if (!window.JSON) {
  41697. Dependencies.load("json2", {}, initializeOnDocumentBody);
  41698. }
  41699. else {
  41700. initializeOnDocumentBody();
  41701. }
  41702. },
  41703. getDocument: function () {
  41704. return document;
  41705. },
  41706. getProtocol: function () {
  41707. return this.getDocument().location.protocol;
  41708. },
  41709. getAuthorizers: function () {
  41710. return { ajax: xhr_auth, jsonp: jsonp_auth };
  41711. },
  41712. onDocumentBody: function (callback) {
  41713. var _this = this;
  41714. if (document.body) {
  41715. callback();
  41716. }
  41717. else {
  41718. setTimeout(function () {
  41719. _this.onDocumentBody(callback);
  41720. }, 0);
  41721. }
  41722. },
  41723. createJSONPRequest: function (url, data) {
  41724. return new jsonp_request(url, data);
  41725. },
  41726. createScriptRequest: function (src) {
  41727. return new script_request(src);
  41728. },
  41729. getLocalStorage: function () {
  41730. try {
  41731. return window.localStorage;
  41732. }
  41733. catch (e) {
  41734. return undefined;
  41735. }
  41736. },
  41737. createXHR: function () {
  41738. if (this.getXHRAPI()) {
  41739. return this.createXMLHttpRequest();
  41740. }
  41741. else {
  41742. return this.createMicrosoftXHR();
  41743. }
  41744. },
  41745. createXMLHttpRequest: function () {
  41746. var Constructor = this.getXHRAPI();
  41747. return new Constructor();
  41748. },
  41749. createMicrosoftXHR: function () {
  41750. return new ActiveXObject("Microsoft.XMLHTTP");
  41751. },
  41752. getNetwork: function () {
  41753. return net_info_Network;
  41754. },
  41755. createWebSocket: function (url) {
  41756. var Constructor = this.getWebSocketAPI();
  41757. return new Constructor(url);
  41758. },
  41759. createSocketRequest: function (method, url) {
  41760. if (this.isXHRSupported()) {
  41761. return this.HTTPFactory.createXHR(method, url);
  41762. }
  41763. else if (this.isXDRSupported(url.indexOf("https:") === 0)) {
  41764. return this.HTTPFactory.createXDR(method, url);
  41765. }
  41766. else {
  41767. throw "Cross-origin HTTP requests are not supported";
  41768. }
  41769. },
  41770. isXHRSupported: function () {
  41771. var Constructor = this.getXHRAPI();
  41772. return Boolean(Constructor) && (new Constructor()).withCredentials !== undefined;
  41773. },
  41774. isXDRSupported: function (useTLS) {
  41775. var protocol = useTLS ? "https:" : "http:";
  41776. var documentProtocol = this.getProtocol();
  41777. return Boolean((window['XDomainRequest'])) && documentProtocol === protocol;
  41778. },
  41779. addUnloadListener: function (listener) {
  41780. if (window.addEventListener !== undefined) {
  41781. window.addEventListener("unload", listener, false);
  41782. }
  41783. else if (window.attachEvent !== undefined) {
  41784. window.attachEvent("onunload", listener);
  41785. }
  41786. },
  41787. removeUnloadListener: function (listener) {
  41788. if (window.addEventListener !== undefined) {
  41789. window.removeEventListener("unload", listener, false);
  41790. }
  41791. else if (window.detachEvent !== undefined) {
  41792. window.detachEvent("onunload", listener);
  41793. }
  41794. }
  41795. };
  41796. /* harmony default export */ var runtime = (Runtime);
  41797. // CONCATENATED MODULE: ./src/core/timeline/level.ts
  41798. var TimelineLevel;
  41799. (function (TimelineLevel) {
  41800. TimelineLevel[TimelineLevel["ERROR"] = 3] = "ERROR";
  41801. TimelineLevel[TimelineLevel["INFO"] = 6] = "INFO";
  41802. TimelineLevel[TimelineLevel["DEBUG"] = 7] = "DEBUG";
  41803. })(TimelineLevel || (TimelineLevel = {}));
  41804. /* harmony default export */ var timeline_level = (TimelineLevel);
  41805. // CONCATENATED MODULE: ./src/core/timeline/timeline.ts
  41806. var timeline_Timeline = (function () {
  41807. function Timeline(key, session, options) {
  41808. this.key = key;
  41809. this.session = session;
  41810. this.events = [];
  41811. this.options = options || {};
  41812. this.sent = 0;
  41813. this.uniqueID = 0;
  41814. }
  41815. Timeline.prototype.log = function (level, event) {
  41816. if (level <= this.options.level) {
  41817. this.events.push(extend({}, event, { timestamp: util.now() }));
  41818. if (this.options.limit && this.events.length > this.options.limit) {
  41819. this.events.shift();
  41820. }
  41821. }
  41822. };
  41823. Timeline.prototype.error = function (event) {
  41824. this.log(timeline_level.ERROR, event);
  41825. };
  41826. Timeline.prototype.info = function (event) {
  41827. this.log(timeline_level.INFO, event);
  41828. };
  41829. Timeline.prototype.debug = function (event) {
  41830. this.log(timeline_level.DEBUG, event);
  41831. };
  41832. Timeline.prototype.isEmpty = function () {
  41833. return this.events.length === 0;
  41834. };
  41835. Timeline.prototype.send = function (sendfn, callback) {
  41836. var _this = this;
  41837. var data = extend({
  41838. session: this.session,
  41839. bundle: this.sent + 1,
  41840. key: this.key,
  41841. lib: "js",
  41842. version: this.options.version,
  41843. cluster: this.options.cluster,
  41844. features: this.options.features,
  41845. timeline: this.events
  41846. }, this.options.params);
  41847. this.events = [];
  41848. sendfn(data, function (error, result) {
  41849. if (!error) {
  41850. _this.sent++;
  41851. }
  41852. if (callback) {
  41853. callback(error, result);
  41854. }
  41855. });
  41856. return true;
  41857. };
  41858. Timeline.prototype.generateUniqueID = function () {
  41859. this.uniqueID++;
  41860. return this.uniqueID;
  41861. };
  41862. return Timeline;
  41863. }());
  41864. /* harmony default export */ var timeline_timeline = (timeline_Timeline);
  41865. // CONCATENATED MODULE: ./src/core/strategies/transport_strategy.ts
  41866. var transport_strategy_TransportStrategy = (function () {
  41867. function TransportStrategy(name, priority, transport, options) {
  41868. this.name = name;
  41869. this.priority = priority;
  41870. this.transport = transport;
  41871. this.options = options || {};
  41872. }
  41873. TransportStrategy.prototype.isSupported = function () {
  41874. return this.transport.isSupported({
  41875. useTLS: this.options.useTLS
  41876. });
  41877. };
  41878. TransportStrategy.prototype.connect = function (minPriority, callback) {
  41879. var _this = this;
  41880. if (!this.isSupported()) {
  41881. return failAttempt(new UnsupportedStrategy(), callback);
  41882. }
  41883. else if (this.priority < minPriority) {
  41884. return failAttempt(new TransportPriorityTooLow(), callback);
  41885. }
  41886. var connected = false;
  41887. var transport = this.transport.createConnection(this.name, this.priority, this.options.key, this.options);
  41888. var handshake = null;
  41889. var onInitialized = function () {
  41890. transport.unbind("initialized", onInitialized);
  41891. transport.connect();
  41892. };
  41893. var onOpen = function () {
  41894. handshake = factory.createHandshake(transport, function (result) {
  41895. connected = true;
  41896. unbindListeners();
  41897. callback(null, result);
  41898. });
  41899. };
  41900. var onError = function (error) {
  41901. unbindListeners();
  41902. callback(error);
  41903. };
  41904. var onClosed = function () {
  41905. unbindListeners();
  41906. var serializedTransport;
  41907. serializedTransport = safeJSONStringify(transport);
  41908. callback(new TransportClosed(serializedTransport));
  41909. };
  41910. var unbindListeners = function () {
  41911. transport.unbind("initialized", onInitialized);
  41912. transport.unbind("open", onOpen);
  41913. transport.unbind("error", onError);
  41914. transport.unbind("closed", onClosed);
  41915. };
  41916. transport.bind("initialized", onInitialized);
  41917. transport.bind("open", onOpen);
  41918. transport.bind("error", onError);
  41919. transport.bind("closed", onClosed);
  41920. transport.initialize();
  41921. return {
  41922. abort: function () {
  41923. if (connected) {
  41924. return;
  41925. }
  41926. unbindListeners();
  41927. if (handshake) {
  41928. handshake.close();
  41929. }
  41930. else {
  41931. transport.close();
  41932. }
  41933. },
  41934. forceMinPriority: function (p) {
  41935. if (connected) {
  41936. return;
  41937. }
  41938. if (_this.priority < p) {
  41939. if (handshake) {
  41940. handshake.close();
  41941. }
  41942. else {
  41943. transport.close();
  41944. }
  41945. }
  41946. }
  41947. };
  41948. };
  41949. return TransportStrategy;
  41950. }());
  41951. /* harmony default export */ var transport_strategy = (transport_strategy_TransportStrategy);
  41952. function failAttempt(error, callback) {
  41953. util.defer(function () {
  41954. callback(error);
  41955. });
  41956. return {
  41957. abort: function () { },
  41958. forceMinPriority: function () { }
  41959. };
  41960. }
  41961. // CONCATENATED MODULE: ./src/core/strategies/strategy_builder.ts
  41962. var strategy_builder_Transports = runtime.Transports;
  41963. var strategy_builder_defineTransport = function (config, name, type, priority, options, manager) {
  41964. var transportClass = strategy_builder_Transports[type];
  41965. if (!transportClass) {
  41966. throw new UnsupportedTransport(type);
  41967. }
  41968. var enabled = (!config.enabledTransports ||
  41969. arrayIndexOf(config.enabledTransports, name) !== -1) &&
  41970. (!config.disabledTransports ||
  41971. arrayIndexOf(config.disabledTransports, name) === -1);
  41972. var transport;
  41973. if (enabled) {
  41974. transport = new transport_strategy(name, priority, manager ? manager.getAssistant(transportClass) : transportClass, extend({
  41975. key: config.key,
  41976. useTLS: config.useTLS,
  41977. timeline: config.timeline,
  41978. ignoreNullOrigin: config.ignoreNullOrigin
  41979. }, options));
  41980. }
  41981. else {
  41982. transport = strategy_builder_UnsupportedStrategy;
  41983. }
  41984. return transport;
  41985. };
  41986. var strategy_builder_UnsupportedStrategy = {
  41987. isSupported: function () {
  41988. return false;
  41989. },
  41990. connect: function (_, callback) {
  41991. var deferred = util.defer(function () {
  41992. callback(new UnsupportedStrategy());
  41993. });
  41994. return {
  41995. abort: function () {
  41996. deferred.ensureAborted();
  41997. },
  41998. forceMinPriority: function () { }
  41999. };
  42000. }
  42001. };
  42002. // CONCATENATED MODULE: ./src/core/config.ts
  42003. var getGlobalConfig = function () {
  42004. return {
  42005. wsHost: defaults.host,
  42006. wsPort: defaults.ws_port,
  42007. wssPort: defaults.wss_port,
  42008. wsPath: defaults.ws_path,
  42009. httpHost: defaults.sockjs_host,
  42010. httpPort: defaults.sockjs_http_port,
  42011. httpsPort: defaults.sockjs_https_port,
  42012. httpPath: defaults.sockjs_path,
  42013. statsHost: defaults.stats_host,
  42014. authEndpoint: defaults.channel_auth_endpoint,
  42015. authTransport: defaults.channel_auth_transport,
  42016. activity_timeout: defaults.activity_timeout,
  42017. pong_timeout: defaults.pong_timeout,
  42018. unavailable_timeout: defaults.unavailable_timeout
  42019. };
  42020. };
  42021. var getClusterConfig = function (clusterName) {
  42022. return {
  42023. wsHost: 'ws-' + clusterName + '.pusher.com',
  42024. httpHost: 'sockjs-' + clusterName + '.pusher.com'
  42025. };
  42026. };
  42027. // CONCATENATED MODULE: ./src/core/pusher.ts
  42028. var pusher_Pusher = (function () {
  42029. function Pusher(app_key, options) {
  42030. var _this = this;
  42031. checkAppKey(app_key);
  42032. options = options || {};
  42033. if (!options.cluster && !(options.wsHost || options.httpHost)) {
  42034. var suffix = url_store.buildLogSuffix('javascriptQuickStart');
  42035. logger.warn("You should always specify a cluster when connecting. " + suffix);
  42036. }
  42037. this.key = app_key;
  42038. this.config = extend(getGlobalConfig(), options.cluster ? getClusterConfig(options.cluster) : {}, options);
  42039. this.channels = factory.createChannels();
  42040. this.global_emitter = new dispatcher();
  42041. this.sessionID = Math.floor(Math.random() * 1000000000);
  42042. this.timeline = new timeline_timeline(this.key, this.sessionID, {
  42043. cluster: this.config.cluster,
  42044. features: Pusher.getClientFeatures(),
  42045. params: this.config.timelineParams || {},
  42046. limit: 50,
  42047. level: timeline_level.INFO,
  42048. version: defaults.VERSION
  42049. });
  42050. if (!this.config.disableStats) {
  42051. this.timelineSender = factory.createTimelineSender(this.timeline, {
  42052. host: this.config.statsHost,
  42053. path: '/timeline/v2/' + runtime.TimelineTransport.name
  42054. });
  42055. }
  42056. var getStrategy = function (options) {
  42057. var config = extend({}, _this.config, options);
  42058. return runtime.getDefaultStrategy(config, strategy_builder_defineTransport);
  42059. };
  42060. this.connection = factory.createConnectionManager(this.key, extend({
  42061. getStrategy: getStrategy,
  42062. timeline: this.timeline,
  42063. activityTimeout: this.config.activity_timeout,
  42064. pongTimeout: this.config.pong_timeout,
  42065. unavailableTimeout: this.config.unavailable_timeout
  42066. }, this.config, { useTLS: this.shouldUseTLS() }));
  42067. this.connection.bind('connected', function () {
  42068. _this.subscribeAll();
  42069. if (_this.timelineSender) {
  42070. _this.timelineSender.send(_this.connection.isUsingTLS());
  42071. }
  42072. });
  42073. this.connection.bind('message', function (event) {
  42074. var eventName = event.event;
  42075. var internal = eventName.indexOf('pusher_internal:') === 0;
  42076. if (event.channel) {
  42077. var channel = _this.channel(event.channel);
  42078. if (channel) {
  42079. channel.handleEvent(event);
  42080. }
  42081. }
  42082. if (!internal) {
  42083. _this.global_emitter.emit(event.event, event.data);
  42084. }
  42085. });
  42086. this.connection.bind('connecting', function () {
  42087. _this.channels.disconnect();
  42088. });
  42089. this.connection.bind('disconnected', function () {
  42090. _this.channels.disconnect();
  42091. });
  42092. this.connection.bind('error', function (err) {
  42093. logger.warn(err);
  42094. });
  42095. Pusher.instances.push(this);
  42096. this.timeline.info({ instances: Pusher.instances.length });
  42097. if (Pusher.isReady) {
  42098. this.connect();
  42099. }
  42100. }
  42101. Pusher.ready = function () {
  42102. Pusher.isReady = true;
  42103. for (var i = 0, l = Pusher.instances.length; i < l; i++) {
  42104. Pusher.instances[i].connect();
  42105. }
  42106. };
  42107. Pusher.getClientFeatures = function () {
  42108. return keys(filterObject({ ws: runtime.Transports.ws }, function (t) {
  42109. return t.isSupported({});
  42110. }));
  42111. };
  42112. Pusher.prototype.channel = function (name) {
  42113. return this.channels.find(name);
  42114. };
  42115. Pusher.prototype.allChannels = function () {
  42116. return this.channels.all();
  42117. };
  42118. Pusher.prototype.connect = function () {
  42119. this.connection.connect();
  42120. if (this.timelineSender) {
  42121. if (!this.timelineSenderTimer) {
  42122. var usingTLS = this.connection.isUsingTLS();
  42123. var timelineSender = this.timelineSender;
  42124. this.timelineSenderTimer = new PeriodicTimer(60000, function () {
  42125. timelineSender.send(usingTLS);
  42126. });
  42127. }
  42128. }
  42129. };
  42130. Pusher.prototype.disconnect = function () {
  42131. this.connection.disconnect();
  42132. if (this.timelineSenderTimer) {
  42133. this.timelineSenderTimer.ensureAborted();
  42134. this.timelineSenderTimer = null;
  42135. }
  42136. };
  42137. Pusher.prototype.bind = function (event_name, callback, context) {
  42138. this.global_emitter.bind(event_name, callback, context);
  42139. return this;
  42140. };
  42141. Pusher.prototype.unbind = function (event_name, callback, context) {
  42142. this.global_emitter.unbind(event_name, callback, context);
  42143. return this;
  42144. };
  42145. Pusher.prototype.bind_global = function (callback) {
  42146. this.global_emitter.bind_global(callback);
  42147. return this;
  42148. };
  42149. Pusher.prototype.unbind_global = function (callback) {
  42150. this.global_emitter.unbind_global(callback);
  42151. return this;
  42152. };
  42153. Pusher.prototype.unbind_all = function (callback) {
  42154. this.global_emitter.unbind_all();
  42155. return this;
  42156. };
  42157. Pusher.prototype.subscribeAll = function () {
  42158. var channelName;
  42159. for (channelName in this.channels.channels) {
  42160. if (this.channels.channels.hasOwnProperty(channelName)) {
  42161. this.subscribe(channelName);
  42162. }
  42163. }
  42164. };
  42165. Pusher.prototype.subscribe = function (channel_name) {
  42166. var channel = this.channels.add(channel_name, this);
  42167. if (channel.subscriptionPending && channel.subscriptionCancelled) {
  42168. channel.reinstateSubscription();
  42169. }
  42170. else if (!channel.subscriptionPending &&
  42171. this.connection.state === 'connected') {
  42172. channel.subscribe();
  42173. }
  42174. return channel;
  42175. };
  42176. Pusher.prototype.unsubscribe = function (channel_name) {
  42177. var channel = this.channels.find(channel_name);
  42178. if (channel && channel.subscriptionPending) {
  42179. channel.cancelSubscription();
  42180. }
  42181. else {
  42182. channel = this.channels.remove(channel_name);
  42183. if (channel && this.connection.state === 'connected') {
  42184. channel.unsubscribe();
  42185. }
  42186. }
  42187. };
  42188. Pusher.prototype.send_event = function (event_name, data, channel) {
  42189. return this.connection.send_event(event_name, data, channel);
  42190. };
  42191. Pusher.prototype.shouldUseTLS = function () {
  42192. if (runtime.getProtocol() === 'https:') {
  42193. return true;
  42194. }
  42195. else if (this.config.forceTLS === true) {
  42196. return true;
  42197. }
  42198. else {
  42199. return Boolean(this.config.encrypted);
  42200. }
  42201. };
  42202. Pusher.instances = [];
  42203. Pusher.isReady = false;
  42204. Pusher.logToConsole = false;
  42205. Pusher.Runtime = runtime;
  42206. Pusher.ScriptReceivers = runtime.ScriptReceivers;
  42207. Pusher.DependenciesReceivers = runtime.DependenciesReceivers;
  42208. Pusher.auth_callbacks = runtime.auth_callbacks;
  42209. return Pusher;
  42210. }());
  42211. /* harmony default export */ var core_pusher = __webpack_exports__["default"] = (pusher_Pusher);
  42212. function checkAppKey(key) {
  42213. if (key === null || key === undefined) {
  42214. throw 'You must pass your app key when you instantiate Pusher.';
  42215. }
  42216. }
  42217. runtime.setup(pusher_Pusher);
  42218. /***/ })
  42219. /******/ ]);
  42220. });
  42221. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ "./node_modules/buffer/index.js").Buffer))
  42222. /***/ }),
  42223. /***/ "./node_modules/setimmediate/setImmediate.js":
  42224. /*!***************************************************!*\
  42225. !*** ./node_modules/setimmediate/setImmediate.js ***!
  42226. \***************************************************/
  42227. /*! no static exports found */
  42228. /***/ (function(module, exports, __webpack_require__) {
  42229. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  42230. "use strict";
  42231. if (global.setImmediate) {
  42232. return;
  42233. }
  42234. var nextHandle = 1; // Spec says greater than zero
  42235. var tasksByHandle = {};
  42236. var currentlyRunningATask = false;
  42237. var doc = global.document;
  42238. var registerImmediate;
  42239. function setImmediate(callback) {
  42240. // Callback can either be a function or a string
  42241. if (typeof callback !== "function") {
  42242. callback = new Function("" + callback);
  42243. }
  42244. // Copy function arguments
  42245. var args = new Array(arguments.length - 1);
  42246. for (var i = 0; i < args.length; i++) {
  42247. args[i] = arguments[i + 1];
  42248. }
  42249. // Store and register the task
  42250. var task = { callback: callback, args: args };
  42251. tasksByHandle[nextHandle] = task;
  42252. registerImmediate(nextHandle);
  42253. return nextHandle++;
  42254. }
  42255. function clearImmediate(handle) {
  42256. delete tasksByHandle[handle];
  42257. }
  42258. function run(task) {
  42259. var callback = task.callback;
  42260. var args = task.args;
  42261. switch (args.length) {
  42262. case 0:
  42263. callback();
  42264. break;
  42265. case 1:
  42266. callback(args[0]);
  42267. break;
  42268. case 2:
  42269. callback(args[0], args[1]);
  42270. break;
  42271. case 3:
  42272. callback(args[0], args[1], args[2]);
  42273. break;
  42274. default:
  42275. callback.apply(undefined, args);
  42276. break;
  42277. }
  42278. }
  42279. function runIfPresent(handle) {
  42280. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  42281. // So if we're currently running a task, we'll need to delay this invocation.
  42282. if (currentlyRunningATask) {
  42283. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  42284. // "too much recursion" error.
  42285. setTimeout(runIfPresent, 0, handle);
  42286. } else {
  42287. var task = tasksByHandle[handle];
  42288. if (task) {
  42289. currentlyRunningATask = true;
  42290. try {
  42291. run(task);
  42292. } finally {
  42293. clearImmediate(handle);
  42294. currentlyRunningATask = false;
  42295. }
  42296. }
  42297. }
  42298. }
  42299. function installNextTickImplementation() {
  42300. registerImmediate = function(handle) {
  42301. process.nextTick(function () { runIfPresent(handle); });
  42302. };
  42303. }
  42304. function canUsePostMessage() {
  42305. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  42306. // where `global.postMessage` means something completely different and can't be used for this purpose.
  42307. if (global.postMessage && !global.importScripts) {
  42308. var postMessageIsAsynchronous = true;
  42309. var oldOnMessage = global.onmessage;
  42310. global.onmessage = function() {
  42311. postMessageIsAsynchronous = false;
  42312. };
  42313. global.postMessage("", "*");
  42314. global.onmessage = oldOnMessage;
  42315. return postMessageIsAsynchronous;
  42316. }
  42317. }
  42318. function installPostMessageImplementation() {
  42319. // Installs an event handler on `global` for the `message` event: see
  42320. // * https://developer.mozilla.org/en/DOM/window.postMessage
  42321. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  42322. var messagePrefix = "setImmediate$" + Math.random() + "$";
  42323. var onGlobalMessage = function(event) {
  42324. if (event.source === global &&
  42325. typeof event.data === "string" &&
  42326. event.data.indexOf(messagePrefix) === 0) {
  42327. runIfPresent(+event.data.slice(messagePrefix.length));
  42328. }
  42329. };
  42330. if (global.addEventListener) {
  42331. global.addEventListener("message", onGlobalMessage, false);
  42332. } else {
  42333. global.attachEvent("onmessage", onGlobalMessage);
  42334. }
  42335. registerImmediate = function(handle) {
  42336. global.postMessage(messagePrefix + handle, "*");
  42337. };
  42338. }
  42339. function installMessageChannelImplementation() {
  42340. var channel = new MessageChannel();
  42341. channel.port1.onmessage = function(event) {
  42342. var handle = event.data;
  42343. runIfPresent(handle);
  42344. };
  42345. registerImmediate = function(handle) {
  42346. channel.port2.postMessage(handle);
  42347. };
  42348. }
  42349. function installReadyStateChangeImplementation() {
  42350. var html = doc.documentElement;
  42351. registerImmediate = function(handle) {
  42352. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  42353. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  42354. var script = doc.createElement("script");
  42355. script.onreadystatechange = function () {
  42356. runIfPresent(handle);
  42357. script.onreadystatechange = null;
  42358. html.removeChild(script);
  42359. script = null;
  42360. };
  42361. html.appendChild(script);
  42362. };
  42363. }
  42364. function installSetTimeoutImplementation() {
  42365. registerImmediate = function(handle) {
  42366. setTimeout(runIfPresent, 0, handle);
  42367. };
  42368. }
  42369. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  42370. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  42371. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  42372. // Don't get fooled by e.g. browserify environments.
  42373. if ({}.toString.call(global.process) === "[object process]") {
  42374. // For Node.js before 0.9
  42375. installNextTickImplementation();
  42376. } else if (canUsePostMessage()) {
  42377. // For non-IE10 modern browsers
  42378. installPostMessageImplementation();
  42379. } else if (global.MessageChannel) {
  42380. // For web workers, where supported
  42381. installMessageChannelImplementation();
  42382. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  42383. // For IE 6–8
  42384. installReadyStateChangeImplementation();
  42385. } else {
  42386. // For older browsers
  42387. installSetTimeoutImplementation();
  42388. }
  42389. attachTo.setImmediate = setImmediate;
  42390. attachTo.clearImmediate = clearImmediate;
  42391. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  42392. /* 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")))
  42393. /***/ }),
  42394. /***/ "./node_modules/timers-browserify/main.js":
  42395. /*!************************************************!*\
  42396. !*** ./node_modules/timers-browserify/main.js ***!
  42397. \************************************************/
  42398. /*! no static exports found */
  42399. /***/ (function(module, exports, __webpack_require__) {
  42400. /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
  42401. (typeof self !== "undefined" && self) ||
  42402. window;
  42403. var apply = Function.prototype.apply;
  42404. // DOM APIs, for completeness
  42405. exports.setTimeout = function() {
  42406. return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
  42407. };
  42408. exports.setInterval = function() {
  42409. return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
  42410. };
  42411. exports.clearTimeout =
  42412. exports.clearInterval = function(timeout) {
  42413. if (timeout) {
  42414. timeout.close();
  42415. }
  42416. };
  42417. function Timeout(id, clearFn) {
  42418. this._id = id;
  42419. this._clearFn = clearFn;
  42420. }
  42421. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  42422. Timeout.prototype.close = function() {
  42423. this._clearFn.call(scope, this._id);
  42424. };
  42425. // Does not start the time, just sets up the members needed.
  42426. exports.enroll = function(item, msecs) {
  42427. clearTimeout(item._idleTimeoutId);
  42428. item._idleTimeout = msecs;
  42429. };
  42430. exports.unenroll = function(item) {
  42431. clearTimeout(item._idleTimeoutId);
  42432. item._idleTimeout = -1;
  42433. };
  42434. exports._unrefActive = exports.active = function(item) {
  42435. clearTimeout(item._idleTimeoutId);
  42436. var msecs = item._idleTimeout;
  42437. if (msecs >= 0) {
  42438. item._idleTimeoutId = setTimeout(function onTimeout() {
  42439. if (item._onTimeout)
  42440. item._onTimeout();
  42441. }, msecs);
  42442. }
  42443. };
  42444. // setimmediate attaches itself to the global object
  42445. __webpack_require__(/*! setimmediate */ "./node_modules/setimmediate/setImmediate.js");
  42446. // On some exotic environments, it's not clear which object `setimmediate` was
  42447. // able to install onto. Search each possibility in the same order as the
  42448. // `setimmediate` library.
  42449. exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
  42450. (typeof global !== "undefined" && global.setImmediate) ||
  42451. (this && this.setImmediate);
  42452. exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
  42453. (typeof global !== "undefined" && global.clearImmediate) ||
  42454. (this && this.clearImmediate);
  42455. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  42456. /***/ }),
  42457. /***/ "./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&":
  42458. /*!*******************************************************************************************************************************************************************************************************************!*\
  42459. !*** ./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& ***!
  42460. \*******************************************************************************************************************************************************************************************************************/
  42461. /*! exports provided: render, staticRenderFns */
  42462. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42463. "use strict";
  42464. __webpack_require__.r(__webpack_exports__);
  42465. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42466. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42467. var render = function() {
  42468. var _vm = this
  42469. var _h = _vm.$createElement
  42470. var _c = _vm._self._c || _h
  42471. return _vm._m(0)
  42472. }
  42473. var staticRenderFns = [
  42474. function() {
  42475. var _vm = this
  42476. var _h = _vm.$createElement
  42477. var _c = _vm._self._c || _h
  42478. return _c("div", { staticClass: "container" }, [
  42479. _c("div", { staticClass: "row justify-content-center" }, [
  42480. _c("div", { staticClass: "col-md-8" }, [
  42481. _c("div", { staticClass: "card" }, [
  42482. _c("div", { staticClass: "card-header" }, [
  42483. _vm._v("Example Component")
  42484. ]),
  42485. _vm._v(" "),
  42486. _c("div", { staticClass: "card-body" }, [
  42487. _vm._v(
  42488. "\n I'm an example component.\n "
  42489. )
  42490. ])
  42491. ])
  42492. ])
  42493. ])
  42494. ])
  42495. }
  42496. ]
  42497. render._withStripped = true
  42498. /***/ }),
  42499. /***/ "./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&":
  42500. /*!************************************************************************************************************************************************************************************************************!*\
  42501. !*** ./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& ***!
  42502. \************************************************************************************************************************************************************************************************************/
  42503. /*! exports provided: render, staticRenderFns */
  42504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42505. "use strict";
  42506. __webpack_require__.r(__webpack_exports__);
  42507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42508. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42509. var render = function() {
  42510. var _vm = this
  42511. var _h = _vm.$createElement
  42512. var _c = _vm._self._c || _h
  42513. return _c("div", [
  42514. _c("h4", { staticClass: "text-center" }, [
  42515. _vm._v(_vm._s(this.data.pcmanu) + " " + _vm._s(this.data.pcmake) + " - "),
  42516. _c("small", { staticClass: "text-muted" }, [
  42517. _vm._v(_vm._s(this.data.pcnickname))
  42518. ])
  42519. ]),
  42520. _vm._v(" "),
  42521. _c("p", [_vm._v("S/N: " + _vm._s(this.data.pcserial))]),
  42522. _vm._v(" "),
  42523. _c("p", [_vm._v("CPU: " + _vm._s(this.data.pcproc))]),
  42524. _vm._v(" "),
  42525. _c("p", [_vm._v("RAM: " + _vm._s(this.data.pcram))]),
  42526. _vm._v(" "),
  42527. _c("p", [_vm._v("OS: " + _vm._s(this.data.pcos))])
  42528. ])
  42529. }
  42530. var staticRenderFns = []
  42531. render._withStripped = true
  42532. /***/ }),
  42533. /***/ "./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&":
  42534. /*!*************************************************************************************************************************************************************************************************************!*\
  42535. !*** ./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& ***!
  42536. \*************************************************************************************************************************************************************************************************************/
  42537. /*! exports provided: render, staticRenderFns */
  42538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42539. "use strict";
  42540. __webpack_require__.r(__webpack_exports__);
  42541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42543. var render = function() {
  42544. var _vm = this
  42545. var _h = _vm.$createElement
  42546. var _c = _vm._self._c || _h
  42547. return _c(
  42548. "div",
  42549. { staticClass: "bg-lightgray m-1 p-2 border rounded container-fluid" },
  42550. [
  42551. _c("div", { staticClass: "row no-gutters" }, [
  42552. _c("div", { staticClass: "h5 col-3 text-left" }, [
  42553. _vm._v(_vm._s(this.data.creddesc))
  42554. ]),
  42555. _vm._v(" "),
  42556. _c("div", { staticClass: "col-9 text-right" }, [
  42557. _vm._v(_vm._s(this.data.creddate))
  42558. ])
  42559. ]),
  42560. _vm._v(" "),
  42561. _c("div", { staticClass: "row" }, [
  42562. _c("div", { staticClass: "col-lg-9" }, [
  42563. _c("div", [
  42564. _vm._m(0),
  42565. _vm._v(" "),
  42566. _c("input", {
  42567. staticClass: "border-0 credential",
  42568. attrs: {
  42569. type: "text",
  42570. id: "username" + this.data.credid,
  42571. readonly: ""
  42572. },
  42573. domProps: { value: this.data.creduser }
  42574. }),
  42575. _vm._v(" "),
  42576. _c(
  42577. "button",
  42578. {
  42579. staticClass: "btn-clip btn btn-sm btn-primary rounded-pill",
  42580. attrs: {
  42581. id: "btn-username" + this.data.credid,
  42582. "data-clipboard-target": "#username" + this.data.credid
  42583. }
  42584. },
  42585. [_c("i", { staticClass: "far fa-clone" })]
  42586. )
  42587. ]),
  42588. _vm._v(" "),
  42589. _c("div", [
  42590. _vm._m(1),
  42591. _vm._v(" "),
  42592. _c("input", {
  42593. staticClass: "border-0 credential",
  42594. attrs: {
  42595. type: "text",
  42596. id: "password" + this.data.credid,
  42597. readonly: ""
  42598. },
  42599. domProps: { value: this.data.credpass }
  42600. }),
  42601. _vm._v(" "),
  42602. _c(
  42603. "button",
  42604. {
  42605. staticClass: "btn-clip btn btn-sm btn-primary rounded-pill",
  42606. attrs: {
  42607. id: "btn-password" + this.data.credid,
  42608. "data-clipboard-target": "#password" + this.data.credid
  42609. }
  42610. },
  42611. [_c("i", { staticClass: "far fa-clone" })]
  42612. )
  42613. ])
  42614. ]),
  42615. _vm._v(" "),
  42616. _vm._m(2)
  42617. ])
  42618. ]
  42619. )
  42620. }
  42621. var staticRenderFns = [
  42622. function() {
  42623. var _vm = this
  42624. var _h = _vm.$createElement
  42625. var _c = _vm._self._c || _h
  42626. return _c("label", { attrs: { for: "username" } }, [
  42627. _c("i", { staticClass: "fas fa-fw fa-user" })
  42628. ])
  42629. },
  42630. function() {
  42631. var _vm = this
  42632. var _h = _vm.$createElement
  42633. var _c = _vm._self._c || _h
  42634. return _c("label", { attrs: { for: "password" } }, [
  42635. _c("i", { staticClass: "fas fa-fw fa-key" })
  42636. ])
  42637. },
  42638. function() {
  42639. var _vm = this
  42640. var _h = _vm.$createElement
  42641. var _c = _vm._self._c || _h
  42642. return _c(
  42643. "div",
  42644. {
  42645. staticClass: "btn-group col-lg-2 align-self-end w-25 w-lg-auto",
  42646. attrs: { role: "group", "aria-label": "Edit and Delete" }
  42647. },
  42648. [
  42649. _c(
  42650. "button",
  42651. {
  42652. staticClass: "btn btn-sm btn-secondary p-lg-1",
  42653. attrs: { type: "button" }
  42654. },
  42655. [_c("i", { staticClass: "fas fa-fw fa-edit" })]
  42656. ),
  42657. _vm._v(" "),
  42658. _c(
  42659. "button",
  42660. {
  42661. staticClass: "btn btn-sm btn-danger p-lg-1",
  42662. attrs: { type: "button" }
  42663. },
  42664. [_c("i", { staticClass: "fas fa-fw fa-trash-alt" })]
  42665. )
  42666. ]
  42667. )
  42668. }
  42669. ]
  42670. render._withStripped = true
  42671. /***/ }),
  42672. /***/ "./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&":
  42673. /*!********************************************************************************************************************************************************************************************************!*\
  42674. !*** ./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& ***!
  42675. \********************************************************************************************************************************************************************************************************/
  42676. /*! exports provided: render, staticRenderFns */
  42677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42678. "use strict";
  42679. __webpack_require__.r(__webpack_exports__);
  42680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42682. var render = function() {
  42683. var _vm = this
  42684. var _h = _vm.$createElement
  42685. var _c = _vm._self._c || _h
  42686. return _c(
  42687. "ul",
  42688. { staticClass: "list-unstyled" },
  42689. _vm._l(this.notes, function(note) {
  42690. return _c(
  42691. "li",
  42692. { key: note.noteid, staticClass: "d-flex" },
  42693. [
  42694. _vm.authusername === note.noteuser || _vm.authusername === "admin"
  42695. ? [
  42696. _c("button", { staticClass: "btn btn-primary m-1 my-2" }, [
  42697. _vm._v("Edit")
  42698. ]),
  42699. _vm._v(" "),
  42700. _c("button", { staticClass: "btn btn-danger m-1 my-2" }, [
  42701. _vm._v("Delete")
  42702. ]),
  42703. _vm._v(" "),
  42704. _c("button", { staticClass: "btn btn-primary m-1 my-2" }, [
  42705. _vm._v("Switch")
  42706. ])
  42707. ]
  42708. : _vm._e(),
  42709. _vm._v(" "),
  42710. _c("div", { staticClass: "card m-2 w-100" }, [
  42711. _c("div", { staticClass: "card-body p-2" }, [
  42712. _vm._v(
  42713. "\n " + _vm._s(note.thenote) + "\n "
  42714. )
  42715. ])
  42716. ])
  42717. ],
  42718. 2
  42719. )
  42720. }),
  42721. 0
  42722. )
  42723. }
  42724. var staticRenderFns = []
  42725. render._withStripped = true
  42726. /***/ }),
  42727. /***/ "./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&":
  42728. /*!*********************************************************************************************************************************************************************************************************!*\
  42729. !*** ./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& ***!
  42730. \*********************************************************************************************************************************************************************************************************/
  42731. /*! exports provided: render, staticRenderFns */
  42732. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42733. "use strict";
  42734. __webpack_require__.r(__webpack_exports__);
  42735. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; });
  42736. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "staticRenderFns", function() { return staticRenderFns; });
  42737. var render = function() {
  42738. var _vm = this
  42739. var _h = _vm.$createElement
  42740. var _c = _vm._self._c || _h
  42741. return _c("div", [
  42742. _c("p", [
  42743. _c("i", { staticClass: "fas fa-fw fa-info-circle" }),
  42744. _vm._v(" "),
  42745. _c("span", { domProps: { textContent: _vm._s(this.data.probdesc) } })
  42746. ]),
  42747. _vm._v(" "),
  42748. _c("p", [
  42749. _c("i", { staticClass: "far fa-fw fa-lightbulb" }),
  42750. _vm._v(" "),
  42751. _c("span", { domProps: { textContent: _vm._s(this.data.suggested) } })
  42752. ]),
  42753. _vm._v(" "),
  42754. _c("p", [
  42755. _c("i", { staticClass: "fas fa-fw fa-paste" }),
  42756. _vm._v(" "),
  42757. _c("span", { domProps: { textContent: _vm._s(this.data.woid) } })
  42758. ]),
  42759. _vm._v(" "),
  42760. _c("p", [
  42761. _c("i", { staticClass: "fas fa-fw fa-building" }),
  42762. _vm._v(" "),
  42763. _c("span", { domProps: { textContent: _vm._s(this.data.storeid) } })
  42764. ]),
  42765. _vm._v(" "),
  42766. _c("p", [
  42767. _c("i", { staticClass: "fas fa-fw fa-sign-in-alt" }),
  42768. _vm._v(" "),
  42769. _c(
  42770. "span",
  42771. {
  42772. staticClass: "dashed-underline",
  42773. attrs: {
  42774. "data-toggle": "tooltip",
  42775. "data-placement": "bottom",
  42776. title: this.getHRDate(this.data.dropdate)
  42777. }
  42778. },
  42779. [
  42780. _vm._v(
  42781. "\n " +
  42782. _vm._s(Math.floor(this.daysSinceToday(this.data.dropdate))) +
  42783. " days ago\n "
  42784. )
  42785. ]
  42786. )
  42787. ]),
  42788. _vm._v(" "),
  42789. _c("p", [
  42790. _c("i", { staticClass: "fas fa-sign-out-alt" }),
  42791. _vm._v(" "),
  42792. !this.isZero(this.data.pickupdate)
  42793. ? _c(
  42794. "span",
  42795. {
  42796. staticClass: "dashed-underline",
  42797. attrs: {
  42798. "data-toggle": "tooltip",
  42799. "data-placement": "bottom",
  42800. tittle: this.getHRDate(this.data.pickupdate)
  42801. }
  42802. },
  42803. [
  42804. _vm._v(
  42805. "\n " +
  42806. _vm._s(
  42807. Math.floor(this.daysSinceToday(this.data.pickupdate))
  42808. ) +
  42809. " days ago\n "
  42810. )
  42811. ]
  42812. )
  42813. : _vm._e()
  42814. ])
  42815. ])
  42816. }
  42817. var staticRenderFns = []
  42818. render._withStripped = true
  42819. /***/ }),
  42820. /***/ "./node_modules/vue-loader/lib/runtime/componentNormalizer.js":
  42821. /*!********************************************************************!*\
  42822. !*** ./node_modules/vue-loader/lib/runtime/componentNormalizer.js ***!
  42823. \********************************************************************/
  42824. /*! exports provided: default */
  42825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42826. "use strict";
  42827. __webpack_require__.r(__webpack_exports__);
  42828. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return normalizeComponent; });
  42829. /* globals __VUE_SSR_CONTEXT__ */
  42830. // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
  42831. // This module is a runtime utility for cleaner component module output and will
  42832. // be included in the final webpack user bundle.
  42833. function normalizeComponent (
  42834. scriptExports,
  42835. render,
  42836. staticRenderFns,
  42837. functionalTemplate,
  42838. injectStyles,
  42839. scopeId,
  42840. moduleIdentifier, /* server only */
  42841. shadowMode /* vue-cli only */
  42842. ) {
  42843. // Vue.extend constructor export interop
  42844. var options = typeof scriptExports === 'function'
  42845. ? scriptExports.options
  42846. : scriptExports
  42847. // render functions
  42848. if (render) {
  42849. options.render = render
  42850. options.staticRenderFns = staticRenderFns
  42851. options._compiled = true
  42852. }
  42853. // functional template
  42854. if (functionalTemplate) {
  42855. options.functional = true
  42856. }
  42857. // scopedId
  42858. if (scopeId) {
  42859. options._scopeId = 'data-v-' + scopeId
  42860. }
  42861. var hook
  42862. if (moduleIdentifier) { // server build
  42863. hook = function (context) {
  42864. // 2.3 injection
  42865. context =
  42866. context || // cached call
  42867. (this.$vnode && this.$vnode.ssrContext) || // stateful
  42868. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  42869. // 2.2 with runInNewContext: true
  42870. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  42871. context = __VUE_SSR_CONTEXT__
  42872. }
  42873. // inject component styles
  42874. if (injectStyles) {
  42875. injectStyles.call(this, context)
  42876. }
  42877. // register component module identifier for async chunk inferrence
  42878. if (context && context._registeredComponents) {
  42879. context._registeredComponents.add(moduleIdentifier)
  42880. }
  42881. }
  42882. // used by ssr in case component is cached and beforeCreate
  42883. // never gets called
  42884. options._ssrRegister = hook
  42885. } else if (injectStyles) {
  42886. hook = shadowMode
  42887. ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
  42888. : injectStyles
  42889. }
  42890. if (hook) {
  42891. if (options.functional) {
  42892. // for template-only hot-reload because in that case the render fn doesn't
  42893. // go through the normalizer
  42894. options._injectStyles = hook
  42895. // register for functioal component in vue file
  42896. var originalRender = options.render
  42897. options.render = function renderWithStyleInjection (h, context) {
  42898. hook.call(context)
  42899. return originalRender(h, context)
  42900. }
  42901. } else {
  42902. // inject component registration as beforeCreate hook
  42903. var existing = options.beforeCreate
  42904. options.beforeCreate = existing
  42905. ? [].concat(existing, hook)
  42906. : [hook]
  42907. }
  42908. }
  42909. return {
  42910. exports: scriptExports,
  42911. options: options
  42912. }
  42913. }
  42914. /***/ }),
  42915. /***/ "./node_modules/vue/dist/vue.common.dev.js":
  42916. /*!*************************************************!*\
  42917. !*** ./node_modules/vue/dist/vue.common.dev.js ***!
  42918. \*************************************************/
  42919. /*! no static exports found */
  42920. /***/ (function(module, exports, __webpack_require__) {
  42921. "use strict";
  42922. /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
  42923. * Vue.js v2.6.11
  42924. * (c) 2014-2019 Evan You
  42925. * Released under the MIT License.
  42926. */
  42927. /* */
  42928. var emptyObject = Object.freeze({});
  42929. // These helpers produce better VM code in JS engines due to their
  42930. // explicitness and function inlining.
  42931. function isUndef (v) {
  42932. return v === undefined || v === null
  42933. }
  42934. function isDef (v) {
  42935. return v !== undefined && v !== null
  42936. }
  42937. function isTrue (v) {
  42938. return v === true
  42939. }
  42940. function isFalse (v) {
  42941. return v === false
  42942. }
  42943. /**
  42944. * Check if value is primitive.
  42945. */
  42946. function isPrimitive (value) {
  42947. return (
  42948. typeof value === 'string' ||
  42949. typeof value === 'number' ||
  42950. // $flow-disable-line
  42951. typeof value === 'symbol' ||
  42952. typeof value === 'boolean'
  42953. )
  42954. }
  42955. /**
  42956. * Quick object check - this is primarily used to tell
  42957. * Objects from primitive values when we know the value
  42958. * is a JSON-compliant type.
  42959. */
  42960. function isObject (obj) {
  42961. return obj !== null && typeof obj === 'object'
  42962. }
  42963. /**
  42964. * Get the raw type string of a value, e.g., [object Object].
  42965. */
  42966. var _toString = Object.prototype.toString;
  42967. function toRawType (value) {
  42968. return _toString.call(value).slice(8, -1)
  42969. }
  42970. /**
  42971. * Strict object type check. Only returns true
  42972. * for plain JavaScript objects.
  42973. */
  42974. function isPlainObject (obj) {
  42975. return _toString.call(obj) === '[object Object]'
  42976. }
  42977. function isRegExp (v) {
  42978. return _toString.call(v) === '[object RegExp]'
  42979. }
  42980. /**
  42981. * Check if val is a valid array index.
  42982. */
  42983. function isValidArrayIndex (val) {
  42984. var n = parseFloat(String(val));
  42985. return n >= 0 && Math.floor(n) === n && isFinite(val)
  42986. }
  42987. function isPromise (val) {
  42988. return (
  42989. isDef(val) &&
  42990. typeof val.then === 'function' &&
  42991. typeof val.catch === 'function'
  42992. )
  42993. }
  42994. /**
  42995. * Convert a value to a string that is actually rendered.
  42996. */
  42997. function toString (val) {
  42998. return val == null
  42999. ? ''
  43000. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  43001. ? JSON.stringify(val, null, 2)
  43002. : String(val)
  43003. }
  43004. /**
  43005. * Convert an input value to a number for persistence.
  43006. * If the conversion fails, return original string.
  43007. */
  43008. function toNumber (val) {
  43009. var n = parseFloat(val);
  43010. return isNaN(n) ? val : n
  43011. }
  43012. /**
  43013. * Make a map and return a function for checking if a key
  43014. * is in that map.
  43015. */
  43016. function makeMap (
  43017. str,
  43018. expectsLowerCase
  43019. ) {
  43020. var map = Object.create(null);
  43021. var list = str.split(',');
  43022. for (var i = 0; i < list.length; i++) {
  43023. map[list[i]] = true;
  43024. }
  43025. return expectsLowerCase
  43026. ? function (val) { return map[val.toLowerCase()]; }
  43027. : function (val) { return map[val]; }
  43028. }
  43029. /**
  43030. * Check if a tag is a built-in tag.
  43031. */
  43032. var isBuiltInTag = makeMap('slot,component', true);
  43033. /**
  43034. * Check if an attribute is a reserved attribute.
  43035. */
  43036. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  43037. /**
  43038. * Remove an item from an array.
  43039. */
  43040. function remove (arr, item) {
  43041. if (arr.length) {
  43042. var index = arr.indexOf(item);
  43043. if (index > -1) {
  43044. return arr.splice(index, 1)
  43045. }
  43046. }
  43047. }
  43048. /**
  43049. * Check whether an object has the property.
  43050. */
  43051. var hasOwnProperty = Object.prototype.hasOwnProperty;
  43052. function hasOwn (obj, key) {
  43053. return hasOwnProperty.call(obj, key)
  43054. }
  43055. /**
  43056. * Create a cached version of a pure function.
  43057. */
  43058. function cached (fn) {
  43059. var cache = Object.create(null);
  43060. return (function cachedFn (str) {
  43061. var hit = cache[str];
  43062. return hit || (cache[str] = fn(str))
  43063. })
  43064. }
  43065. /**
  43066. * Camelize a hyphen-delimited string.
  43067. */
  43068. var camelizeRE = /-(\w)/g;
  43069. var camelize = cached(function (str) {
  43070. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  43071. });
  43072. /**
  43073. * Capitalize a string.
  43074. */
  43075. var capitalize = cached(function (str) {
  43076. return str.charAt(0).toUpperCase() + str.slice(1)
  43077. });
  43078. /**
  43079. * Hyphenate a camelCase string.
  43080. */
  43081. var hyphenateRE = /\B([A-Z])/g;
  43082. var hyphenate = cached(function (str) {
  43083. return str.replace(hyphenateRE, '-$1').toLowerCase()
  43084. });
  43085. /**
  43086. * Simple bind polyfill for environments that do not support it,
  43087. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  43088. * since native bind is now performant enough in most browsers.
  43089. * But removing it would mean breaking code that was able to run in
  43090. * PhantomJS 1.x, so this must be kept for backward compatibility.
  43091. */
  43092. /* istanbul ignore next */
  43093. function polyfillBind (fn, ctx) {
  43094. function boundFn (a) {
  43095. var l = arguments.length;
  43096. return l
  43097. ? l > 1
  43098. ? fn.apply(ctx, arguments)
  43099. : fn.call(ctx, a)
  43100. : fn.call(ctx)
  43101. }
  43102. boundFn._length = fn.length;
  43103. return boundFn
  43104. }
  43105. function nativeBind (fn, ctx) {
  43106. return fn.bind(ctx)
  43107. }
  43108. var bind = Function.prototype.bind
  43109. ? nativeBind
  43110. : polyfillBind;
  43111. /**
  43112. * Convert an Array-like object to a real Array.
  43113. */
  43114. function toArray (list, start) {
  43115. start = start || 0;
  43116. var i = list.length - start;
  43117. var ret = new Array(i);
  43118. while (i--) {
  43119. ret[i] = list[i + start];
  43120. }
  43121. return ret
  43122. }
  43123. /**
  43124. * Mix properties into target object.
  43125. */
  43126. function extend (to, _from) {
  43127. for (var key in _from) {
  43128. to[key] = _from[key];
  43129. }
  43130. return to
  43131. }
  43132. /**
  43133. * Merge an Array of Objects into a single Object.
  43134. */
  43135. function toObject (arr) {
  43136. var res = {};
  43137. for (var i = 0; i < arr.length; i++) {
  43138. if (arr[i]) {
  43139. extend(res, arr[i]);
  43140. }
  43141. }
  43142. return res
  43143. }
  43144. /* eslint-disable no-unused-vars */
  43145. /**
  43146. * Perform no operation.
  43147. * Stubbing args to make Flow happy without leaving useless transpiled code
  43148. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  43149. */
  43150. function noop (a, b, c) {}
  43151. /**
  43152. * Always return false.
  43153. */
  43154. var no = function (a, b, c) { return false; };
  43155. /* eslint-enable no-unused-vars */
  43156. /**
  43157. * Return the same value.
  43158. */
  43159. var identity = function (_) { return _; };
  43160. /**
  43161. * Generate a string containing static keys from compiler modules.
  43162. */
  43163. function genStaticKeys (modules) {
  43164. return modules.reduce(function (keys, m) {
  43165. return keys.concat(m.staticKeys || [])
  43166. }, []).join(',')
  43167. }
  43168. /**
  43169. * Check if two values are loosely equal - that is,
  43170. * if they are plain objects, do they have the same shape?
  43171. */
  43172. function looseEqual (a, b) {
  43173. if (a === b) { return true }
  43174. var isObjectA = isObject(a);
  43175. var isObjectB = isObject(b);
  43176. if (isObjectA && isObjectB) {
  43177. try {
  43178. var isArrayA = Array.isArray(a);
  43179. var isArrayB = Array.isArray(b);
  43180. if (isArrayA && isArrayB) {
  43181. return a.length === b.length && a.every(function (e, i) {
  43182. return looseEqual(e, b[i])
  43183. })
  43184. } else if (a instanceof Date && b instanceof Date) {
  43185. return a.getTime() === b.getTime()
  43186. } else if (!isArrayA && !isArrayB) {
  43187. var keysA = Object.keys(a);
  43188. var keysB = Object.keys(b);
  43189. return keysA.length === keysB.length && keysA.every(function (key) {
  43190. return looseEqual(a[key], b[key])
  43191. })
  43192. } else {
  43193. /* istanbul ignore next */
  43194. return false
  43195. }
  43196. } catch (e) {
  43197. /* istanbul ignore next */
  43198. return false
  43199. }
  43200. } else if (!isObjectA && !isObjectB) {
  43201. return String(a) === String(b)
  43202. } else {
  43203. return false
  43204. }
  43205. }
  43206. /**
  43207. * Return the first index at which a loosely equal value can be
  43208. * found in the array (if value is a plain object, the array must
  43209. * contain an object of the same shape), or -1 if it is not present.
  43210. */
  43211. function looseIndexOf (arr, val) {
  43212. for (var i = 0; i < arr.length; i++) {
  43213. if (looseEqual(arr[i], val)) { return i }
  43214. }
  43215. return -1
  43216. }
  43217. /**
  43218. * Ensure a function is called only once.
  43219. */
  43220. function once (fn) {
  43221. var called = false;
  43222. return function () {
  43223. if (!called) {
  43224. called = true;
  43225. fn.apply(this, arguments);
  43226. }
  43227. }
  43228. }
  43229. var SSR_ATTR = 'data-server-rendered';
  43230. var ASSET_TYPES = [
  43231. 'component',
  43232. 'directive',
  43233. 'filter'
  43234. ];
  43235. var LIFECYCLE_HOOKS = [
  43236. 'beforeCreate',
  43237. 'created',
  43238. 'beforeMount',
  43239. 'mounted',
  43240. 'beforeUpdate',
  43241. 'updated',
  43242. 'beforeDestroy',
  43243. 'destroyed',
  43244. 'activated',
  43245. 'deactivated',
  43246. 'errorCaptured',
  43247. 'serverPrefetch'
  43248. ];
  43249. /* */
  43250. var config = ({
  43251. /**
  43252. * Option merge strategies (used in core/util/options)
  43253. */
  43254. // $flow-disable-line
  43255. optionMergeStrategies: Object.create(null),
  43256. /**
  43257. * Whether to suppress warnings.
  43258. */
  43259. silent: false,
  43260. /**
  43261. * Show production mode tip message on boot?
  43262. */
  43263. productionTip: "development" !== 'production',
  43264. /**
  43265. * Whether to enable devtools
  43266. */
  43267. devtools: "development" !== 'production',
  43268. /**
  43269. * Whether to record perf
  43270. */
  43271. performance: false,
  43272. /**
  43273. * Error handler for watcher errors
  43274. */
  43275. errorHandler: null,
  43276. /**
  43277. * Warn handler for watcher warns
  43278. */
  43279. warnHandler: null,
  43280. /**
  43281. * Ignore certain custom elements
  43282. */
  43283. ignoredElements: [],
  43284. /**
  43285. * Custom user key aliases for v-on
  43286. */
  43287. // $flow-disable-line
  43288. keyCodes: Object.create(null),
  43289. /**
  43290. * Check if a tag is reserved so that it cannot be registered as a
  43291. * component. This is platform-dependent and may be overwritten.
  43292. */
  43293. isReservedTag: no,
  43294. /**
  43295. * Check if an attribute is reserved so that it cannot be used as a component
  43296. * prop. This is platform-dependent and may be overwritten.
  43297. */
  43298. isReservedAttr: no,
  43299. /**
  43300. * Check if a tag is an unknown element.
  43301. * Platform-dependent.
  43302. */
  43303. isUnknownElement: no,
  43304. /**
  43305. * Get the namespace of an element
  43306. */
  43307. getTagNamespace: noop,
  43308. /**
  43309. * Parse the real tag name for the specific platform.
  43310. */
  43311. parsePlatformTagName: identity,
  43312. /**
  43313. * Check if an attribute must be bound using property, e.g. value
  43314. * Platform-dependent.
  43315. */
  43316. mustUseProp: no,
  43317. /**
  43318. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  43319. * This will significantly reduce performance if set to false.
  43320. */
  43321. async: true,
  43322. /**
  43323. * Exposed for legacy reasons
  43324. */
  43325. _lifecycleHooks: LIFECYCLE_HOOKS
  43326. });
  43327. /* */
  43328. /**
  43329. * unicode letters used for parsing html tags, component names and property paths.
  43330. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  43331. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  43332. */
  43333. 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/;
  43334. /**
  43335. * Check if a string starts with $ or _
  43336. */
  43337. function isReserved (str) {
  43338. var c = (str + '').charCodeAt(0);
  43339. return c === 0x24 || c === 0x5F
  43340. }
  43341. /**
  43342. * Define a property.
  43343. */
  43344. function def (obj, key, val, enumerable) {
  43345. Object.defineProperty(obj, key, {
  43346. value: val,
  43347. enumerable: !!enumerable,
  43348. writable: true,
  43349. configurable: true
  43350. });
  43351. }
  43352. /**
  43353. * Parse simple path.
  43354. */
  43355. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  43356. function parsePath (path) {
  43357. if (bailRE.test(path)) {
  43358. return
  43359. }
  43360. var segments = path.split('.');
  43361. return function (obj) {
  43362. for (var i = 0; i < segments.length; i++) {
  43363. if (!obj) { return }
  43364. obj = obj[segments[i]];
  43365. }
  43366. return obj
  43367. }
  43368. }
  43369. /* */
  43370. // can we use __proto__?
  43371. var hasProto = '__proto__' in {};
  43372. // Browser environment sniffing
  43373. var inBrowser = typeof window !== 'undefined';
  43374. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  43375. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  43376. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  43377. var isIE = UA && /msie|trident/.test(UA);
  43378. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  43379. var isEdge = UA && UA.indexOf('edge/') > 0;
  43380. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  43381. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  43382. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  43383. var isPhantomJS = UA && /phantomjs/.test(UA);
  43384. var isFF = UA && UA.match(/firefox\/(\d+)/);
  43385. // Firefox has a "watch" function on Object.prototype...
  43386. var nativeWatch = ({}).watch;
  43387. var supportsPassive = false;
  43388. if (inBrowser) {
  43389. try {
  43390. var opts = {};
  43391. Object.defineProperty(opts, 'passive', ({
  43392. get: function get () {
  43393. /* istanbul ignore next */
  43394. supportsPassive = true;
  43395. }
  43396. })); // https://github.com/facebook/flow/issues/285
  43397. window.addEventListener('test-passive', null, opts);
  43398. } catch (e) {}
  43399. }
  43400. // this needs to be lazy-evaled because vue may be required before
  43401. // vue-server-renderer can set VUE_ENV
  43402. var _isServer;
  43403. var isServerRendering = function () {
  43404. if (_isServer === undefined) {
  43405. /* istanbul ignore if */
  43406. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  43407. // detect presence of vue-server-renderer and avoid
  43408. // Webpack shimming the process
  43409. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  43410. } else {
  43411. _isServer = false;
  43412. }
  43413. }
  43414. return _isServer
  43415. };
  43416. // detect devtools
  43417. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  43418. /* istanbul ignore next */
  43419. function isNative (Ctor) {
  43420. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  43421. }
  43422. var hasSymbol =
  43423. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  43424. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  43425. var _Set;
  43426. /* istanbul ignore if */ // $flow-disable-line
  43427. if (typeof Set !== 'undefined' && isNative(Set)) {
  43428. // use native Set when available.
  43429. _Set = Set;
  43430. } else {
  43431. // a non-standard Set polyfill that only works with primitive keys.
  43432. _Set = /*@__PURE__*/(function () {
  43433. function Set () {
  43434. this.set = Object.create(null);
  43435. }
  43436. Set.prototype.has = function has (key) {
  43437. return this.set[key] === true
  43438. };
  43439. Set.prototype.add = function add (key) {
  43440. this.set[key] = true;
  43441. };
  43442. Set.prototype.clear = function clear () {
  43443. this.set = Object.create(null);
  43444. };
  43445. return Set;
  43446. }());
  43447. }
  43448. /* */
  43449. var warn = noop;
  43450. var tip = noop;
  43451. var generateComponentTrace = (noop); // work around flow check
  43452. var formatComponentName = (noop);
  43453. {
  43454. var hasConsole = typeof console !== 'undefined';
  43455. var classifyRE = /(?:^|[-_])(\w)/g;
  43456. var classify = function (str) { return str
  43457. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  43458. .replace(/[-_]/g, ''); };
  43459. warn = function (msg, vm) {
  43460. var trace = vm ? generateComponentTrace(vm) : '';
  43461. if (config.warnHandler) {
  43462. config.warnHandler.call(null, msg, vm, trace);
  43463. } else if (hasConsole && (!config.silent)) {
  43464. console.error(("[Vue warn]: " + msg + trace));
  43465. }
  43466. };
  43467. tip = function (msg, vm) {
  43468. if (hasConsole && (!config.silent)) {
  43469. console.warn("[Vue tip]: " + msg + (
  43470. vm ? generateComponentTrace(vm) : ''
  43471. ));
  43472. }
  43473. };
  43474. formatComponentName = function (vm, includeFile) {
  43475. if (vm.$root === vm) {
  43476. return '<Root>'
  43477. }
  43478. var options = typeof vm === 'function' && vm.cid != null
  43479. ? vm.options
  43480. : vm._isVue
  43481. ? vm.$options || vm.constructor.options
  43482. : vm;
  43483. var name = options.name || options._componentTag;
  43484. var file = options.__file;
  43485. if (!name && file) {
  43486. var match = file.match(/([^/\\]+)\.vue$/);
  43487. name = match && match[1];
  43488. }
  43489. return (
  43490. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  43491. (file && includeFile !== false ? (" at " + file) : '')
  43492. )
  43493. };
  43494. var repeat = function (str, n) {
  43495. var res = '';
  43496. while (n) {
  43497. if (n % 2 === 1) { res += str; }
  43498. if (n > 1) { str += str; }
  43499. n >>= 1;
  43500. }
  43501. return res
  43502. };
  43503. generateComponentTrace = function (vm) {
  43504. if (vm._isVue && vm.$parent) {
  43505. var tree = [];
  43506. var currentRecursiveSequence = 0;
  43507. while (vm) {
  43508. if (tree.length > 0) {
  43509. var last = tree[tree.length - 1];
  43510. if (last.constructor === vm.constructor) {
  43511. currentRecursiveSequence++;
  43512. vm = vm.$parent;
  43513. continue
  43514. } else if (currentRecursiveSequence > 0) {
  43515. tree[tree.length - 1] = [last, currentRecursiveSequence];
  43516. currentRecursiveSequence = 0;
  43517. }
  43518. }
  43519. tree.push(vm);
  43520. vm = vm.$parent;
  43521. }
  43522. return '\n\nfound in\n\n' + tree
  43523. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  43524. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  43525. : formatComponentName(vm))); })
  43526. .join('\n')
  43527. } else {
  43528. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  43529. }
  43530. };
  43531. }
  43532. /* */
  43533. var uid = 0;
  43534. /**
  43535. * A dep is an observable that can have multiple
  43536. * directives subscribing to it.
  43537. */
  43538. var Dep = function Dep () {
  43539. this.id = uid++;
  43540. this.subs = [];
  43541. };
  43542. Dep.prototype.addSub = function addSub (sub) {
  43543. this.subs.push(sub);
  43544. };
  43545. Dep.prototype.removeSub = function removeSub (sub) {
  43546. remove(this.subs, sub);
  43547. };
  43548. Dep.prototype.depend = function depend () {
  43549. if (Dep.target) {
  43550. Dep.target.addDep(this);
  43551. }
  43552. };
  43553. Dep.prototype.notify = function notify () {
  43554. // stabilize the subscriber list first
  43555. var subs = this.subs.slice();
  43556. if (!config.async) {
  43557. // subs aren't sorted in scheduler if not running async
  43558. // we need to sort them now to make sure they fire in correct
  43559. // order
  43560. subs.sort(function (a, b) { return a.id - b.id; });
  43561. }
  43562. for (var i = 0, l = subs.length; i < l; i++) {
  43563. subs[i].update();
  43564. }
  43565. };
  43566. // The current target watcher being evaluated.
  43567. // This is globally unique because only one watcher
  43568. // can be evaluated at a time.
  43569. Dep.target = null;
  43570. var targetStack = [];
  43571. function pushTarget (target) {
  43572. targetStack.push(target);
  43573. Dep.target = target;
  43574. }
  43575. function popTarget () {
  43576. targetStack.pop();
  43577. Dep.target = targetStack[targetStack.length - 1];
  43578. }
  43579. /* */
  43580. var VNode = function VNode (
  43581. tag,
  43582. data,
  43583. children,
  43584. text,
  43585. elm,
  43586. context,
  43587. componentOptions,
  43588. asyncFactory
  43589. ) {
  43590. this.tag = tag;
  43591. this.data = data;
  43592. this.children = children;
  43593. this.text = text;
  43594. this.elm = elm;
  43595. this.ns = undefined;
  43596. this.context = context;
  43597. this.fnContext = undefined;
  43598. this.fnOptions = undefined;
  43599. this.fnScopeId = undefined;
  43600. this.key = data && data.key;
  43601. this.componentOptions = componentOptions;
  43602. this.componentInstance = undefined;
  43603. this.parent = undefined;
  43604. this.raw = false;
  43605. this.isStatic = false;
  43606. this.isRootInsert = true;
  43607. this.isComment = false;
  43608. this.isCloned = false;
  43609. this.isOnce = false;
  43610. this.asyncFactory = asyncFactory;
  43611. this.asyncMeta = undefined;
  43612. this.isAsyncPlaceholder = false;
  43613. };
  43614. var prototypeAccessors = { child: { configurable: true } };
  43615. // DEPRECATED: alias for componentInstance for backwards compat.
  43616. /* istanbul ignore next */
  43617. prototypeAccessors.child.get = function () {
  43618. return this.componentInstance
  43619. };
  43620. Object.defineProperties( VNode.prototype, prototypeAccessors );
  43621. var createEmptyVNode = function (text) {
  43622. if ( text === void 0 ) text = '';
  43623. var node = new VNode();
  43624. node.text = text;
  43625. node.isComment = true;
  43626. return node
  43627. };
  43628. function createTextVNode (val) {
  43629. return new VNode(undefined, undefined, undefined, String(val))
  43630. }
  43631. // optimized shallow clone
  43632. // used for static nodes and slot nodes because they may be reused across
  43633. // multiple renders, cloning them avoids errors when DOM manipulations rely
  43634. // on their elm reference.
  43635. function cloneVNode (vnode) {
  43636. var cloned = new VNode(
  43637. vnode.tag,
  43638. vnode.data,
  43639. // #7975
  43640. // clone children array to avoid mutating original in case of cloning
  43641. // a child.
  43642. vnode.children && vnode.children.slice(),
  43643. vnode.text,
  43644. vnode.elm,
  43645. vnode.context,
  43646. vnode.componentOptions,
  43647. vnode.asyncFactory
  43648. );
  43649. cloned.ns = vnode.ns;
  43650. cloned.isStatic = vnode.isStatic;
  43651. cloned.key = vnode.key;
  43652. cloned.isComment = vnode.isComment;
  43653. cloned.fnContext = vnode.fnContext;
  43654. cloned.fnOptions = vnode.fnOptions;
  43655. cloned.fnScopeId = vnode.fnScopeId;
  43656. cloned.asyncMeta = vnode.asyncMeta;
  43657. cloned.isCloned = true;
  43658. return cloned
  43659. }
  43660. /*
  43661. * not type checking this file because flow doesn't play well with
  43662. * dynamically accessing methods on Array prototype
  43663. */
  43664. var arrayProto = Array.prototype;
  43665. var arrayMethods = Object.create(arrayProto);
  43666. var methodsToPatch = [
  43667. 'push',
  43668. 'pop',
  43669. 'shift',
  43670. 'unshift',
  43671. 'splice',
  43672. 'sort',
  43673. 'reverse'
  43674. ];
  43675. /**
  43676. * Intercept mutating methods and emit events
  43677. */
  43678. methodsToPatch.forEach(function (method) {
  43679. // cache original method
  43680. var original = arrayProto[method];
  43681. def(arrayMethods, method, function mutator () {
  43682. var args = [], len = arguments.length;
  43683. while ( len-- ) args[ len ] = arguments[ len ];
  43684. var result = original.apply(this, args);
  43685. var ob = this.__ob__;
  43686. var inserted;
  43687. switch (method) {
  43688. case 'push':
  43689. case 'unshift':
  43690. inserted = args;
  43691. break
  43692. case 'splice':
  43693. inserted = args.slice(2);
  43694. break
  43695. }
  43696. if (inserted) { ob.observeArray(inserted); }
  43697. // notify change
  43698. ob.dep.notify();
  43699. return result
  43700. });
  43701. });
  43702. /* */
  43703. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  43704. /**
  43705. * In some cases we may want to disable observation inside a component's
  43706. * update computation.
  43707. */
  43708. var shouldObserve = true;
  43709. function toggleObserving (value) {
  43710. shouldObserve = value;
  43711. }
  43712. /**
  43713. * Observer class that is attached to each observed
  43714. * object. Once attached, the observer converts the target
  43715. * object's property keys into getter/setters that
  43716. * collect dependencies and dispatch updates.
  43717. */
  43718. var Observer = function Observer (value) {
  43719. this.value = value;
  43720. this.dep = new Dep();
  43721. this.vmCount = 0;
  43722. def(value, '__ob__', this);
  43723. if (Array.isArray(value)) {
  43724. if (hasProto) {
  43725. protoAugment(value, arrayMethods);
  43726. } else {
  43727. copyAugment(value, arrayMethods, arrayKeys);
  43728. }
  43729. this.observeArray(value);
  43730. } else {
  43731. this.walk(value);
  43732. }
  43733. };
  43734. /**
  43735. * Walk through all properties and convert them into
  43736. * getter/setters. This method should only be called when
  43737. * value type is Object.
  43738. */
  43739. Observer.prototype.walk = function walk (obj) {
  43740. var keys = Object.keys(obj);
  43741. for (var i = 0; i < keys.length; i++) {
  43742. defineReactive$$1(obj, keys[i]);
  43743. }
  43744. };
  43745. /**
  43746. * Observe a list of Array items.
  43747. */
  43748. Observer.prototype.observeArray = function observeArray (items) {
  43749. for (var i = 0, l = items.length; i < l; i++) {
  43750. observe(items[i]);
  43751. }
  43752. };
  43753. // helpers
  43754. /**
  43755. * Augment a target Object or Array by intercepting
  43756. * the prototype chain using __proto__
  43757. */
  43758. function protoAugment (target, src) {
  43759. /* eslint-disable no-proto */
  43760. target.__proto__ = src;
  43761. /* eslint-enable no-proto */
  43762. }
  43763. /**
  43764. * Augment a target Object or Array by defining
  43765. * hidden properties.
  43766. */
  43767. /* istanbul ignore next */
  43768. function copyAugment (target, src, keys) {
  43769. for (var i = 0, l = keys.length; i < l; i++) {
  43770. var key = keys[i];
  43771. def(target, key, src[key]);
  43772. }
  43773. }
  43774. /**
  43775. * Attempt to create an observer instance for a value,
  43776. * returns the new observer if successfully observed,
  43777. * or the existing observer if the value already has one.
  43778. */
  43779. function observe (value, asRootData) {
  43780. if (!isObject(value) || value instanceof VNode) {
  43781. return
  43782. }
  43783. var ob;
  43784. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  43785. ob = value.__ob__;
  43786. } else if (
  43787. shouldObserve &&
  43788. !isServerRendering() &&
  43789. (Array.isArray(value) || isPlainObject(value)) &&
  43790. Object.isExtensible(value) &&
  43791. !value._isVue
  43792. ) {
  43793. ob = new Observer(value);
  43794. }
  43795. if (asRootData && ob) {
  43796. ob.vmCount++;
  43797. }
  43798. return ob
  43799. }
  43800. /**
  43801. * Define a reactive property on an Object.
  43802. */
  43803. function defineReactive$$1 (
  43804. obj,
  43805. key,
  43806. val,
  43807. customSetter,
  43808. shallow
  43809. ) {
  43810. var dep = new Dep();
  43811. var property = Object.getOwnPropertyDescriptor(obj, key);
  43812. if (property && property.configurable === false) {
  43813. return
  43814. }
  43815. // cater for pre-defined getter/setters
  43816. var getter = property && property.get;
  43817. var setter = property && property.set;
  43818. if ((!getter || setter) && arguments.length === 2) {
  43819. val = obj[key];
  43820. }
  43821. var childOb = !shallow && observe(val);
  43822. Object.defineProperty(obj, key, {
  43823. enumerable: true,
  43824. configurable: true,
  43825. get: function reactiveGetter () {
  43826. var value = getter ? getter.call(obj) : val;
  43827. if (Dep.target) {
  43828. dep.depend();
  43829. if (childOb) {
  43830. childOb.dep.depend();
  43831. if (Array.isArray(value)) {
  43832. dependArray(value);
  43833. }
  43834. }
  43835. }
  43836. return value
  43837. },
  43838. set: function reactiveSetter (newVal) {
  43839. var value = getter ? getter.call(obj) : val;
  43840. /* eslint-disable no-self-compare */
  43841. if (newVal === value || (newVal !== newVal && value !== value)) {
  43842. return
  43843. }
  43844. /* eslint-enable no-self-compare */
  43845. if (customSetter) {
  43846. customSetter();
  43847. }
  43848. // #7981: for accessor properties without setter
  43849. if (getter && !setter) { return }
  43850. if (setter) {
  43851. setter.call(obj, newVal);
  43852. } else {
  43853. val = newVal;
  43854. }
  43855. childOb = !shallow && observe(newVal);
  43856. dep.notify();
  43857. }
  43858. });
  43859. }
  43860. /**
  43861. * Set a property on an object. Adds the new property and
  43862. * triggers change notification if the property doesn't
  43863. * already exist.
  43864. */
  43865. function set (target, key, val) {
  43866. if (isUndef(target) || isPrimitive(target)
  43867. ) {
  43868. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  43869. }
  43870. if (Array.isArray(target) && isValidArrayIndex(key)) {
  43871. target.length = Math.max(target.length, key);
  43872. target.splice(key, 1, val);
  43873. return val
  43874. }
  43875. if (key in target && !(key in Object.prototype)) {
  43876. target[key] = val;
  43877. return val
  43878. }
  43879. var ob = (target).__ob__;
  43880. if (target._isVue || (ob && ob.vmCount)) {
  43881. warn(
  43882. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  43883. 'at runtime - declare it upfront in the data option.'
  43884. );
  43885. return val
  43886. }
  43887. if (!ob) {
  43888. target[key] = val;
  43889. return val
  43890. }
  43891. defineReactive$$1(ob.value, key, val);
  43892. ob.dep.notify();
  43893. return val
  43894. }
  43895. /**
  43896. * Delete a property and trigger change if necessary.
  43897. */
  43898. function del (target, key) {
  43899. if (isUndef(target) || isPrimitive(target)
  43900. ) {
  43901. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  43902. }
  43903. if (Array.isArray(target) && isValidArrayIndex(key)) {
  43904. target.splice(key, 1);
  43905. return
  43906. }
  43907. var ob = (target).__ob__;
  43908. if (target._isVue || (ob && ob.vmCount)) {
  43909. warn(
  43910. 'Avoid deleting properties on a Vue instance or its root $data ' +
  43911. '- just set it to null.'
  43912. );
  43913. return
  43914. }
  43915. if (!hasOwn(target, key)) {
  43916. return
  43917. }
  43918. delete target[key];
  43919. if (!ob) {
  43920. return
  43921. }
  43922. ob.dep.notify();
  43923. }
  43924. /**
  43925. * Collect dependencies on array elements when the array is touched, since
  43926. * we cannot intercept array element access like property getters.
  43927. */
  43928. function dependArray (value) {
  43929. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  43930. e = value[i];
  43931. e && e.__ob__ && e.__ob__.dep.depend();
  43932. if (Array.isArray(e)) {
  43933. dependArray(e);
  43934. }
  43935. }
  43936. }
  43937. /* */
  43938. /**
  43939. * Option overwriting strategies are functions that handle
  43940. * how to merge a parent option value and a child option
  43941. * value into the final value.
  43942. */
  43943. var strats = config.optionMergeStrategies;
  43944. /**
  43945. * Options with restrictions
  43946. */
  43947. {
  43948. strats.el = strats.propsData = function (parent, child, vm, key) {
  43949. if (!vm) {
  43950. warn(
  43951. "option \"" + key + "\" can only be used during instance " +
  43952. 'creation with the `new` keyword.'
  43953. );
  43954. }
  43955. return defaultStrat(parent, child)
  43956. };
  43957. }
  43958. /**
  43959. * Helper that recursively merges two data objects together.
  43960. */
  43961. function mergeData (to, from) {
  43962. if (!from) { return to }
  43963. var key, toVal, fromVal;
  43964. var keys = hasSymbol
  43965. ? Reflect.ownKeys(from)
  43966. : Object.keys(from);
  43967. for (var i = 0; i < keys.length; i++) {
  43968. key = keys[i];
  43969. // in case the object is already observed...
  43970. if (key === '__ob__') { continue }
  43971. toVal = to[key];
  43972. fromVal = from[key];
  43973. if (!hasOwn(to, key)) {
  43974. set(to, key, fromVal);
  43975. } else if (
  43976. toVal !== fromVal &&
  43977. isPlainObject(toVal) &&
  43978. isPlainObject(fromVal)
  43979. ) {
  43980. mergeData(toVal, fromVal);
  43981. }
  43982. }
  43983. return to
  43984. }
  43985. /**
  43986. * Data
  43987. */
  43988. function mergeDataOrFn (
  43989. parentVal,
  43990. childVal,
  43991. vm
  43992. ) {
  43993. if (!vm) {
  43994. // in a Vue.extend merge, both should be functions
  43995. if (!childVal) {
  43996. return parentVal
  43997. }
  43998. if (!parentVal) {
  43999. return childVal
  44000. }
  44001. // when parentVal & childVal are both present,
  44002. // we need to return a function that returns the
  44003. // merged result of both functions... no need to
  44004. // check if parentVal is a function here because
  44005. // it has to be a function to pass previous merges.
  44006. return function mergedDataFn () {
  44007. return mergeData(
  44008. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  44009. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  44010. )
  44011. }
  44012. } else {
  44013. return function mergedInstanceDataFn () {
  44014. // instance merge
  44015. var instanceData = typeof childVal === 'function'
  44016. ? childVal.call(vm, vm)
  44017. : childVal;
  44018. var defaultData = typeof parentVal === 'function'
  44019. ? parentVal.call(vm, vm)
  44020. : parentVal;
  44021. if (instanceData) {
  44022. return mergeData(instanceData, defaultData)
  44023. } else {
  44024. return defaultData
  44025. }
  44026. }
  44027. }
  44028. }
  44029. strats.data = function (
  44030. parentVal,
  44031. childVal,
  44032. vm
  44033. ) {
  44034. if (!vm) {
  44035. if (childVal && typeof childVal !== 'function') {
  44036. warn(
  44037. 'The "data" option should be a function ' +
  44038. 'that returns a per-instance value in component ' +
  44039. 'definitions.',
  44040. vm
  44041. );
  44042. return parentVal
  44043. }
  44044. return mergeDataOrFn(parentVal, childVal)
  44045. }
  44046. return mergeDataOrFn(parentVal, childVal, vm)
  44047. };
  44048. /**
  44049. * Hooks and props are merged as arrays.
  44050. */
  44051. function mergeHook (
  44052. parentVal,
  44053. childVal
  44054. ) {
  44055. var res = childVal
  44056. ? parentVal
  44057. ? parentVal.concat(childVal)
  44058. : Array.isArray(childVal)
  44059. ? childVal
  44060. : [childVal]
  44061. : parentVal;
  44062. return res
  44063. ? dedupeHooks(res)
  44064. : res
  44065. }
  44066. function dedupeHooks (hooks) {
  44067. var res = [];
  44068. for (var i = 0; i < hooks.length; i++) {
  44069. if (res.indexOf(hooks[i]) === -1) {
  44070. res.push(hooks[i]);
  44071. }
  44072. }
  44073. return res
  44074. }
  44075. LIFECYCLE_HOOKS.forEach(function (hook) {
  44076. strats[hook] = mergeHook;
  44077. });
  44078. /**
  44079. * Assets
  44080. *
  44081. * When a vm is present (instance creation), we need to do
  44082. * a three-way merge between constructor options, instance
  44083. * options and parent options.
  44084. */
  44085. function mergeAssets (
  44086. parentVal,
  44087. childVal,
  44088. vm,
  44089. key
  44090. ) {
  44091. var res = Object.create(parentVal || null);
  44092. if (childVal) {
  44093. assertObjectType(key, childVal, vm);
  44094. return extend(res, childVal)
  44095. } else {
  44096. return res
  44097. }
  44098. }
  44099. ASSET_TYPES.forEach(function (type) {
  44100. strats[type + 's'] = mergeAssets;
  44101. });
  44102. /**
  44103. * Watchers.
  44104. *
  44105. * Watchers hashes should not overwrite one
  44106. * another, so we merge them as arrays.
  44107. */
  44108. strats.watch = function (
  44109. parentVal,
  44110. childVal,
  44111. vm,
  44112. key
  44113. ) {
  44114. // work around Firefox's Object.prototype.watch...
  44115. if (parentVal === nativeWatch) { parentVal = undefined; }
  44116. if (childVal === nativeWatch) { childVal = undefined; }
  44117. /* istanbul ignore if */
  44118. if (!childVal) { return Object.create(parentVal || null) }
  44119. {
  44120. assertObjectType(key, childVal, vm);
  44121. }
  44122. if (!parentVal) { return childVal }
  44123. var ret = {};
  44124. extend(ret, parentVal);
  44125. for (var key$1 in childVal) {
  44126. var parent = ret[key$1];
  44127. var child = childVal[key$1];
  44128. if (parent && !Array.isArray(parent)) {
  44129. parent = [parent];
  44130. }
  44131. ret[key$1] = parent
  44132. ? parent.concat(child)
  44133. : Array.isArray(child) ? child : [child];
  44134. }
  44135. return ret
  44136. };
  44137. /**
  44138. * Other object hashes.
  44139. */
  44140. strats.props =
  44141. strats.methods =
  44142. strats.inject =
  44143. strats.computed = function (
  44144. parentVal,
  44145. childVal,
  44146. vm,
  44147. key
  44148. ) {
  44149. if (childVal && "development" !== 'production') {
  44150. assertObjectType(key, childVal, vm);
  44151. }
  44152. if (!parentVal) { return childVal }
  44153. var ret = Object.create(null);
  44154. extend(ret, parentVal);
  44155. if (childVal) { extend(ret, childVal); }
  44156. return ret
  44157. };
  44158. strats.provide = mergeDataOrFn;
  44159. /**
  44160. * Default strategy.
  44161. */
  44162. var defaultStrat = function (parentVal, childVal) {
  44163. return childVal === undefined
  44164. ? parentVal
  44165. : childVal
  44166. };
  44167. /**
  44168. * Validate component names
  44169. */
  44170. function checkComponents (options) {
  44171. for (var key in options.components) {
  44172. validateComponentName(key);
  44173. }
  44174. }
  44175. function validateComponentName (name) {
  44176. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  44177. warn(
  44178. 'Invalid component name: "' + name + '". Component names ' +
  44179. 'should conform to valid custom element name in html5 specification.'
  44180. );
  44181. }
  44182. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  44183. warn(
  44184. 'Do not use built-in or reserved HTML elements as component ' +
  44185. 'id: ' + name
  44186. );
  44187. }
  44188. }
  44189. /**
  44190. * Ensure all props option syntax are normalized into the
  44191. * Object-based format.
  44192. */
  44193. function normalizeProps (options, vm) {
  44194. var props = options.props;
  44195. if (!props) { return }
  44196. var res = {};
  44197. var i, val, name;
  44198. if (Array.isArray(props)) {
  44199. i = props.length;
  44200. while (i--) {
  44201. val = props[i];
  44202. if (typeof val === 'string') {
  44203. name = camelize(val);
  44204. res[name] = { type: null };
  44205. } else {
  44206. warn('props must be strings when using array syntax.');
  44207. }
  44208. }
  44209. } else if (isPlainObject(props)) {
  44210. for (var key in props) {
  44211. val = props[key];
  44212. name = camelize(key);
  44213. res[name] = isPlainObject(val)
  44214. ? val
  44215. : { type: val };
  44216. }
  44217. } else {
  44218. warn(
  44219. "Invalid value for option \"props\": expected an Array or an Object, " +
  44220. "but got " + (toRawType(props)) + ".",
  44221. vm
  44222. );
  44223. }
  44224. options.props = res;
  44225. }
  44226. /**
  44227. * Normalize all injections into Object-based format
  44228. */
  44229. function normalizeInject (options, vm) {
  44230. var inject = options.inject;
  44231. if (!inject) { return }
  44232. var normalized = options.inject = {};
  44233. if (Array.isArray(inject)) {
  44234. for (var i = 0; i < inject.length; i++) {
  44235. normalized[inject[i]] = { from: inject[i] };
  44236. }
  44237. } else if (isPlainObject(inject)) {
  44238. for (var key in inject) {
  44239. var val = inject[key];
  44240. normalized[key] = isPlainObject(val)
  44241. ? extend({ from: key }, val)
  44242. : { from: val };
  44243. }
  44244. } else {
  44245. warn(
  44246. "Invalid value for option \"inject\": expected an Array or an Object, " +
  44247. "but got " + (toRawType(inject)) + ".",
  44248. vm
  44249. );
  44250. }
  44251. }
  44252. /**
  44253. * Normalize raw function directives into object format.
  44254. */
  44255. function normalizeDirectives (options) {
  44256. var dirs = options.directives;
  44257. if (dirs) {
  44258. for (var key in dirs) {
  44259. var def$$1 = dirs[key];
  44260. if (typeof def$$1 === 'function') {
  44261. dirs[key] = { bind: def$$1, update: def$$1 };
  44262. }
  44263. }
  44264. }
  44265. }
  44266. function assertObjectType (name, value, vm) {
  44267. if (!isPlainObject(value)) {
  44268. warn(
  44269. "Invalid value for option \"" + name + "\": expected an Object, " +
  44270. "but got " + (toRawType(value)) + ".",
  44271. vm
  44272. );
  44273. }
  44274. }
  44275. /**
  44276. * Merge two option objects into a new one.
  44277. * Core utility used in both instantiation and inheritance.
  44278. */
  44279. function mergeOptions (
  44280. parent,
  44281. child,
  44282. vm
  44283. ) {
  44284. {
  44285. checkComponents(child);
  44286. }
  44287. if (typeof child === 'function') {
  44288. child = child.options;
  44289. }
  44290. normalizeProps(child, vm);
  44291. normalizeInject(child, vm);
  44292. normalizeDirectives(child);
  44293. // Apply extends and mixins on the child options,
  44294. // but only if it is a raw options object that isn't
  44295. // the result of another mergeOptions call.
  44296. // Only merged options has the _base property.
  44297. if (!child._base) {
  44298. if (child.extends) {
  44299. parent = mergeOptions(parent, child.extends, vm);
  44300. }
  44301. if (child.mixins) {
  44302. for (var i = 0, l = child.mixins.length; i < l; i++) {
  44303. parent = mergeOptions(parent, child.mixins[i], vm);
  44304. }
  44305. }
  44306. }
  44307. var options = {};
  44308. var key;
  44309. for (key in parent) {
  44310. mergeField(key);
  44311. }
  44312. for (key in child) {
  44313. if (!hasOwn(parent, key)) {
  44314. mergeField(key);
  44315. }
  44316. }
  44317. function mergeField (key) {
  44318. var strat = strats[key] || defaultStrat;
  44319. options[key] = strat(parent[key], child[key], vm, key);
  44320. }
  44321. return options
  44322. }
  44323. /**
  44324. * Resolve an asset.
  44325. * This function is used because child instances need access
  44326. * to assets defined in its ancestor chain.
  44327. */
  44328. function resolveAsset (
  44329. options,
  44330. type,
  44331. id,
  44332. warnMissing
  44333. ) {
  44334. /* istanbul ignore if */
  44335. if (typeof id !== 'string') {
  44336. return
  44337. }
  44338. var assets = options[type];
  44339. // check local registration variations first
  44340. if (hasOwn(assets, id)) { return assets[id] }
  44341. var camelizedId = camelize(id);
  44342. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  44343. var PascalCaseId = capitalize(camelizedId);
  44344. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  44345. // fallback to prototype chain
  44346. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  44347. if (warnMissing && !res) {
  44348. warn(
  44349. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  44350. options
  44351. );
  44352. }
  44353. return res
  44354. }
  44355. /* */
  44356. function validateProp (
  44357. key,
  44358. propOptions,
  44359. propsData,
  44360. vm
  44361. ) {
  44362. var prop = propOptions[key];
  44363. var absent = !hasOwn(propsData, key);
  44364. var value = propsData[key];
  44365. // boolean casting
  44366. var booleanIndex = getTypeIndex(Boolean, prop.type);
  44367. if (booleanIndex > -1) {
  44368. if (absent && !hasOwn(prop, 'default')) {
  44369. value = false;
  44370. } else if (value === '' || value === hyphenate(key)) {
  44371. // only cast empty string / same name to boolean if
  44372. // boolean has higher priority
  44373. var stringIndex = getTypeIndex(String, prop.type);
  44374. if (stringIndex < 0 || booleanIndex < stringIndex) {
  44375. value = true;
  44376. }
  44377. }
  44378. }
  44379. // check default value
  44380. if (value === undefined) {
  44381. value = getPropDefaultValue(vm, prop, key);
  44382. // since the default value is a fresh copy,
  44383. // make sure to observe it.
  44384. var prevShouldObserve = shouldObserve;
  44385. toggleObserving(true);
  44386. observe(value);
  44387. toggleObserving(prevShouldObserve);
  44388. }
  44389. {
  44390. assertProp(prop, key, value, vm, absent);
  44391. }
  44392. return value
  44393. }
  44394. /**
  44395. * Get the default value of a prop.
  44396. */
  44397. function getPropDefaultValue (vm, prop, key) {
  44398. // no default, return undefined
  44399. if (!hasOwn(prop, 'default')) {
  44400. return undefined
  44401. }
  44402. var def = prop.default;
  44403. // warn against non-factory defaults for Object & Array
  44404. if (isObject(def)) {
  44405. warn(
  44406. 'Invalid default value for prop "' + key + '": ' +
  44407. 'Props with type Object/Array must use a factory function ' +
  44408. 'to return the default value.',
  44409. vm
  44410. );
  44411. }
  44412. // the raw prop value was also undefined from previous render,
  44413. // return previous default value to avoid unnecessary watcher trigger
  44414. if (vm && vm.$options.propsData &&
  44415. vm.$options.propsData[key] === undefined &&
  44416. vm._props[key] !== undefined
  44417. ) {
  44418. return vm._props[key]
  44419. }
  44420. // call factory function for non-Function types
  44421. // a value is Function if its prototype is function even across different execution context
  44422. return typeof def === 'function' && getType(prop.type) !== 'Function'
  44423. ? def.call(vm)
  44424. : def
  44425. }
  44426. /**
  44427. * Assert whether a prop is valid.
  44428. */
  44429. function assertProp (
  44430. prop,
  44431. name,
  44432. value,
  44433. vm,
  44434. absent
  44435. ) {
  44436. if (prop.required && absent) {
  44437. warn(
  44438. 'Missing required prop: "' + name + '"',
  44439. vm
  44440. );
  44441. return
  44442. }
  44443. if (value == null && !prop.required) {
  44444. return
  44445. }
  44446. var type = prop.type;
  44447. var valid = !type || type === true;
  44448. var expectedTypes = [];
  44449. if (type) {
  44450. if (!Array.isArray(type)) {
  44451. type = [type];
  44452. }
  44453. for (var i = 0; i < type.length && !valid; i++) {
  44454. var assertedType = assertType(value, type[i]);
  44455. expectedTypes.push(assertedType.expectedType || '');
  44456. valid = assertedType.valid;
  44457. }
  44458. }
  44459. if (!valid) {
  44460. warn(
  44461. getInvalidTypeMessage(name, value, expectedTypes),
  44462. vm
  44463. );
  44464. return
  44465. }
  44466. var validator = prop.validator;
  44467. if (validator) {
  44468. if (!validator(value)) {
  44469. warn(
  44470. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  44471. vm
  44472. );
  44473. }
  44474. }
  44475. }
  44476. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  44477. function assertType (value, type) {
  44478. var valid;
  44479. var expectedType = getType(type);
  44480. if (simpleCheckRE.test(expectedType)) {
  44481. var t = typeof value;
  44482. valid = t === expectedType.toLowerCase();
  44483. // for primitive wrapper objects
  44484. if (!valid && t === 'object') {
  44485. valid = value instanceof type;
  44486. }
  44487. } else if (expectedType === 'Object') {
  44488. valid = isPlainObject(value);
  44489. } else if (expectedType === 'Array') {
  44490. valid = Array.isArray(value);
  44491. } else {
  44492. valid = value instanceof type;
  44493. }
  44494. return {
  44495. valid: valid,
  44496. expectedType: expectedType
  44497. }
  44498. }
  44499. /**
  44500. * Use function string name to check built-in types,
  44501. * because a simple equality check will fail when running
  44502. * across different vms / iframes.
  44503. */
  44504. function getType (fn) {
  44505. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  44506. return match ? match[1] : ''
  44507. }
  44508. function isSameType (a, b) {
  44509. return getType(a) === getType(b)
  44510. }
  44511. function getTypeIndex (type, expectedTypes) {
  44512. if (!Array.isArray(expectedTypes)) {
  44513. return isSameType(expectedTypes, type) ? 0 : -1
  44514. }
  44515. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  44516. if (isSameType(expectedTypes[i], type)) {
  44517. return i
  44518. }
  44519. }
  44520. return -1
  44521. }
  44522. function getInvalidTypeMessage (name, value, expectedTypes) {
  44523. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  44524. " Expected " + (expectedTypes.map(capitalize).join(', '));
  44525. var expectedType = expectedTypes[0];
  44526. var receivedType = toRawType(value);
  44527. var expectedValue = styleValue(value, expectedType);
  44528. var receivedValue = styleValue(value, receivedType);
  44529. // check if we need to specify expected value
  44530. if (expectedTypes.length === 1 &&
  44531. isExplicable(expectedType) &&
  44532. !isBoolean(expectedType, receivedType)) {
  44533. message += " with value " + expectedValue;
  44534. }
  44535. message += ", got " + receivedType + " ";
  44536. // check if we need to specify received value
  44537. if (isExplicable(receivedType)) {
  44538. message += "with value " + receivedValue + ".";
  44539. }
  44540. return message
  44541. }
  44542. function styleValue (value, type) {
  44543. if (type === 'String') {
  44544. return ("\"" + value + "\"")
  44545. } else if (type === 'Number') {
  44546. return ("" + (Number(value)))
  44547. } else {
  44548. return ("" + value)
  44549. }
  44550. }
  44551. function isExplicable (value) {
  44552. var explicitTypes = ['string', 'number', 'boolean'];
  44553. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  44554. }
  44555. function isBoolean () {
  44556. var args = [], len = arguments.length;
  44557. while ( len-- ) args[ len ] = arguments[ len ];
  44558. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  44559. }
  44560. /* */
  44561. function handleError (err, vm, info) {
  44562. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  44563. // See: https://github.com/vuejs/vuex/issues/1505
  44564. pushTarget();
  44565. try {
  44566. if (vm) {
  44567. var cur = vm;
  44568. while ((cur = cur.$parent)) {
  44569. var hooks = cur.$options.errorCaptured;
  44570. if (hooks) {
  44571. for (var i = 0; i < hooks.length; i++) {
  44572. try {
  44573. var capture = hooks[i].call(cur, err, vm, info) === false;
  44574. if (capture) { return }
  44575. } catch (e) {
  44576. globalHandleError(e, cur, 'errorCaptured hook');
  44577. }
  44578. }
  44579. }
  44580. }
  44581. }
  44582. globalHandleError(err, vm, info);
  44583. } finally {
  44584. popTarget();
  44585. }
  44586. }
  44587. function invokeWithErrorHandling (
  44588. handler,
  44589. context,
  44590. args,
  44591. vm,
  44592. info
  44593. ) {
  44594. var res;
  44595. try {
  44596. res = args ? handler.apply(context, args) : handler.call(context);
  44597. if (res && !res._isVue && isPromise(res) && !res._handled) {
  44598. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  44599. // issue #9511
  44600. // avoid catch triggering multiple times when nested calls
  44601. res._handled = true;
  44602. }
  44603. } catch (e) {
  44604. handleError(e, vm, info);
  44605. }
  44606. return res
  44607. }
  44608. function globalHandleError (err, vm, info) {
  44609. if (config.errorHandler) {
  44610. try {
  44611. return config.errorHandler.call(null, err, vm, info)
  44612. } catch (e) {
  44613. // if the user intentionally throws the original error in the handler,
  44614. // do not log it twice
  44615. if (e !== err) {
  44616. logError(e, null, 'config.errorHandler');
  44617. }
  44618. }
  44619. }
  44620. logError(err, vm, info);
  44621. }
  44622. function logError (err, vm, info) {
  44623. {
  44624. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  44625. }
  44626. /* istanbul ignore else */
  44627. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  44628. console.error(err);
  44629. } else {
  44630. throw err
  44631. }
  44632. }
  44633. /* */
  44634. var isUsingMicroTask = false;
  44635. var callbacks = [];
  44636. var pending = false;
  44637. function flushCallbacks () {
  44638. pending = false;
  44639. var copies = callbacks.slice(0);
  44640. callbacks.length = 0;
  44641. for (var i = 0; i < copies.length; i++) {
  44642. copies[i]();
  44643. }
  44644. }
  44645. // Here we have async deferring wrappers using microtasks.
  44646. // In 2.5 we used (macro) tasks (in combination with microtasks).
  44647. // However, it has subtle problems when state is changed right before repaint
  44648. // (e.g. #6813, out-in transitions).
  44649. // Also, using (macro) tasks in event handler would cause some weird behaviors
  44650. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  44651. // So we now use microtasks everywhere, again.
  44652. // A major drawback of this tradeoff is that there are some scenarios
  44653. // where microtasks have too high a priority and fire in between supposedly
  44654. // sequential events (e.g. #4521, #6690, which have workarounds)
  44655. // or even between bubbling of the same event (#6566).
  44656. var timerFunc;
  44657. // The nextTick behavior leverages the microtask queue, which can be accessed
  44658. // via either native Promise.then or MutationObserver.
  44659. // MutationObserver has wider support, however it is seriously bugged in
  44660. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  44661. // completely stops working after triggering a few times... so, if native
  44662. // Promise is available, we will use it:
  44663. /* istanbul ignore next, $flow-disable-line */
  44664. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  44665. var p = Promise.resolve();
  44666. timerFunc = function () {
  44667. p.then(flushCallbacks);
  44668. // In problematic UIWebViews, Promise.then doesn't completely break, but
  44669. // it can get stuck in a weird state where callbacks are pushed into the
  44670. // microtask queue but the queue isn't being flushed, until the browser
  44671. // needs to do some other work, e.g. handle a timer. Therefore we can
  44672. // "force" the microtask queue to be flushed by adding an empty timer.
  44673. if (isIOS) { setTimeout(noop); }
  44674. };
  44675. isUsingMicroTask = true;
  44676. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  44677. isNative(MutationObserver) ||
  44678. // PhantomJS and iOS 7.x
  44679. MutationObserver.toString() === '[object MutationObserverConstructor]'
  44680. )) {
  44681. // Use MutationObserver where native Promise is not available,
  44682. // e.g. PhantomJS, iOS7, Android 4.4
  44683. // (#6466 MutationObserver is unreliable in IE11)
  44684. var counter = 1;
  44685. var observer = new MutationObserver(flushCallbacks);
  44686. var textNode = document.createTextNode(String(counter));
  44687. observer.observe(textNode, {
  44688. characterData: true
  44689. });
  44690. timerFunc = function () {
  44691. counter = (counter + 1) % 2;
  44692. textNode.data = String(counter);
  44693. };
  44694. isUsingMicroTask = true;
  44695. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  44696. // Fallback to setImmediate.
  44697. // Technically it leverages the (macro) task queue,
  44698. // but it is still a better choice than setTimeout.
  44699. timerFunc = function () {
  44700. setImmediate(flushCallbacks);
  44701. };
  44702. } else {
  44703. // Fallback to setTimeout.
  44704. timerFunc = function () {
  44705. setTimeout(flushCallbacks, 0);
  44706. };
  44707. }
  44708. function nextTick (cb, ctx) {
  44709. var _resolve;
  44710. callbacks.push(function () {
  44711. if (cb) {
  44712. try {
  44713. cb.call(ctx);
  44714. } catch (e) {
  44715. handleError(e, ctx, 'nextTick');
  44716. }
  44717. } else if (_resolve) {
  44718. _resolve(ctx);
  44719. }
  44720. });
  44721. if (!pending) {
  44722. pending = true;
  44723. timerFunc();
  44724. }
  44725. // $flow-disable-line
  44726. if (!cb && typeof Promise !== 'undefined') {
  44727. return new Promise(function (resolve) {
  44728. _resolve = resolve;
  44729. })
  44730. }
  44731. }
  44732. /* */
  44733. var mark;
  44734. var measure;
  44735. {
  44736. var perf = inBrowser && window.performance;
  44737. /* istanbul ignore if */
  44738. if (
  44739. perf &&
  44740. perf.mark &&
  44741. perf.measure &&
  44742. perf.clearMarks &&
  44743. perf.clearMeasures
  44744. ) {
  44745. mark = function (tag) { return perf.mark(tag); };
  44746. measure = function (name, startTag, endTag) {
  44747. perf.measure(name, startTag, endTag);
  44748. perf.clearMarks(startTag);
  44749. perf.clearMarks(endTag);
  44750. // perf.clearMeasures(name)
  44751. };
  44752. }
  44753. }
  44754. /* not type checking this file because flow doesn't play well with Proxy */
  44755. var initProxy;
  44756. {
  44757. var allowedGlobals = makeMap(
  44758. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  44759. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  44760. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  44761. 'require' // for Webpack/Browserify
  44762. );
  44763. var warnNonPresent = function (target, key) {
  44764. warn(
  44765. "Property or method \"" + key + "\" is not defined on the instance but " +
  44766. 'referenced during render. Make sure that this property is reactive, ' +
  44767. 'either in the data option, or for class-based components, by ' +
  44768. 'initializing the property. ' +
  44769. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  44770. target
  44771. );
  44772. };
  44773. var warnReservedPrefix = function (target, key) {
  44774. warn(
  44775. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  44776. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  44777. 'prevent conflicts with Vue internals. ' +
  44778. 'See: https://vuejs.org/v2/api/#data',
  44779. target
  44780. );
  44781. };
  44782. var hasProxy =
  44783. typeof Proxy !== 'undefined' && isNative(Proxy);
  44784. if (hasProxy) {
  44785. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  44786. config.keyCodes = new Proxy(config.keyCodes, {
  44787. set: function set (target, key, value) {
  44788. if (isBuiltInModifier(key)) {
  44789. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  44790. return false
  44791. } else {
  44792. target[key] = value;
  44793. return true
  44794. }
  44795. }
  44796. });
  44797. }
  44798. var hasHandler = {
  44799. has: function has (target, key) {
  44800. var has = key in target;
  44801. var isAllowed = allowedGlobals(key) ||
  44802. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  44803. if (!has && !isAllowed) {
  44804. if (key in target.$data) { warnReservedPrefix(target, key); }
  44805. else { warnNonPresent(target, key); }
  44806. }
  44807. return has || !isAllowed
  44808. }
  44809. };
  44810. var getHandler = {
  44811. get: function get (target, key) {
  44812. if (typeof key === 'string' && !(key in target)) {
  44813. if (key in target.$data) { warnReservedPrefix(target, key); }
  44814. else { warnNonPresent(target, key); }
  44815. }
  44816. return target[key]
  44817. }
  44818. };
  44819. initProxy = function initProxy (vm) {
  44820. if (hasProxy) {
  44821. // determine which proxy handler to use
  44822. var options = vm.$options;
  44823. var handlers = options.render && options.render._withStripped
  44824. ? getHandler
  44825. : hasHandler;
  44826. vm._renderProxy = new Proxy(vm, handlers);
  44827. } else {
  44828. vm._renderProxy = vm;
  44829. }
  44830. };
  44831. }
  44832. /* */
  44833. var seenObjects = new _Set();
  44834. /**
  44835. * Recursively traverse an object to evoke all converted
  44836. * getters, so that every nested property inside the object
  44837. * is collected as a "deep" dependency.
  44838. */
  44839. function traverse (val) {
  44840. _traverse(val, seenObjects);
  44841. seenObjects.clear();
  44842. }
  44843. function _traverse (val, seen) {
  44844. var i, keys;
  44845. var isA = Array.isArray(val);
  44846. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  44847. return
  44848. }
  44849. if (val.__ob__) {
  44850. var depId = val.__ob__.dep.id;
  44851. if (seen.has(depId)) {
  44852. return
  44853. }
  44854. seen.add(depId);
  44855. }
  44856. if (isA) {
  44857. i = val.length;
  44858. while (i--) { _traverse(val[i], seen); }
  44859. } else {
  44860. keys = Object.keys(val);
  44861. i = keys.length;
  44862. while (i--) { _traverse(val[keys[i]], seen); }
  44863. }
  44864. }
  44865. /* */
  44866. var normalizeEvent = cached(function (name) {
  44867. var passive = name.charAt(0) === '&';
  44868. name = passive ? name.slice(1) : name;
  44869. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  44870. name = once$$1 ? name.slice(1) : name;
  44871. var capture = name.charAt(0) === '!';
  44872. name = capture ? name.slice(1) : name;
  44873. return {
  44874. name: name,
  44875. once: once$$1,
  44876. capture: capture,
  44877. passive: passive
  44878. }
  44879. });
  44880. function createFnInvoker (fns, vm) {
  44881. function invoker () {
  44882. var arguments$1 = arguments;
  44883. var fns = invoker.fns;
  44884. if (Array.isArray(fns)) {
  44885. var cloned = fns.slice();
  44886. for (var i = 0; i < cloned.length; i++) {
  44887. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  44888. }
  44889. } else {
  44890. // return handler return value for single handlers
  44891. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  44892. }
  44893. }
  44894. invoker.fns = fns;
  44895. return invoker
  44896. }
  44897. function updateListeners (
  44898. on,
  44899. oldOn,
  44900. add,
  44901. remove$$1,
  44902. createOnceHandler,
  44903. vm
  44904. ) {
  44905. var name, def$$1, cur, old, event;
  44906. for (name in on) {
  44907. def$$1 = cur = on[name];
  44908. old = oldOn[name];
  44909. event = normalizeEvent(name);
  44910. if (isUndef(cur)) {
  44911. warn(
  44912. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  44913. vm
  44914. );
  44915. } else if (isUndef(old)) {
  44916. if (isUndef(cur.fns)) {
  44917. cur = on[name] = createFnInvoker(cur, vm);
  44918. }
  44919. if (isTrue(event.once)) {
  44920. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  44921. }
  44922. add(event.name, cur, event.capture, event.passive, event.params);
  44923. } else if (cur !== old) {
  44924. old.fns = cur;
  44925. on[name] = old;
  44926. }
  44927. }
  44928. for (name in oldOn) {
  44929. if (isUndef(on[name])) {
  44930. event = normalizeEvent(name);
  44931. remove$$1(event.name, oldOn[name], event.capture);
  44932. }
  44933. }
  44934. }
  44935. /* */
  44936. function mergeVNodeHook (def, hookKey, hook) {
  44937. if (def instanceof VNode) {
  44938. def = def.data.hook || (def.data.hook = {});
  44939. }
  44940. var invoker;
  44941. var oldHook = def[hookKey];
  44942. function wrappedHook () {
  44943. hook.apply(this, arguments);
  44944. // important: remove merged hook to ensure it's called only once
  44945. // and prevent memory leak
  44946. remove(invoker.fns, wrappedHook);
  44947. }
  44948. if (isUndef(oldHook)) {
  44949. // no existing hook
  44950. invoker = createFnInvoker([wrappedHook]);
  44951. } else {
  44952. /* istanbul ignore if */
  44953. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  44954. // already a merged invoker
  44955. invoker = oldHook;
  44956. invoker.fns.push(wrappedHook);
  44957. } else {
  44958. // existing plain hook
  44959. invoker = createFnInvoker([oldHook, wrappedHook]);
  44960. }
  44961. }
  44962. invoker.merged = true;
  44963. def[hookKey] = invoker;
  44964. }
  44965. /* */
  44966. function extractPropsFromVNodeData (
  44967. data,
  44968. Ctor,
  44969. tag
  44970. ) {
  44971. // we are only extracting raw values here.
  44972. // validation and default values are handled in the child
  44973. // component itself.
  44974. var propOptions = Ctor.options.props;
  44975. if (isUndef(propOptions)) {
  44976. return
  44977. }
  44978. var res = {};
  44979. var attrs = data.attrs;
  44980. var props = data.props;
  44981. if (isDef(attrs) || isDef(props)) {
  44982. for (var key in propOptions) {
  44983. var altKey = hyphenate(key);
  44984. {
  44985. var keyInLowerCase = key.toLowerCase();
  44986. if (
  44987. key !== keyInLowerCase &&
  44988. attrs && hasOwn(attrs, keyInLowerCase)
  44989. ) {
  44990. tip(
  44991. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  44992. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  44993. " \"" + key + "\". " +
  44994. "Note that HTML attributes are case-insensitive and camelCased " +
  44995. "props need to use their kebab-case equivalents when using in-DOM " +
  44996. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  44997. );
  44998. }
  44999. }
  45000. checkProp(res, props, key, altKey, true) ||
  45001. checkProp(res, attrs, key, altKey, false);
  45002. }
  45003. }
  45004. return res
  45005. }
  45006. function checkProp (
  45007. res,
  45008. hash,
  45009. key,
  45010. altKey,
  45011. preserve
  45012. ) {
  45013. if (isDef(hash)) {
  45014. if (hasOwn(hash, key)) {
  45015. res[key] = hash[key];
  45016. if (!preserve) {
  45017. delete hash[key];
  45018. }
  45019. return true
  45020. } else if (hasOwn(hash, altKey)) {
  45021. res[key] = hash[altKey];
  45022. if (!preserve) {
  45023. delete hash[altKey];
  45024. }
  45025. return true
  45026. }
  45027. }
  45028. return false
  45029. }
  45030. /* */
  45031. // The template compiler attempts to minimize the need for normalization by
  45032. // statically analyzing the template at compile time.
  45033. //
  45034. // For plain HTML markup, normalization can be completely skipped because the
  45035. // generated render function is guaranteed to return Array<VNode>. There are
  45036. // two cases where extra normalization is needed:
  45037. // 1. When the children contains components - because a functional component
  45038. // may return an Array instead of a single root. In this case, just a simple
  45039. // normalization is needed - if any child is an Array, we flatten the whole
  45040. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  45041. // because functional components already normalize their own children.
  45042. function simpleNormalizeChildren (children) {
  45043. for (var i = 0; i < children.length; i++) {
  45044. if (Array.isArray(children[i])) {
  45045. return Array.prototype.concat.apply([], children)
  45046. }
  45047. }
  45048. return children
  45049. }
  45050. // 2. When the children contains constructs that always generated nested Arrays,
  45051. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  45052. // with hand-written render functions / JSX. In such cases a full normalization
  45053. // is needed to cater to all possible types of children values.
  45054. function normalizeChildren (children) {
  45055. return isPrimitive(children)
  45056. ? [createTextVNode(children)]
  45057. : Array.isArray(children)
  45058. ? normalizeArrayChildren(children)
  45059. : undefined
  45060. }
  45061. function isTextNode (node) {
  45062. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  45063. }
  45064. function normalizeArrayChildren (children, nestedIndex) {
  45065. var res = [];
  45066. var i, c, lastIndex, last;
  45067. for (i = 0; i < children.length; i++) {
  45068. c = children[i];
  45069. if (isUndef(c) || typeof c === 'boolean') { continue }
  45070. lastIndex = res.length - 1;
  45071. last = res[lastIndex];
  45072. // nested
  45073. if (Array.isArray(c)) {
  45074. if (c.length > 0) {
  45075. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  45076. // merge adjacent text nodes
  45077. if (isTextNode(c[0]) && isTextNode(last)) {
  45078. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  45079. c.shift();
  45080. }
  45081. res.push.apply(res, c);
  45082. }
  45083. } else if (isPrimitive(c)) {
  45084. if (isTextNode(last)) {
  45085. // merge adjacent text nodes
  45086. // this is necessary for SSR hydration because text nodes are
  45087. // essentially merged when rendered to HTML strings
  45088. res[lastIndex] = createTextVNode(last.text + c);
  45089. } else if (c !== '') {
  45090. // convert primitive to vnode
  45091. res.push(createTextVNode(c));
  45092. }
  45093. } else {
  45094. if (isTextNode(c) && isTextNode(last)) {
  45095. // merge adjacent text nodes
  45096. res[lastIndex] = createTextVNode(last.text + c.text);
  45097. } else {
  45098. // default key for nested array children (likely generated by v-for)
  45099. if (isTrue(children._isVList) &&
  45100. isDef(c.tag) &&
  45101. isUndef(c.key) &&
  45102. isDef(nestedIndex)) {
  45103. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  45104. }
  45105. res.push(c);
  45106. }
  45107. }
  45108. }
  45109. return res
  45110. }
  45111. /* */
  45112. function initProvide (vm) {
  45113. var provide = vm.$options.provide;
  45114. if (provide) {
  45115. vm._provided = typeof provide === 'function'
  45116. ? provide.call(vm)
  45117. : provide;
  45118. }
  45119. }
  45120. function initInjections (vm) {
  45121. var result = resolveInject(vm.$options.inject, vm);
  45122. if (result) {
  45123. toggleObserving(false);
  45124. Object.keys(result).forEach(function (key) {
  45125. /* istanbul ignore else */
  45126. {
  45127. defineReactive$$1(vm, key, result[key], function () {
  45128. warn(
  45129. "Avoid mutating an injected value directly since the changes will be " +
  45130. "overwritten whenever the provided component re-renders. " +
  45131. "injection being mutated: \"" + key + "\"",
  45132. vm
  45133. );
  45134. });
  45135. }
  45136. });
  45137. toggleObserving(true);
  45138. }
  45139. }
  45140. function resolveInject (inject, vm) {
  45141. if (inject) {
  45142. // inject is :any because flow is not smart enough to figure out cached
  45143. var result = Object.create(null);
  45144. var keys = hasSymbol
  45145. ? Reflect.ownKeys(inject)
  45146. : Object.keys(inject);
  45147. for (var i = 0; i < keys.length; i++) {
  45148. var key = keys[i];
  45149. // #6574 in case the inject object is observed...
  45150. if (key === '__ob__') { continue }
  45151. var provideKey = inject[key].from;
  45152. var source = vm;
  45153. while (source) {
  45154. if (source._provided && hasOwn(source._provided, provideKey)) {
  45155. result[key] = source._provided[provideKey];
  45156. break
  45157. }
  45158. source = source.$parent;
  45159. }
  45160. if (!source) {
  45161. if ('default' in inject[key]) {
  45162. var provideDefault = inject[key].default;
  45163. result[key] = typeof provideDefault === 'function'
  45164. ? provideDefault.call(vm)
  45165. : provideDefault;
  45166. } else {
  45167. warn(("Injection \"" + key + "\" not found"), vm);
  45168. }
  45169. }
  45170. }
  45171. return result
  45172. }
  45173. }
  45174. /* */
  45175. /**
  45176. * Runtime helper for resolving raw children VNodes into a slot object.
  45177. */
  45178. function resolveSlots (
  45179. children,
  45180. context
  45181. ) {
  45182. if (!children || !children.length) {
  45183. return {}
  45184. }
  45185. var slots = {};
  45186. for (var i = 0, l = children.length; i < l; i++) {
  45187. var child = children[i];
  45188. var data = child.data;
  45189. // remove slot attribute if the node is resolved as a Vue slot node
  45190. if (data && data.attrs && data.attrs.slot) {
  45191. delete data.attrs.slot;
  45192. }
  45193. // named slots should only be respected if the vnode was rendered in the
  45194. // same context.
  45195. if ((child.context === context || child.fnContext === context) &&
  45196. data && data.slot != null
  45197. ) {
  45198. var name = data.slot;
  45199. var slot = (slots[name] || (slots[name] = []));
  45200. if (child.tag === 'template') {
  45201. slot.push.apply(slot, child.children || []);
  45202. } else {
  45203. slot.push(child);
  45204. }
  45205. } else {
  45206. (slots.default || (slots.default = [])).push(child);
  45207. }
  45208. }
  45209. // ignore slots that contains only whitespace
  45210. for (var name$1 in slots) {
  45211. if (slots[name$1].every(isWhitespace)) {
  45212. delete slots[name$1];
  45213. }
  45214. }
  45215. return slots
  45216. }
  45217. function isWhitespace (node) {
  45218. return (node.isComment && !node.asyncFactory) || node.text === ' '
  45219. }
  45220. /* */
  45221. function normalizeScopedSlots (
  45222. slots,
  45223. normalSlots,
  45224. prevSlots
  45225. ) {
  45226. var res;
  45227. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  45228. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  45229. var key = slots && slots.$key;
  45230. if (!slots) {
  45231. res = {};
  45232. } else if (slots._normalized) {
  45233. // fast path 1: child component re-render only, parent did not change
  45234. return slots._normalized
  45235. } else if (
  45236. isStable &&
  45237. prevSlots &&
  45238. prevSlots !== emptyObject &&
  45239. key === prevSlots.$key &&
  45240. !hasNormalSlots &&
  45241. !prevSlots.$hasNormal
  45242. ) {
  45243. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  45244. // only need to normalize once
  45245. return prevSlots
  45246. } else {
  45247. res = {};
  45248. for (var key$1 in slots) {
  45249. if (slots[key$1] && key$1[0] !== '$') {
  45250. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  45251. }
  45252. }
  45253. }
  45254. // expose normal slots on scopedSlots
  45255. for (var key$2 in normalSlots) {
  45256. if (!(key$2 in res)) {
  45257. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  45258. }
  45259. }
  45260. // avoriaz seems to mock a non-extensible $scopedSlots object
  45261. // and when that is passed down this would cause an error
  45262. if (slots && Object.isExtensible(slots)) {
  45263. (slots)._normalized = res;
  45264. }
  45265. def(res, '$stable', isStable);
  45266. def(res, '$key', key);
  45267. def(res, '$hasNormal', hasNormalSlots);
  45268. return res
  45269. }
  45270. function normalizeScopedSlot(normalSlots, key, fn) {
  45271. var normalized = function () {
  45272. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  45273. res = res && typeof res === 'object' && !Array.isArray(res)
  45274. ? [res] // single vnode
  45275. : normalizeChildren(res);
  45276. return res && (
  45277. res.length === 0 ||
  45278. (res.length === 1 && res[0].isComment) // #9658
  45279. ) ? undefined
  45280. : res
  45281. };
  45282. // this is a slot using the new v-slot syntax without scope. although it is
  45283. // compiled as a scoped slot, render fn users would expect it to be present
  45284. // on this.$slots because the usage is semantically a normal slot.
  45285. if (fn.proxy) {
  45286. Object.defineProperty(normalSlots, key, {
  45287. get: normalized,
  45288. enumerable: true,
  45289. configurable: true
  45290. });
  45291. }
  45292. return normalized
  45293. }
  45294. function proxyNormalSlot(slots, key) {
  45295. return function () { return slots[key]; }
  45296. }
  45297. /* */
  45298. /**
  45299. * Runtime helper for rendering v-for lists.
  45300. */
  45301. function renderList (
  45302. val,
  45303. render
  45304. ) {
  45305. var ret, i, l, keys, key;
  45306. if (Array.isArray(val) || typeof val === 'string') {
  45307. ret = new Array(val.length);
  45308. for (i = 0, l = val.length; i < l; i++) {
  45309. ret[i] = render(val[i], i);
  45310. }
  45311. } else if (typeof val === 'number') {
  45312. ret = new Array(val);
  45313. for (i = 0; i < val; i++) {
  45314. ret[i] = render(i + 1, i);
  45315. }
  45316. } else if (isObject(val)) {
  45317. if (hasSymbol && val[Symbol.iterator]) {
  45318. ret = [];
  45319. var iterator = val[Symbol.iterator]();
  45320. var result = iterator.next();
  45321. while (!result.done) {
  45322. ret.push(render(result.value, ret.length));
  45323. result = iterator.next();
  45324. }
  45325. } else {
  45326. keys = Object.keys(val);
  45327. ret = new Array(keys.length);
  45328. for (i = 0, l = keys.length; i < l; i++) {
  45329. key = keys[i];
  45330. ret[i] = render(val[key], key, i);
  45331. }
  45332. }
  45333. }
  45334. if (!isDef(ret)) {
  45335. ret = [];
  45336. }
  45337. (ret)._isVList = true;
  45338. return ret
  45339. }
  45340. /* */
  45341. /**
  45342. * Runtime helper for rendering <slot>
  45343. */
  45344. function renderSlot (
  45345. name,
  45346. fallback,
  45347. props,
  45348. bindObject
  45349. ) {
  45350. var scopedSlotFn = this.$scopedSlots[name];
  45351. var nodes;
  45352. if (scopedSlotFn) { // scoped slot
  45353. props = props || {};
  45354. if (bindObject) {
  45355. if (!isObject(bindObject)) {
  45356. warn(
  45357. 'slot v-bind without argument expects an Object',
  45358. this
  45359. );
  45360. }
  45361. props = extend(extend({}, bindObject), props);
  45362. }
  45363. nodes = scopedSlotFn(props) || fallback;
  45364. } else {
  45365. nodes = this.$slots[name] || fallback;
  45366. }
  45367. var target = props && props.slot;
  45368. if (target) {
  45369. return this.$createElement('template', { slot: target }, nodes)
  45370. } else {
  45371. return nodes
  45372. }
  45373. }
  45374. /* */
  45375. /**
  45376. * Runtime helper for resolving filters
  45377. */
  45378. function resolveFilter (id) {
  45379. return resolveAsset(this.$options, 'filters', id, true) || identity
  45380. }
  45381. /* */
  45382. function isKeyNotMatch (expect, actual) {
  45383. if (Array.isArray(expect)) {
  45384. return expect.indexOf(actual) === -1
  45385. } else {
  45386. return expect !== actual
  45387. }
  45388. }
  45389. /**
  45390. * Runtime helper for checking keyCodes from config.
  45391. * exposed as Vue.prototype._k
  45392. * passing in eventKeyName as last argument separately for backwards compat
  45393. */
  45394. function checkKeyCodes (
  45395. eventKeyCode,
  45396. key,
  45397. builtInKeyCode,
  45398. eventKeyName,
  45399. builtInKeyName
  45400. ) {
  45401. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  45402. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  45403. return isKeyNotMatch(builtInKeyName, eventKeyName)
  45404. } else if (mappedKeyCode) {
  45405. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  45406. } else if (eventKeyName) {
  45407. return hyphenate(eventKeyName) !== key
  45408. }
  45409. }
  45410. /* */
  45411. /**
  45412. * Runtime helper for merging v-bind="object" into a VNode's data.
  45413. */
  45414. function bindObjectProps (
  45415. data,
  45416. tag,
  45417. value,
  45418. asProp,
  45419. isSync
  45420. ) {
  45421. if (value) {
  45422. if (!isObject(value)) {
  45423. warn(
  45424. 'v-bind without argument expects an Object or Array value',
  45425. this
  45426. );
  45427. } else {
  45428. if (Array.isArray(value)) {
  45429. value = toObject(value);
  45430. }
  45431. var hash;
  45432. var loop = function ( key ) {
  45433. if (
  45434. key === 'class' ||
  45435. key === 'style' ||
  45436. isReservedAttribute(key)
  45437. ) {
  45438. hash = data;
  45439. } else {
  45440. var type = data.attrs && data.attrs.type;
  45441. hash = asProp || config.mustUseProp(tag, type, key)
  45442. ? data.domProps || (data.domProps = {})
  45443. : data.attrs || (data.attrs = {});
  45444. }
  45445. var camelizedKey = camelize(key);
  45446. var hyphenatedKey = hyphenate(key);
  45447. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  45448. hash[key] = value[key];
  45449. if (isSync) {
  45450. var on = data.on || (data.on = {});
  45451. on[("update:" + key)] = function ($event) {
  45452. value[key] = $event;
  45453. };
  45454. }
  45455. }
  45456. };
  45457. for (var key in value) loop( key );
  45458. }
  45459. }
  45460. return data
  45461. }
  45462. /* */
  45463. /**
  45464. * Runtime helper for rendering static trees.
  45465. */
  45466. function renderStatic (
  45467. index,
  45468. isInFor
  45469. ) {
  45470. var cached = this._staticTrees || (this._staticTrees = []);
  45471. var tree = cached[index];
  45472. // if has already-rendered static tree and not inside v-for,
  45473. // we can reuse the same tree.
  45474. if (tree && !isInFor) {
  45475. return tree
  45476. }
  45477. // otherwise, render a fresh tree.
  45478. tree = cached[index] = this.$options.staticRenderFns[index].call(
  45479. this._renderProxy,
  45480. null,
  45481. this // for render fns generated for functional component templates
  45482. );
  45483. markStatic(tree, ("__static__" + index), false);
  45484. return tree
  45485. }
  45486. /**
  45487. * Runtime helper for v-once.
  45488. * Effectively it means marking the node as static with a unique key.
  45489. */
  45490. function markOnce (
  45491. tree,
  45492. index,
  45493. key
  45494. ) {
  45495. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  45496. return tree
  45497. }
  45498. function markStatic (
  45499. tree,
  45500. key,
  45501. isOnce
  45502. ) {
  45503. if (Array.isArray(tree)) {
  45504. for (var i = 0; i < tree.length; i++) {
  45505. if (tree[i] && typeof tree[i] !== 'string') {
  45506. markStaticNode(tree[i], (key + "_" + i), isOnce);
  45507. }
  45508. }
  45509. } else {
  45510. markStaticNode(tree, key, isOnce);
  45511. }
  45512. }
  45513. function markStaticNode (node, key, isOnce) {
  45514. node.isStatic = true;
  45515. node.key = key;
  45516. node.isOnce = isOnce;
  45517. }
  45518. /* */
  45519. function bindObjectListeners (data, value) {
  45520. if (value) {
  45521. if (!isPlainObject(value)) {
  45522. warn(
  45523. 'v-on without argument expects an Object value',
  45524. this
  45525. );
  45526. } else {
  45527. var on = data.on = data.on ? extend({}, data.on) : {};
  45528. for (var key in value) {
  45529. var existing = on[key];
  45530. var ours = value[key];
  45531. on[key] = existing ? [].concat(existing, ours) : ours;
  45532. }
  45533. }
  45534. }
  45535. return data
  45536. }
  45537. /* */
  45538. function resolveScopedSlots (
  45539. fns, // see flow/vnode
  45540. res,
  45541. // the following are added in 2.6
  45542. hasDynamicKeys,
  45543. contentHashKey
  45544. ) {
  45545. res = res || { $stable: !hasDynamicKeys };
  45546. for (var i = 0; i < fns.length; i++) {
  45547. var slot = fns[i];
  45548. if (Array.isArray(slot)) {
  45549. resolveScopedSlots(slot, res, hasDynamicKeys);
  45550. } else if (slot) {
  45551. // marker for reverse proxying v-slot without scope on this.$slots
  45552. if (slot.proxy) {
  45553. slot.fn.proxy = true;
  45554. }
  45555. res[slot.key] = slot.fn;
  45556. }
  45557. }
  45558. if (contentHashKey) {
  45559. (res).$key = contentHashKey;
  45560. }
  45561. return res
  45562. }
  45563. /* */
  45564. function bindDynamicKeys (baseObj, values) {
  45565. for (var i = 0; i < values.length; i += 2) {
  45566. var key = values[i];
  45567. if (typeof key === 'string' && key) {
  45568. baseObj[values[i]] = values[i + 1];
  45569. } else if (key !== '' && key !== null) {
  45570. // null is a special value for explicitly removing a binding
  45571. warn(
  45572. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  45573. this
  45574. );
  45575. }
  45576. }
  45577. return baseObj
  45578. }
  45579. // helper to dynamically append modifier runtime markers to event names.
  45580. // ensure only append when value is already string, otherwise it will be cast
  45581. // to string and cause the type check to miss.
  45582. function prependModifier (value, symbol) {
  45583. return typeof value === 'string' ? symbol + value : value
  45584. }
  45585. /* */
  45586. function installRenderHelpers (target) {
  45587. target._o = markOnce;
  45588. target._n = toNumber;
  45589. target._s = toString;
  45590. target._l = renderList;
  45591. target._t = renderSlot;
  45592. target._q = looseEqual;
  45593. target._i = looseIndexOf;
  45594. target._m = renderStatic;
  45595. target._f = resolveFilter;
  45596. target._k = checkKeyCodes;
  45597. target._b = bindObjectProps;
  45598. target._v = createTextVNode;
  45599. target._e = createEmptyVNode;
  45600. target._u = resolveScopedSlots;
  45601. target._g = bindObjectListeners;
  45602. target._d = bindDynamicKeys;
  45603. target._p = prependModifier;
  45604. }
  45605. /* */
  45606. function FunctionalRenderContext (
  45607. data,
  45608. props,
  45609. children,
  45610. parent,
  45611. Ctor
  45612. ) {
  45613. var this$1 = this;
  45614. var options = Ctor.options;
  45615. // ensure the createElement function in functional components
  45616. // gets a unique context - this is necessary for correct named slot check
  45617. var contextVm;
  45618. if (hasOwn(parent, '_uid')) {
  45619. contextVm = Object.create(parent);
  45620. // $flow-disable-line
  45621. contextVm._original = parent;
  45622. } else {
  45623. // the context vm passed in is a functional context as well.
  45624. // in this case we want to make sure we are able to get a hold to the
  45625. // real context instance.
  45626. contextVm = parent;
  45627. // $flow-disable-line
  45628. parent = parent._original;
  45629. }
  45630. var isCompiled = isTrue(options._compiled);
  45631. var needNormalization = !isCompiled;
  45632. this.data = data;
  45633. this.props = props;
  45634. this.children = children;
  45635. this.parent = parent;
  45636. this.listeners = data.on || emptyObject;
  45637. this.injections = resolveInject(options.inject, parent);
  45638. this.slots = function () {
  45639. if (!this$1.$slots) {
  45640. normalizeScopedSlots(
  45641. data.scopedSlots,
  45642. this$1.$slots = resolveSlots(children, parent)
  45643. );
  45644. }
  45645. return this$1.$slots
  45646. };
  45647. Object.defineProperty(this, 'scopedSlots', ({
  45648. enumerable: true,
  45649. get: function get () {
  45650. return normalizeScopedSlots(data.scopedSlots, this.slots())
  45651. }
  45652. }));
  45653. // support for compiled functional template
  45654. if (isCompiled) {
  45655. // exposing $options for renderStatic()
  45656. this.$options = options;
  45657. // pre-resolve slots for renderSlot()
  45658. this.$slots = this.slots();
  45659. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  45660. }
  45661. if (options._scopeId) {
  45662. this._c = function (a, b, c, d) {
  45663. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  45664. if (vnode && !Array.isArray(vnode)) {
  45665. vnode.fnScopeId = options._scopeId;
  45666. vnode.fnContext = parent;
  45667. }
  45668. return vnode
  45669. };
  45670. } else {
  45671. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  45672. }
  45673. }
  45674. installRenderHelpers(FunctionalRenderContext.prototype);
  45675. function createFunctionalComponent (
  45676. Ctor,
  45677. propsData,
  45678. data,
  45679. contextVm,
  45680. children
  45681. ) {
  45682. var options = Ctor.options;
  45683. var props = {};
  45684. var propOptions = options.props;
  45685. if (isDef(propOptions)) {
  45686. for (var key in propOptions) {
  45687. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  45688. }
  45689. } else {
  45690. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  45691. if (isDef(data.props)) { mergeProps(props, data.props); }
  45692. }
  45693. var renderContext = new FunctionalRenderContext(
  45694. data,
  45695. props,
  45696. children,
  45697. contextVm,
  45698. Ctor
  45699. );
  45700. var vnode = options.render.call(null, renderContext._c, renderContext);
  45701. if (vnode instanceof VNode) {
  45702. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  45703. } else if (Array.isArray(vnode)) {
  45704. var vnodes = normalizeChildren(vnode) || [];
  45705. var res = new Array(vnodes.length);
  45706. for (var i = 0; i < vnodes.length; i++) {
  45707. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  45708. }
  45709. return res
  45710. }
  45711. }
  45712. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  45713. // #7817 clone node before setting fnContext, otherwise if the node is reused
  45714. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  45715. // that should not be matched to match.
  45716. var clone = cloneVNode(vnode);
  45717. clone.fnContext = contextVm;
  45718. clone.fnOptions = options;
  45719. {
  45720. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  45721. }
  45722. if (data.slot) {
  45723. (clone.data || (clone.data = {})).slot = data.slot;
  45724. }
  45725. return clone
  45726. }
  45727. function mergeProps (to, from) {
  45728. for (var key in from) {
  45729. to[camelize(key)] = from[key];
  45730. }
  45731. }
  45732. /* */
  45733. /* */
  45734. /* */
  45735. /* */
  45736. // inline hooks to be invoked on component VNodes during patch
  45737. var componentVNodeHooks = {
  45738. init: function init (vnode, hydrating) {
  45739. if (
  45740. vnode.componentInstance &&
  45741. !vnode.componentInstance._isDestroyed &&
  45742. vnode.data.keepAlive
  45743. ) {
  45744. // kept-alive components, treat as a patch
  45745. var mountedNode = vnode; // work around flow
  45746. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  45747. } else {
  45748. var child = vnode.componentInstance = createComponentInstanceForVnode(
  45749. vnode,
  45750. activeInstance
  45751. );
  45752. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  45753. }
  45754. },
  45755. prepatch: function prepatch (oldVnode, vnode) {
  45756. var options = vnode.componentOptions;
  45757. var child = vnode.componentInstance = oldVnode.componentInstance;
  45758. updateChildComponent(
  45759. child,
  45760. options.propsData, // updated props
  45761. options.listeners, // updated listeners
  45762. vnode, // new parent vnode
  45763. options.children // new children
  45764. );
  45765. },
  45766. insert: function insert (vnode) {
  45767. var context = vnode.context;
  45768. var componentInstance = vnode.componentInstance;
  45769. if (!componentInstance._isMounted) {
  45770. componentInstance._isMounted = true;
  45771. callHook(componentInstance, 'mounted');
  45772. }
  45773. if (vnode.data.keepAlive) {
  45774. if (context._isMounted) {
  45775. // vue-router#1212
  45776. // During updates, a kept-alive component's child components may
  45777. // change, so directly walking the tree here may call activated hooks
  45778. // on incorrect children. Instead we push them into a queue which will
  45779. // be processed after the whole patch process ended.
  45780. queueActivatedComponent(componentInstance);
  45781. } else {
  45782. activateChildComponent(componentInstance, true /* direct */);
  45783. }
  45784. }
  45785. },
  45786. destroy: function destroy (vnode) {
  45787. var componentInstance = vnode.componentInstance;
  45788. if (!componentInstance._isDestroyed) {
  45789. if (!vnode.data.keepAlive) {
  45790. componentInstance.$destroy();
  45791. } else {
  45792. deactivateChildComponent(componentInstance, true /* direct */);
  45793. }
  45794. }
  45795. }
  45796. };
  45797. var hooksToMerge = Object.keys(componentVNodeHooks);
  45798. function createComponent (
  45799. Ctor,
  45800. data,
  45801. context,
  45802. children,
  45803. tag
  45804. ) {
  45805. if (isUndef(Ctor)) {
  45806. return
  45807. }
  45808. var baseCtor = context.$options._base;
  45809. // plain options object: turn it into a constructor
  45810. if (isObject(Ctor)) {
  45811. Ctor = baseCtor.extend(Ctor);
  45812. }
  45813. // if at this stage it's not a constructor or an async component factory,
  45814. // reject.
  45815. if (typeof Ctor !== 'function') {
  45816. {
  45817. warn(("Invalid Component definition: " + (String(Ctor))), context);
  45818. }
  45819. return
  45820. }
  45821. // async component
  45822. var asyncFactory;
  45823. if (isUndef(Ctor.cid)) {
  45824. asyncFactory = Ctor;
  45825. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  45826. if (Ctor === undefined) {
  45827. // return a placeholder node for async component, which is rendered
  45828. // as a comment node but preserves all the raw information for the node.
  45829. // the information will be used for async server-rendering and hydration.
  45830. return createAsyncPlaceholder(
  45831. asyncFactory,
  45832. data,
  45833. context,
  45834. children,
  45835. tag
  45836. )
  45837. }
  45838. }
  45839. data = data || {};
  45840. // resolve constructor options in case global mixins are applied after
  45841. // component constructor creation
  45842. resolveConstructorOptions(Ctor);
  45843. // transform component v-model data into props & events
  45844. if (isDef(data.model)) {
  45845. transformModel(Ctor.options, data);
  45846. }
  45847. // extract props
  45848. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  45849. // functional component
  45850. if (isTrue(Ctor.options.functional)) {
  45851. return createFunctionalComponent(Ctor, propsData, data, context, children)
  45852. }
  45853. // extract listeners, since these needs to be treated as
  45854. // child component listeners instead of DOM listeners
  45855. var listeners = data.on;
  45856. // replace with listeners with .native modifier
  45857. // so it gets processed during parent component patch.
  45858. data.on = data.nativeOn;
  45859. if (isTrue(Ctor.options.abstract)) {
  45860. // abstract components do not keep anything
  45861. // other than props & listeners & slot
  45862. // work around flow
  45863. var slot = data.slot;
  45864. data = {};
  45865. if (slot) {
  45866. data.slot = slot;
  45867. }
  45868. }
  45869. // install component management hooks onto the placeholder node
  45870. installComponentHooks(data);
  45871. // return a placeholder vnode
  45872. var name = Ctor.options.name || tag;
  45873. var vnode = new VNode(
  45874. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  45875. data, undefined, undefined, undefined, context,
  45876. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  45877. asyncFactory
  45878. );
  45879. return vnode
  45880. }
  45881. function createComponentInstanceForVnode (
  45882. vnode, // we know it's MountedComponentVNode but flow doesn't
  45883. parent // activeInstance in lifecycle state
  45884. ) {
  45885. var options = {
  45886. _isComponent: true,
  45887. _parentVnode: vnode,
  45888. parent: parent
  45889. };
  45890. // check inline-template render functions
  45891. var inlineTemplate = vnode.data.inlineTemplate;
  45892. if (isDef(inlineTemplate)) {
  45893. options.render = inlineTemplate.render;
  45894. options.staticRenderFns = inlineTemplate.staticRenderFns;
  45895. }
  45896. return new vnode.componentOptions.Ctor(options)
  45897. }
  45898. function installComponentHooks (data) {
  45899. var hooks = data.hook || (data.hook = {});
  45900. for (var i = 0; i < hooksToMerge.length; i++) {
  45901. var key = hooksToMerge[i];
  45902. var existing = hooks[key];
  45903. var toMerge = componentVNodeHooks[key];
  45904. if (existing !== toMerge && !(existing && existing._merged)) {
  45905. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  45906. }
  45907. }
  45908. }
  45909. function mergeHook$1 (f1, f2) {
  45910. var merged = function (a, b) {
  45911. // flow complains about extra args which is why we use any
  45912. f1(a, b);
  45913. f2(a, b);
  45914. };
  45915. merged._merged = true;
  45916. return merged
  45917. }
  45918. // transform component v-model info (value and callback) into
  45919. // prop and event handler respectively.
  45920. function transformModel (options, data) {
  45921. var prop = (options.model && options.model.prop) || 'value';
  45922. var event = (options.model && options.model.event) || 'input'
  45923. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  45924. var on = data.on || (data.on = {});
  45925. var existing = on[event];
  45926. var callback = data.model.callback;
  45927. if (isDef(existing)) {
  45928. if (
  45929. Array.isArray(existing)
  45930. ? existing.indexOf(callback) === -1
  45931. : existing !== callback
  45932. ) {
  45933. on[event] = [callback].concat(existing);
  45934. }
  45935. } else {
  45936. on[event] = callback;
  45937. }
  45938. }
  45939. /* */
  45940. var SIMPLE_NORMALIZE = 1;
  45941. var ALWAYS_NORMALIZE = 2;
  45942. // wrapper function for providing a more flexible interface
  45943. // without getting yelled at by flow
  45944. function createElement (
  45945. context,
  45946. tag,
  45947. data,
  45948. children,
  45949. normalizationType,
  45950. alwaysNormalize
  45951. ) {
  45952. if (Array.isArray(data) || isPrimitive(data)) {
  45953. normalizationType = children;
  45954. children = data;
  45955. data = undefined;
  45956. }
  45957. if (isTrue(alwaysNormalize)) {
  45958. normalizationType = ALWAYS_NORMALIZE;
  45959. }
  45960. return _createElement(context, tag, data, children, normalizationType)
  45961. }
  45962. function _createElement (
  45963. context,
  45964. tag,
  45965. data,
  45966. children,
  45967. normalizationType
  45968. ) {
  45969. if (isDef(data) && isDef((data).__ob__)) {
  45970. warn(
  45971. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  45972. 'Always create fresh vnode data objects in each render!',
  45973. context
  45974. );
  45975. return createEmptyVNode()
  45976. }
  45977. // object syntax in v-bind
  45978. if (isDef(data) && isDef(data.is)) {
  45979. tag = data.is;
  45980. }
  45981. if (!tag) {
  45982. // in case of component :is set to falsy value
  45983. return createEmptyVNode()
  45984. }
  45985. // warn against non-primitive key
  45986. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  45987. ) {
  45988. {
  45989. warn(
  45990. 'Avoid using non-primitive value as key, ' +
  45991. 'use string/number value instead.',
  45992. context
  45993. );
  45994. }
  45995. }
  45996. // support single function children as default scoped slot
  45997. if (Array.isArray(children) &&
  45998. typeof children[0] === 'function'
  45999. ) {
  46000. data = data || {};
  46001. data.scopedSlots = { default: children[0] };
  46002. children.length = 0;
  46003. }
  46004. if (normalizationType === ALWAYS_NORMALIZE) {
  46005. children = normalizeChildren(children);
  46006. } else if (normalizationType === SIMPLE_NORMALIZE) {
  46007. children = simpleNormalizeChildren(children);
  46008. }
  46009. var vnode, ns;
  46010. if (typeof tag === 'string') {
  46011. var Ctor;
  46012. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  46013. if (config.isReservedTag(tag)) {
  46014. // platform built-in elements
  46015. if (isDef(data) && isDef(data.nativeOn)) {
  46016. warn(
  46017. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  46018. context
  46019. );
  46020. }
  46021. vnode = new VNode(
  46022. config.parsePlatformTagName(tag), data, children,
  46023. undefined, undefined, context
  46024. );
  46025. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  46026. // component
  46027. vnode = createComponent(Ctor, data, context, children, tag);
  46028. } else {
  46029. // unknown or unlisted namespaced elements
  46030. // check at runtime because it may get assigned a namespace when its
  46031. // parent normalizes children
  46032. vnode = new VNode(
  46033. tag, data, children,
  46034. undefined, undefined, context
  46035. );
  46036. }
  46037. } else {
  46038. // direct component options / constructor
  46039. vnode = createComponent(tag, data, context, children);
  46040. }
  46041. if (Array.isArray(vnode)) {
  46042. return vnode
  46043. } else if (isDef(vnode)) {
  46044. if (isDef(ns)) { applyNS(vnode, ns); }
  46045. if (isDef(data)) { registerDeepBindings(data); }
  46046. return vnode
  46047. } else {
  46048. return createEmptyVNode()
  46049. }
  46050. }
  46051. function applyNS (vnode, ns, force) {
  46052. vnode.ns = ns;
  46053. if (vnode.tag === 'foreignObject') {
  46054. // use default namespace inside foreignObject
  46055. ns = undefined;
  46056. force = true;
  46057. }
  46058. if (isDef(vnode.children)) {
  46059. for (var i = 0, l = vnode.children.length; i < l; i++) {
  46060. var child = vnode.children[i];
  46061. if (isDef(child.tag) && (
  46062. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  46063. applyNS(child, ns, force);
  46064. }
  46065. }
  46066. }
  46067. }
  46068. // ref #5318
  46069. // necessary to ensure parent re-render when deep bindings like :style and
  46070. // :class are used on slot nodes
  46071. function registerDeepBindings (data) {
  46072. if (isObject(data.style)) {
  46073. traverse(data.style);
  46074. }
  46075. if (isObject(data.class)) {
  46076. traverse(data.class);
  46077. }
  46078. }
  46079. /* */
  46080. function initRender (vm) {
  46081. vm._vnode = null; // the root of the child tree
  46082. vm._staticTrees = null; // v-once cached trees
  46083. var options = vm.$options;
  46084. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  46085. var renderContext = parentVnode && parentVnode.context;
  46086. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  46087. vm.$scopedSlots = emptyObject;
  46088. // bind the createElement fn to this instance
  46089. // so that we get proper render context inside it.
  46090. // args order: tag, data, children, normalizationType, alwaysNormalize
  46091. // internal version is used by render functions compiled from templates
  46092. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  46093. // normalization is always applied for the public version, used in
  46094. // user-written render functions.
  46095. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  46096. // $attrs & $listeners are exposed for easier HOC creation.
  46097. // they need to be reactive so that HOCs using them are always updated
  46098. var parentData = parentVnode && parentVnode.data;
  46099. /* istanbul ignore else */
  46100. {
  46101. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  46102. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  46103. }, true);
  46104. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  46105. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  46106. }, true);
  46107. }
  46108. }
  46109. var currentRenderingInstance = null;
  46110. function renderMixin (Vue) {
  46111. // install runtime convenience helpers
  46112. installRenderHelpers(Vue.prototype);
  46113. Vue.prototype.$nextTick = function (fn) {
  46114. return nextTick(fn, this)
  46115. };
  46116. Vue.prototype._render = function () {
  46117. var vm = this;
  46118. var ref = vm.$options;
  46119. var render = ref.render;
  46120. var _parentVnode = ref._parentVnode;
  46121. if (_parentVnode) {
  46122. vm.$scopedSlots = normalizeScopedSlots(
  46123. _parentVnode.data.scopedSlots,
  46124. vm.$slots,
  46125. vm.$scopedSlots
  46126. );
  46127. }
  46128. // set parent vnode. this allows render functions to have access
  46129. // to the data on the placeholder node.
  46130. vm.$vnode = _parentVnode;
  46131. // render self
  46132. var vnode;
  46133. try {
  46134. // There's no need to maintain a stack because all render fns are called
  46135. // separately from one another. Nested component's render fns are called
  46136. // when parent component is patched.
  46137. currentRenderingInstance = vm;
  46138. vnode = render.call(vm._renderProxy, vm.$createElement);
  46139. } catch (e) {
  46140. handleError(e, vm, "render");
  46141. // return error render result,
  46142. // or previous vnode to prevent render error causing blank component
  46143. /* istanbul ignore else */
  46144. if (vm.$options.renderError) {
  46145. try {
  46146. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  46147. } catch (e) {
  46148. handleError(e, vm, "renderError");
  46149. vnode = vm._vnode;
  46150. }
  46151. } else {
  46152. vnode = vm._vnode;
  46153. }
  46154. } finally {
  46155. currentRenderingInstance = null;
  46156. }
  46157. // if the returned array contains only a single node, allow it
  46158. if (Array.isArray(vnode) && vnode.length === 1) {
  46159. vnode = vnode[0];
  46160. }
  46161. // return empty vnode in case the render function errored out
  46162. if (!(vnode instanceof VNode)) {
  46163. if (Array.isArray(vnode)) {
  46164. warn(
  46165. 'Multiple root nodes returned from render function. Render function ' +
  46166. 'should return a single root node.',
  46167. vm
  46168. );
  46169. }
  46170. vnode = createEmptyVNode();
  46171. }
  46172. // set parent
  46173. vnode.parent = _parentVnode;
  46174. return vnode
  46175. };
  46176. }
  46177. /* */
  46178. function ensureCtor (comp, base) {
  46179. if (
  46180. comp.__esModule ||
  46181. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  46182. ) {
  46183. comp = comp.default;
  46184. }
  46185. return isObject(comp)
  46186. ? base.extend(comp)
  46187. : comp
  46188. }
  46189. function createAsyncPlaceholder (
  46190. factory,
  46191. data,
  46192. context,
  46193. children,
  46194. tag
  46195. ) {
  46196. var node = createEmptyVNode();
  46197. node.asyncFactory = factory;
  46198. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  46199. return node
  46200. }
  46201. function resolveAsyncComponent (
  46202. factory,
  46203. baseCtor
  46204. ) {
  46205. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  46206. return factory.errorComp
  46207. }
  46208. if (isDef(factory.resolved)) {
  46209. return factory.resolved
  46210. }
  46211. var owner = currentRenderingInstance;
  46212. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  46213. // already pending
  46214. factory.owners.push(owner);
  46215. }
  46216. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  46217. return factory.loadingComp
  46218. }
  46219. if (owner && !isDef(factory.owners)) {
  46220. var owners = factory.owners = [owner];
  46221. var sync = true;
  46222. var timerLoading = null;
  46223. var timerTimeout = null
  46224. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  46225. var forceRender = function (renderCompleted) {
  46226. for (var i = 0, l = owners.length; i < l; i++) {
  46227. (owners[i]).$forceUpdate();
  46228. }
  46229. if (renderCompleted) {
  46230. owners.length = 0;
  46231. if (timerLoading !== null) {
  46232. clearTimeout(timerLoading);
  46233. timerLoading = null;
  46234. }
  46235. if (timerTimeout !== null) {
  46236. clearTimeout(timerTimeout);
  46237. timerTimeout = null;
  46238. }
  46239. }
  46240. };
  46241. var resolve = once(function (res) {
  46242. // cache resolved
  46243. factory.resolved = ensureCtor(res, baseCtor);
  46244. // invoke callbacks only if this is not a synchronous resolve
  46245. // (async resolves are shimmed as synchronous during SSR)
  46246. if (!sync) {
  46247. forceRender(true);
  46248. } else {
  46249. owners.length = 0;
  46250. }
  46251. });
  46252. var reject = once(function (reason) {
  46253. warn(
  46254. "Failed to resolve async component: " + (String(factory)) +
  46255. (reason ? ("\nReason: " + reason) : '')
  46256. );
  46257. if (isDef(factory.errorComp)) {
  46258. factory.error = true;
  46259. forceRender(true);
  46260. }
  46261. });
  46262. var res = factory(resolve, reject);
  46263. if (isObject(res)) {
  46264. if (isPromise(res)) {
  46265. // () => Promise
  46266. if (isUndef(factory.resolved)) {
  46267. res.then(resolve, reject);
  46268. }
  46269. } else if (isPromise(res.component)) {
  46270. res.component.then(resolve, reject);
  46271. if (isDef(res.error)) {
  46272. factory.errorComp = ensureCtor(res.error, baseCtor);
  46273. }
  46274. if (isDef(res.loading)) {
  46275. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  46276. if (res.delay === 0) {
  46277. factory.loading = true;
  46278. } else {
  46279. timerLoading = setTimeout(function () {
  46280. timerLoading = null;
  46281. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  46282. factory.loading = true;
  46283. forceRender(false);
  46284. }
  46285. }, res.delay || 200);
  46286. }
  46287. }
  46288. if (isDef(res.timeout)) {
  46289. timerTimeout = setTimeout(function () {
  46290. timerTimeout = null;
  46291. if (isUndef(factory.resolved)) {
  46292. reject(
  46293. "timeout (" + (res.timeout) + "ms)"
  46294. );
  46295. }
  46296. }, res.timeout);
  46297. }
  46298. }
  46299. }
  46300. sync = false;
  46301. // return in case resolved synchronously
  46302. return factory.loading
  46303. ? factory.loadingComp
  46304. : factory.resolved
  46305. }
  46306. }
  46307. /* */
  46308. function isAsyncPlaceholder (node) {
  46309. return node.isComment && node.asyncFactory
  46310. }
  46311. /* */
  46312. function getFirstComponentChild (children) {
  46313. if (Array.isArray(children)) {
  46314. for (var i = 0; i < children.length; i++) {
  46315. var c = children[i];
  46316. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  46317. return c
  46318. }
  46319. }
  46320. }
  46321. }
  46322. /* */
  46323. /* */
  46324. function initEvents (vm) {
  46325. vm._events = Object.create(null);
  46326. vm._hasHookEvent = false;
  46327. // init parent attached events
  46328. var listeners = vm.$options._parentListeners;
  46329. if (listeners) {
  46330. updateComponentListeners(vm, listeners);
  46331. }
  46332. }
  46333. var target;
  46334. function add (event, fn) {
  46335. target.$on(event, fn);
  46336. }
  46337. function remove$1 (event, fn) {
  46338. target.$off(event, fn);
  46339. }
  46340. function createOnceHandler (event, fn) {
  46341. var _target = target;
  46342. return function onceHandler () {
  46343. var res = fn.apply(null, arguments);
  46344. if (res !== null) {
  46345. _target.$off(event, onceHandler);
  46346. }
  46347. }
  46348. }
  46349. function updateComponentListeners (
  46350. vm,
  46351. listeners,
  46352. oldListeners
  46353. ) {
  46354. target = vm;
  46355. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  46356. target = undefined;
  46357. }
  46358. function eventsMixin (Vue) {
  46359. var hookRE = /^hook:/;
  46360. Vue.prototype.$on = function (event, fn) {
  46361. var vm = this;
  46362. if (Array.isArray(event)) {
  46363. for (var i = 0, l = event.length; i < l; i++) {
  46364. vm.$on(event[i], fn);
  46365. }
  46366. } else {
  46367. (vm._events[event] || (vm._events[event] = [])).push(fn);
  46368. // optimize hook:event cost by using a boolean flag marked at registration
  46369. // instead of a hash lookup
  46370. if (hookRE.test(event)) {
  46371. vm._hasHookEvent = true;
  46372. }
  46373. }
  46374. return vm
  46375. };
  46376. Vue.prototype.$once = function (event, fn) {
  46377. var vm = this;
  46378. function on () {
  46379. vm.$off(event, on);
  46380. fn.apply(vm, arguments);
  46381. }
  46382. on.fn = fn;
  46383. vm.$on(event, on);
  46384. return vm
  46385. };
  46386. Vue.prototype.$off = function (event, fn) {
  46387. var vm = this;
  46388. // all
  46389. if (!arguments.length) {
  46390. vm._events = Object.create(null);
  46391. return vm
  46392. }
  46393. // array of events
  46394. if (Array.isArray(event)) {
  46395. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  46396. vm.$off(event[i$1], fn);
  46397. }
  46398. return vm
  46399. }
  46400. // specific event
  46401. var cbs = vm._events[event];
  46402. if (!cbs) {
  46403. return vm
  46404. }
  46405. if (!fn) {
  46406. vm._events[event] = null;
  46407. return vm
  46408. }
  46409. // specific handler
  46410. var cb;
  46411. var i = cbs.length;
  46412. while (i--) {
  46413. cb = cbs[i];
  46414. if (cb === fn || cb.fn === fn) {
  46415. cbs.splice(i, 1);
  46416. break
  46417. }
  46418. }
  46419. return vm
  46420. };
  46421. Vue.prototype.$emit = function (event) {
  46422. var vm = this;
  46423. {
  46424. var lowerCaseEvent = event.toLowerCase();
  46425. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  46426. tip(
  46427. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  46428. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  46429. "Note that HTML attributes are case-insensitive and you cannot use " +
  46430. "v-on to listen to camelCase events when using in-DOM templates. " +
  46431. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  46432. );
  46433. }
  46434. }
  46435. var cbs = vm._events[event];
  46436. if (cbs) {
  46437. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  46438. var args = toArray(arguments, 1);
  46439. var info = "event handler for \"" + event + "\"";
  46440. for (var i = 0, l = cbs.length; i < l; i++) {
  46441. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  46442. }
  46443. }
  46444. return vm
  46445. };
  46446. }
  46447. /* */
  46448. var activeInstance = null;
  46449. var isUpdatingChildComponent = false;
  46450. function setActiveInstance(vm) {
  46451. var prevActiveInstance = activeInstance;
  46452. activeInstance = vm;
  46453. return function () {
  46454. activeInstance = prevActiveInstance;
  46455. }
  46456. }
  46457. function initLifecycle (vm) {
  46458. var options = vm.$options;
  46459. // locate first non-abstract parent
  46460. var parent = options.parent;
  46461. if (parent && !options.abstract) {
  46462. while (parent.$options.abstract && parent.$parent) {
  46463. parent = parent.$parent;
  46464. }
  46465. parent.$children.push(vm);
  46466. }
  46467. vm.$parent = parent;
  46468. vm.$root = parent ? parent.$root : vm;
  46469. vm.$children = [];
  46470. vm.$refs = {};
  46471. vm._watcher = null;
  46472. vm._inactive = null;
  46473. vm._directInactive = false;
  46474. vm._isMounted = false;
  46475. vm._isDestroyed = false;
  46476. vm._isBeingDestroyed = false;
  46477. }
  46478. function lifecycleMixin (Vue) {
  46479. Vue.prototype._update = function (vnode, hydrating) {
  46480. var vm = this;
  46481. var prevEl = vm.$el;
  46482. var prevVnode = vm._vnode;
  46483. var restoreActiveInstance = setActiveInstance(vm);
  46484. vm._vnode = vnode;
  46485. // Vue.prototype.__patch__ is injected in entry points
  46486. // based on the rendering backend used.
  46487. if (!prevVnode) {
  46488. // initial render
  46489. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  46490. } else {
  46491. // updates
  46492. vm.$el = vm.__patch__(prevVnode, vnode);
  46493. }
  46494. restoreActiveInstance();
  46495. // update __vue__ reference
  46496. if (prevEl) {
  46497. prevEl.__vue__ = null;
  46498. }
  46499. if (vm.$el) {
  46500. vm.$el.__vue__ = vm;
  46501. }
  46502. // if parent is an HOC, update its $el as well
  46503. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  46504. vm.$parent.$el = vm.$el;
  46505. }
  46506. // updated hook is called by the scheduler to ensure that children are
  46507. // updated in a parent's updated hook.
  46508. };
  46509. Vue.prototype.$forceUpdate = function () {
  46510. var vm = this;
  46511. if (vm._watcher) {
  46512. vm._watcher.update();
  46513. }
  46514. };
  46515. Vue.prototype.$destroy = function () {
  46516. var vm = this;
  46517. if (vm._isBeingDestroyed) {
  46518. return
  46519. }
  46520. callHook(vm, 'beforeDestroy');
  46521. vm._isBeingDestroyed = true;
  46522. // remove self from parent
  46523. var parent = vm.$parent;
  46524. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  46525. remove(parent.$children, vm);
  46526. }
  46527. // teardown watchers
  46528. if (vm._watcher) {
  46529. vm._watcher.teardown();
  46530. }
  46531. var i = vm._watchers.length;
  46532. while (i--) {
  46533. vm._watchers[i].teardown();
  46534. }
  46535. // remove reference from data ob
  46536. // frozen object may not have observer.
  46537. if (vm._data.__ob__) {
  46538. vm._data.__ob__.vmCount--;
  46539. }
  46540. // call the last hook...
  46541. vm._isDestroyed = true;
  46542. // invoke destroy hooks on current rendered tree
  46543. vm.__patch__(vm._vnode, null);
  46544. // fire destroyed hook
  46545. callHook(vm, 'destroyed');
  46546. // turn off all instance listeners.
  46547. vm.$off();
  46548. // remove __vue__ reference
  46549. if (vm.$el) {
  46550. vm.$el.__vue__ = null;
  46551. }
  46552. // release circular reference (#6759)
  46553. if (vm.$vnode) {
  46554. vm.$vnode.parent = null;
  46555. }
  46556. };
  46557. }
  46558. function mountComponent (
  46559. vm,
  46560. el,
  46561. hydrating
  46562. ) {
  46563. vm.$el = el;
  46564. if (!vm.$options.render) {
  46565. vm.$options.render = createEmptyVNode;
  46566. {
  46567. /* istanbul ignore if */
  46568. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  46569. vm.$options.el || el) {
  46570. warn(
  46571. 'You are using the runtime-only build of Vue where the template ' +
  46572. 'compiler is not available. Either pre-compile the templates into ' +
  46573. 'render functions, or use the compiler-included build.',
  46574. vm
  46575. );
  46576. } else {
  46577. warn(
  46578. 'Failed to mount component: template or render function not defined.',
  46579. vm
  46580. );
  46581. }
  46582. }
  46583. }
  46584. callHook(vm, 'beforeMount');
  46585. var updateComponent;
  46586. /* istanbul ignore if */
  46587. if (config.performance && mark) {
  46588. updateComponent = function () {
  46589. var name = vm._name;
  46590. var id = vm._uid;
  46591. var startTag = "vue-perf-start:" + id;
  46592. var endTag = "vue-perf-end:" + id;
  46593. mark(startTag);
  46594. var vnode = vm._render();
  46595. mark(endTag);
  46596. measure(("vue " + name + " render"), startTag, endTag);
  46597. mark(startTag);
  46598. vm._update(vnode, hydrating);
  46599. mark(endTag);
  46600. measure(("vue " + name + " patch"), startTag, endTag);
  46601. };
  46602. } else {
  46603. updateComponent = function () {
  46604. vm._update(vm._render(), hydrating);
  46605. };
  46606. }
  46607. // we set this to vm._watcher inside the watcher's constructor
  46608. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  46609. // component's mounted hook), which relies on vm._watcher being already defined
  46610. new Watcher(vm, updateComponent, noop, {
  46611. before: function before () {
  46612. if (vm._isMounted && !vm._isDestroyed) {
  46613. callHook(vm, 'beforeUpdate');
  46614. }
  46615. }
  46616. }, true /* isRenderWatcher */);
  46617. hydrating = false;
  46618. // manually mounted instance, call mounted on self
  46619. // mounted is called for render-created child components in its inserted hook
  46620. if (vm.$vnode == null) {
  46621. vm._isMounted = true;
  46622. callHook(vm, 'mounted');
  46623. }
  46624. return vm
  46625. }
  46626. function updateChildComponent (
  46627. vm,
  46628. propsData,
  46629. listeners,
  46630. parentVnode,
  46631. renderChildren
  46632. ) {
  46633. {
  46634. isUpdatingChildComponent = true;
  46635. }
  46636. // determine whether component has slot children
  46637. // we need to do this before overwriting $options._renderChildren.
  46638. // check if there are dynamic scopedSlots (hand-written or compiled but with
  46639. // dynamic slot names). Static scoped slots compiled from template has the
  46640. // "$stable" marker.
  46641. var newScopedSlots = parentVnode.data.scopedSlots;
  46642. var oldScopedSlots = vm.$scopedSlots;
  46643. var hasDynamicScopedSlot = !!(
  46644. (newScopedSlots && !newScopedSlots.$stable) ||
  46645. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  46646. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key)
  46647. );
  46648. // Any static slot children from the parent may have changed during parent's
  46649. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  46650. // update is necessary to ensure correctness.
  46651. var needsForceUpdate = !!(
  46652. renderChildren || // has new static slots
  46653. vm.$options._renderChildren || // has old static slots
  46654. hasDynamicScopedSlot
  46655. );
  46656. vm.$options._parentVnode = parentVnode;
  46657. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  46658. if (vm._vnode) { // update child tree's parent
  46659. vm._vnode.parent = parentVnode;
  46660. }
  46661. vm.$options._renderChildren = renderChildren;
  46662. // update $attrs and $listeners hash
  46663. // these are also reactive so they may trigger child update if the child
  46664. // used them during render
  46665. vm.$attrs = parentVnode.data.attrs || emptyObject;
  46666. vm.$listeners = listeners || emptyObject;
  46667. // update props
  46668. if (propsData && vm.$options.props) {
  46669. toggleObserving(false);
  46670. var props = vm._props;
  46671. var propKeys = vm.$options._propKeys || [];
  46672. for (var i = 0; i < propKeys.length; i++) {
  46673. var key = propKeys[i];
  46674. var propOptions = vm.$options.props; // wtf flow?
  46675. props[key] = validateProp(key, propOptions, propsData, vm);
  46676. }
  46677. toggleObserving(true);
  46678. // keep a copy of raw propsData
  46679. vm.$options.propsData = propsData;
  46680. }
  46681. // update listeners
  46682. listeners = listeners || emptyObject;
  46683. var oldListeners = vm.$options._parentListeners;
  46684. vm.$options._parentListeners = listeners;
  46685. updateComponentListeners(vm, listeners, oldListeners);
  46686. // resolve slots + force update if has children
  46687. if (needsForceUpdate) {
  46688. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  46689. vm.$forceUpdate();
  46690. }
  46691. {
  46692. isUpdatingChildComponent = false;
  46693. }
  46694. }
  46695. function isInInactiveTree (vm) {
  46696. while (vm && (vm = vm.$parent)) {
  46697. if (vm._inactive) { return true }
  46698. }
  46699. return false
  46700. }
  46701. function activateChildComponent (vm, direct) {
  46702. if (direct) {
  46703. vm._directInactive = false;
  46704. if (isInInactiveTree(vm)) {
  46705. return
  46706. }
  46707. } else if (vm._directInactive) {
  46708. return
  46709. }
  46710. if (vm._inactive || vm._inactive === null) {
  46711. vm._inactive = false;
  46712. for (var i = 0; i < vm.$children.length; i++) {
  46713. activateChildComponent(vm.$children[i]);
  46714. }
  46715. callHook(vm, 'activated');
  46716. }
  46717. }
  46718. function deactivateChildComponent (vm, direct) {
  46719. if (direct) {
  46720. vm._directInactive = true;
  46721. if (isInInactiveTree(vm)) {
  46722. return
  46723. }
  46724. }
  46725. if (!vm._inactive) {
  46726. vm._inactive = true;
  46727. for (var i = 0; i < vm.$children.length; i++) {
  46728. deactivateChildComponent(vm.$children[i]);
  46729. }
  46730. callHook(vm, 'deactivated');
  46731. }
  46732. }
  46733. function callHook (vm, hook) {
  46734. // #7573 disable dep collection when invoking lifecycle hooks
  46735. pushTarget();
  46736. var handlers = vm.$options[hook];
  46737. var info = hook + " hook";
  46738. if (handlers) {
  46739. for (var i = 0, j = handlers.length; i < j; i++) {
  46740. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  46741. }
  46742. }
  46743. if (vm._hasHookEvent) {
  46744. vm.$emit('hook:' + hook);
  46745. }
  46746. popTarget();
  46747. }
  46748. /* */
  46749. var MAX_UPDATE_COUNT = 100;
  46750. var queue = [];
  46751. var activatedChildren = [];
  46752. var has = {};
  46753. var circular = {};
  46754. var waiting = false;
  46755. var flushing = false;
  46756. var index = 0;
  46757. /**
  46758. * Reset the scheduler's state.
  46759. */
  46760. function resetSchedulerState () {
  46761. index = queue.length = activatedChildren.length = 0;
  46762. has = {};
  46763. {
  46764. circular = {};
  46765. }
  46766. waiting = flushing = false;
  46767. }
  46768. // Async edge case #6566 requires saving the timestamp when event listeners are
  46769. // attached. However, calling performance.now() has a perf overhead especially
  46770. // if the page has thousands of event listeners. Instead, we take a timestamp
  46771. // every time the scheduler flushes and use that for all event listeners
  46772. // attached during that flush.
  46773. var currentFlushTimestamp = 0;
  46774. // Async edge case fix requires storing an event listener's attach timestamp.
  46775. var getNow = Date.now;
  46776. // Determine what event timestamp the browser is using. Annoyingly, the
  46777. // timestamp can either be hi-res (relative to page load) or low-res
  46778. // (relative to UNIX epoch), so in order to compare time we have to use the
  46779. // same timestamp type when saving the flush timestamp.
  46780. // All IE versions use low-res event timestamps, and have problematic clock
  46781. // implementations (#9632)
  46782. if (inBrowser && !isIE) {
  46783. var performance = window.performance;
  46784. if (
  46785. performance &&
  46786. typeof performance.now === 'function' &&
  46787. getNow() > document.createEvent('Event').timeStamp
  46788. ) {
  46789. // if the event timestamp, although evaluated AFTER the Date.now(), is
  46790. // smaller than it, it means the event is using a hi-res timestamp,
  46791. // and we need to use the hi-res version for event listener timestamps as
  46792. // well.
  46793. getNow = function () { return performance.now(); };
  46794. }
  46795. }
  46796. /**
  46797. * Flush both queues and run the watchers.
  46798. */
  46799. function flushSchedulerQueue () {
  46800. currentFlushTimestamp = getNow();
  46801. flushing = true;
  46802. var watcher, id;
  46803. // Sort queue before flush.
  46804. // This ensures that:
  46805. // 1. Components are updated from parent to child. (because parent is always
  46806. // created before the child)
  46807. // 2. A component's user watchers are run before its render watcher (because
  46808. // user watchers are created before the render watcher)
  46809. // 3. If a component is destroyed during a parent component's watcher run,
  46810. // its watchers can be skipped.
  46811. queue.sort(function (a, b) { return a.id - b.id; });
  46812. // do not cache length because more watchers might be pushed
  46813. // as we run existing watchers
  46814. for (index = 0; index < queue.length; index++) {
  46815. watcher = queue[index];
  46816. if (watcher.before) {
  46817. watcher.before();
  46818. }
  46819. id = watcher.id;
  46820. has[id] = null;
  46821. watcher.run();
  46822. // in dev build, check and stop circular updates.
  46823. if (has[id] != null) {
  46824. circular[id] = (circular[id] || 0) + 1;
  46825. if (circular[id] > MAX_UPDATE_COUNT) {
  46826. warn(
  46827. 'You may have an infinite update loop ' + (
  46828. watcher.user
  46829. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  46830. : "in a component render function."
  46831. ),
  46832. watcher.vm
  46833. );
  46834. break
  46835. }
  46836. }
  46837. }
  46838. // keep copies of post queues before resetting state
  46839. var activatedQueue = activatedChildren.slice();
  46840. var updatedQueue = queue.slice();
  46841. resetSchedulerState();
  46842. // call component updated and activated hooks
  46843. callActivatedHooks(activatedQueue);
  46844. callUpdatedHooks(updatedQueue);
  46845. // devtool hook
  46846. /* istanbul ignore if */
  46847. if (devtools && config.devtools) {
  46848. devtools.emit('flush');
  46849. }
  46850. }
  46851. function callUpdatedHooks (queue) {
  46852. var i = queue.length;
  46853. while (i--) {
  46854. var watcher = queue[i];
  46855. var vm = watcher.vm;
  46856. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  46857. callHook(vm, 'updated');
  46858. }
  46859. }
  46860. }
  46861. /**
  46862. * Queue a kept-alive component that was activated during patch.
  46863. * The queue will be processed after the entire tree has been patched.
  46864. */
  46865. function queueActivatedComponent (vm) {
  46866. // setting _inactive to false here so that a render function can
  46867. // rely on checking whether it's in an inactive tree (e.g. router-view)
  46868. vm._inactive = false;
  46869. activatedChildren.push(vm);
  46870. }
  46871. function callActivatedHooks (queue) {
  46872. for (var i = 0; i < queue.length; i++) {
  46873. queue[i]._inactive = true;
  46874. activateChildComponent(queue[i], true /* true */);
  46875. }
  46876. }
  46877. /**
  46878. * Push a watcher into the watcher queue.
  46879. * Jobs with duplicate IDs will be skipped unless it's
  46880. * pushed when the queue is being flushed.
  46881. */
  46882. function queueWatcher (watcher) {
  46883. var id = watcher.id;
  46884. if (has[id] == null) {
  46885. has[id] = true;
  46886. if (!flushing) {
  46887. queue.push(watcher);
  46888. } else {
  46889. // if already flushing, splice the watcher based on its id
  46890. // if already past its id, it will be run next immediately.
  46891. var i = queue.length - 1;
  46892. while (i > index && queue[i].id > watcher.id) {
  46893. i--;
  46894. }
  46895. queue.splice(i + 1, 0, watcher);
  46896. }
  46897. // queue the flush
  46898. if (!waiting) {
  46899. waiting = true;
  46900. if (!config.async) {
  46901. flushSchedulerQueue();
  46902. return
  46903. }
  46904. nextTick(flushSchedulerQueue);
  46905. }
  46906. }
  46907. }
  46908. /* */
  46909. var uid$2 = 0;
  46910. /**
  46911. * A watcher parses an expression, collects dependencies,
  46912. * and fires callback when the expression value changes.
  46913. * This is used for both the $watch() api and directives.
  46914. */
  46915. var Watcher = function Watcher (
  46916. vm,
  46917. expOrFn,
  46918. cb,
  46919. options,
  46920. isRenderWatcher
  46921. ) {
  46922. this.vm = vm;
  46923. if (isRenderWatcher) {
  46924. vm._watcher = this;
  46925. }
  46926. vm._watchers.push(this);
  46927. // options
  46928. if (options) {
  46929. this.deep = !!options.deep;
  46930. this.user = !!options.user;
  46931. this.lazy = !!options.lazy;
  46932. this.sync = !!options.sync;
  46933. this.before = options.before;
  46934. } else {
  46935. this.deep = this.user = this.lazy = this.sync = false;
  46936. }
  46937. this.cb = cb;
  46938. this.id = ++uid$2; // uid for batching
  46939. this.active = true;
  46940. this.dirty = this.lazy; // for lazy watchers
  46941. this.deps = [];
  46942. this.newDeps = [];
  46943. this.depIds = new _Set();
  46944. this.newDepIds = new _Set();
  46945. this.expression = expOrFn.toString();
  46946. // parse expression for getter
  46947. if (typeof expOrFn === 'function') {
  46948. this.getter = expOrFn;
  46949. } else {
  46950. this.getter = parsePath(expOrFn);
  46951. if (!this.getter) {
  46952. this.getter = noop;
  46953. warn(
  46954. "Failed watching path: \"" + expOrFn + "\" " +
  46955. 'Watcher only accepts simple dot-delimited paths. ' +
  46956. 'For full control, use a function instead.',
  46957. vm
  46958. );
  46959. }
  46960. }
  46961. this.value = this.lazy
  46962. ? undefined
  46963. : this.get();
  46964. };
  46965. /**
  46966. * Evaluate the getter, and re-collect dependencies.
  46967. */
  46968. Watcher.prototype.get = function get () {
  46969. pushTarget(this);
  46970. var value;
  46971. var vm = this.vm;
  46972. try {
  46973. value = this.getter.call(vm, vm);
  46974. } catch (e) {
  46975. if (this.user) {
  46976. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  46977. } else {
  46978. throw e
  46979. }
  46980. } finally {
  46981. // "touch" every property so they are all tracked as
  46982. // dependencies for deep watching
  46983. if (this.deep) {
  46984. traverse(value);
  46985. }
  46986. popTarget();
  46987. this.cleanupDeps();
  46988. }
  46989. return value
  46990. };
  46991. /**
  46992. * Add a dependency to this directive.
  46993. */
  46994. Watcher.prototype.addDep = function addDep (dep) {
  46995. var id = dep.id;
  46996. if (!this.newDepIds.has(id)) {
  46997. this.newDepIds.add(id);
  46998. this.newDeps.push(dep);
  46999. if (!this.depIds.has(id)) {
  47000. dep.addSub(this);
  47001. }
  47002. }
  47003. };
  47004. /**
  47005. * Clean up for dependency collection.
  47006. */
  47007. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  47008. var i = this.deps.length;
  47009. while (i--) {
  47010. var dep = this.deps[i];
  47011. if (!this.newDepIds.has(dep.id)) {
  47012. dep.removeSub(this);
  47013. }
  47014. }
  47015. var tmp = this.depIds;
  47016. this.depIds = this.newDepIds;
  47017. this.newDepIds = tmp;
  47018. this.newDepIds.clear();
  47019. tmp = this.deps;
  47020. this.deps = this.newDeps;
  47021. this.newDeps = tmp;
  47022. this.newDeps.length = 0;
  47023. };
  47024. /**
  47025. * Subscriber interface.
  47026. * Will be called when a dependency changes.
  47027. */
  47028. Watcher.prototype.update = function update () {
  47029. /* istanbul ignore else */
  47030. if (this.lazy) {
  47031. this.dirty = true;
  47032. } else if (this.sync) {
  47033. this.run();
  47034. } else {
  47035. queueWatcher(this);
  47036. }
  47037. };
  47038. /**
  47039. * Scheduler job interface.
  47040. * Will be called by the scheduler.
  47041. */
  47042. Watcher.prototype.run = function run () {
  47043. if (this.active) {
  47044. var value = this.get();
  47045. if (
  47046. value !== this.value ||
  47047. // Deep watchers and watchers on Object/Arrays should fire even
  47048. // when the value is the same, because the value may
  47049. // have mutated.
  47050. isObject(value) ||
  47051. this.deep
  47052. ) {
  47053. // set new value
  47054. var oldValue = this.value;
  47055. this.value = value;
  47056. if (this.user) {
  47057. try {
  47058. this.cb.call(this.vm, value, oldValue);
  47059. } catch (e) {
  47060. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  47061. }
  47062. } else {
  47063. this.cb.call(this.vm, value, oldValue);
  47064. }
  47065. }
  47066. }
  47067. };
  47068. /**
  47069. * Evaluate the value of the watcher.
  47070. * This only gets called for lazy watchers.
  47071. */
  47072. Watcher.prototype.evaluate = function evaluate () {
  47073. this.value = this.get();
  47074. this.dirty = false;
  47075. };
  47076. /**
  47077. * Depend on all deps collected by this watcher.
  47078. */
  47079. Watcher.prototype.depend = function depend () {
  47080. var i = this.deps.length;
  47081. while (i--) {
  47082. this.deps[i].depend();
  47083. }
  47084. };
  47085. /**
  47086. * Remove self from all dependencies' subscriber list.
  47087. */
  47088. Watcher.prototype.teardown = function teardown () {
  47089. if (this.active) {
  47090. // remove self from vm's watcher list
  47091. // this is a somewhat expensive operation so we skip it
  47092. // if the vm is being destroyed.
  47093. if (!this.vm._isBeingDestroyed) {
  47094. remove(this.vm._watchers, this);
  47095. }
  47096. var i = this.deps.length;
  47097. while (i--) {
  47098. this.deps[i].removeSub(this);
  47099. }
  47100. this.active = false;
  47101. }
  47102. };
  47103. /* */
  47104. var sharedPropertyDefinition = {
  47105. enumerable: true,
  47106. configurable: true,
  47107. get: noop,
  47108. set: noop
  47109. };
  47110. function proxy (target, sourceKey, key) {
  47111. sharedPropertyDefinition.get = function proxyGetter () {
  47112. return this[sourceKey][key]
  47113. };
  47114. sharedPropertyDefinition.set = function proxySetter (val) {
  47115. this[sourceKey][key] = val;
  47116. };
  47117. Object.defineProperty(target, key, sharedPropertyDefinition);
  47118. }
  47119. function initState (vm) {
  47120. vm._watchers = [];
  47121. var opts = vm.$options;
  47122. if (opts.props) { initProps(vm, opts.props); }
  47123. if (opts.methods) { initMethods(vm, opts.methods); }
  47124. if (opts.data) {
  47125. initData(vm);
  47126. } else {
  47127. observe(vm._data = {}, true /* asRootData */);
  47128. }
  47129. if (opts.computed) { initComputed(vm, opts.computed); }
  47130. if (opts.watch && opts.watch !== nativeWatch) {
  47131. initWatch(vm, opts.watch);
  47132. }
  47133. }
  47134. function initProps (vm, propsOptions) {
  47135. var propsData = vm.$options.propsData || {};
  47136. var props = vm._props = {};
  47137. // cache prop keys so that future props updates can iterate using Array
  47138. // instead of dynamic object key enumeration.
  47139. var keys = vm.$options._propKeys = [];
  47140. var isRoot = !vm.$parent;
  47141. // root instance props should be converted
  47142. if (!isRoot) {
  47143. toggleObserving(false);
  47144. }
  47145. var loop = function ( key ) {
  47146. keys.push(key);
  47147. var value = validateProp(key, propsOptions, propsData, vm);
  47148. /* istanbul ignore else */
  47149. {
  47150. var hyphenatedKey = hyphenate(key);
  47151. if (isReservedAttribute(hyphenatedKey) ||
  47152. config.isReservedAttr(hyphenatedKey)) {
  47153. warn(
  47154. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  47155. vm
  47156. );
  47157. }
  47158. defineReactive$$1(props, key, value, function () {
  47159. if (!isRoot && !isUpdatingChildComponent) {
  47160. warn(
  47161. "Avoid mutating a prop directly since the value will be " +
  47162. "overwritten whenever the parent component re-renders. " +
  47163. "Instead, use a data or computed property based on the prop's " +
  47164. "value. Prop being mutated: \"" + key + "\"",
  47165. vm
  47166. );
  47167. }
  47168. });
  47169. }
  47170. // static props are already proxied on the component's prototype
  47171. // during Vue.extend(). We only need to proxy props defined at
  47172. // instantiation here.
  47173. if (!(key in vm)) {
  47174. proxy(vm, "_props", key);
  47175. }
  47176. };
  47177. for (var key in propsOptions) loop( key );
  47178. toggleObserving(true);
  47179. }
  47180. function initData (vm) {
  47181. var data = vm.$options.data;
  47182. data = vm._data = typeof data === 'function'
  47183. ? getData(data, vm)
  47184. : data || {};
  47185. if (!isPlainObject(data)) {
  47186. data = {};
  47187. warn(
  47188. 'data functions should return an object:\n' +
  47189. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  47190. vm
  47191. );
  47192. }
  47193. // proxy data on instance
  47194. var keys = Object.keys(data);
  47195. var props = vm.$options.props;
  47196. var methods = vm.$options.methods;
  47197. var i = keys.length;
  47198. while (i--) {
  47199. var key = keys[i];
  47200. {
  47201. if (methods && hasOwn(methods, key)) {
  47202. warn(
  47203. ("Method \"" + key + "\" has already been defined as a data property."),
  47204. vm
  47205. );
  47206. }
  47207. }
  47208. if (props && hasOwn(props, key)) {
  47209. warn(
  47210. "The data property \"" + key + "\" is already declared as a prop. " +
  47211. "Use prop default value instead.",
  47212. vm
  47213. );
  47214. } else if (!isReserved(key)) {
  47215. proxy(vm, "_data", key);
  47216. }
  47217. }
  47218. // observe data
  47219. observe(data, true /* asRootData */);
  47220. }
  47221. function getData (data, vm) {
  47222. // #7573 disable dep collection when invoking data getters
  47223. pushTarget();
  47224. try {
  47225. return data.call(vm, vm)
  47226. } catch (e) {
  47227. handleError(e, vm, "data()");
  47228. return {}
  47229. } finally {
  47230. popTarget();
  47231. }
  47232. }
  47233. var computedWatcherOptions = { lazy: true };
  47234. function initComputed (vm, computed) {
  47235. // $flow-disable-line
  47236. var watchers = vm._computedWatchers = Object.create(null);
  47237. // computed properties are just getters during SSR
  47238. var isSSR = isServerRendering();
  47239. for (var key in computed) {
  47240. var userDef = computed[key];
  47241. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  47242. if (getter == null) {
  47243. warn(
  47244. ("Getter is missing for computed property \"" + key + "\"."),
  47245. vm
  47246. );
  47247. }
  47248. if (!isSSR) {
  47249. // create internal watcher for the computed property.
  47250. watchers[key] = new Watcher(
  47251. vm,
  47252. getter || noop,
  47253. noop,
  47254. computedWatcherOptions
  47255. );
  47256. }
  47257. // component-defined computed properties are already defined on the
  47258. // component prototype. We only need to define computed properties defined
  47259. // at instantiation here.
  47260. if (!(key in vm)) {
  47261. defineComputed(vm, key, userDef);
  47262. } else {
  47263. if (key in vm.$data) {
  47264. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  47265. } else if (vm.$options.props && key in vm.$options.props) {
  47266. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  47267. }
  47268. }
  47269. }
  47270. }
  47271. function defineComputed (
  47272. target,
  47273. key,
  47274. userDef
  47275. ) {
  47276. var shouldCache = !isServerRendering();
  47277. if (typeof userDef === 'function') {
  47278. sharedPropertyDefinition.get = shouldCache
  47279. ? createComputedGetter(key)
  47280. : createGetterInvoker(userDef);
  47281. sharedPropertyDefinition.set = noop;
  47282. } else {
  47283. sharedPropertyDefinition.get = userDef.get
  47284. ? shouldCache && userDef.cache !== false
  47285. ? createComputedGetter(key)
  47286. : createGetterInvoker(userDef.get)
  47287. : noop;
  47288. sharedPropertyDefinition.set = userDef.set || noop;
  47289. }
  47290. if (sharedPropertyDefinition.set === noop) {
  47291. sharedPropertyDefinition.set = function () {
  47292. warn(
  47293. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  47294. this
  47295. );
  47296. };
  47297. }
  47298. Object.defineProperty(target, key, sharedPropertyDefinition);
  47299. }
  47300. function createComputedGetter (key) {
  47301. return function computedGetter () {
  47302. var watcher = this._computedWatchers && this._computedWatchers[key];
  47303. if (watcher) {
  47304. if (watcher.dirty) {
  47305. watcher.evaluate();
  47306. }
  47307. if (Dep.target) {
  47308. watcher.depend();
  47309. }
  47310. return watcher.value
  47311. }
  47312. }
  47313. }
  47314. function createGetterInvoker(fn) {
  47315. return function computedGetter () {
  47316. return fn.call(this, this)
  47317. }
  47318. }
  47319. function initMethods (vm, methods) {
  47320. var props = vm.$options.props;
  47321. for (var key in methods) {
  47322. {
  47323. if (typeof methods[key] !== 'function') {
  47324. warn(
  47325. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  47326. "Did you reference the function correctly?",
  47327. vm
  47328. );
  47329. }
  47330. if (props && hasOwn(props, key)) {
  47331. warn(
  47332. ("Method \"" + key + "\" has already been defined as a prop."),
  47333. vm
  47334. );
  47335. }
  47336. if ((key in vm) && isReserved(key)) {
  47337. warn(
  47338. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  47339. "Avoid defining component methods that start with _ or $."
  47340. );
  47341. }
  47342. }
  47343. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  47344. }
  47345. }
  47346. function initWatch (vm, watch) {
  47347. for (var key in watch) {
  47348. var handler = watch[key];
  47349. if (Array.isArray(handler)) {
  47350. for (var i = 0; i < handler.length; i++) {
  47351. createWatcher(vm, key, handler[i]);
  47352. }
  47353. } else {
  47354. createWatcher(vm, key, handler);
  47355. }
  47356. }
  47357. }
  47358. function createWatcher (
  47359. vm,
  47360. expOrFn,
  47361. handler,
  47362. options
  47363. ) {
  47364. if (isPlainObject(handler)) {
  47365. options = handler;
  47366. handler = handler.handler;
  47367. }
  47368. if (typeof handler === 'string') {
  47369. handler = vm[handler];
  47370. }
  47371. return vm.$watch(expOrFn, handler, options)
  47372. }
  47373. function stateMixin (Vue) {
  47374. // flow somehow has problems with directly declared definition object
  47375. // when using Object.defineProperty, so we have to procedurally build up
  47376. // the object here.
  47377. var dataDef = {};
  47378. dataDef.get = function () { return this._data };
  47379. var propsDef = {};
  47380. propsDef.get = function () { return this._props };
  47381. {
  47382. dataDef.set = function () {
  47383. warn(
  47384. 'Avoid replacing instance root $data. ' +
  47385. 'Use nested data properties instead.',
  47386. this
  47387. );
  47388. };
  47389. propsDef.set = function () {
  47390. warn("$props is readonly.", this);
  47391. };
  47392. }
  47393. Object.defineProperty(Vue.prototype, '$data', dataDef);
  47394. Object.defineProperty(Vue.prototype, '$props', propsDef);
  47395. Vue.prototype.$set = set;
  47396. Vue.prototype.$delete = del;
  47397. Vue.prototype.$watch = function (
  47398. expOrFn,
  47399. cb,
  47400. options
  47401. ) {
  47402. var vm = this;
  47403. if (isPlainObject(cb)) {
  47404. return createWatcher(vm, expOrFn, cb, options)
  47405. }
  47406. options = options || {};
  47407. options.user = true;
  47408. var watcher = new Watcher(vm, expOrFn, cb, options);
  47409. if (options.immediate) {
  47410. try {
  47411. cb.call(vm, watcher.value);
  47412. } catch (error) {
  47413. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  47414. }
  47415. }
  47416. return function unwatchFn () {
  47417. watcher.teardown();
  47418. }
  47419. };
  47420. }
  47421. /* */
  47422. var uid$3 = 0;
  47423. function initMixin (Vue) {
  47424. Vue.prototype._init = function (options) {
  47425. var vm = this;
  47426. // a uid
  47427. vm._uid = uid$3++;
  47428. var startTag, endTag;
  47429. /* istanbul ignore if */
  47430. if (config.performance && mark) {
  47431. startTag = "vue-perf-start:" + (vm._uid);
  47432. endTag = "vue-perf-end:" + (vm._uid);
  47433. mark(startTag);
  47434. }
  47435. // a flag to avoid this being observed
  47436. vm._isVue = true;
  47437. // merge options
  47438. if (options && options._isComponent) {
  47439. // optimize internal component instantiation
  47440. // since dynamic options merging is pretty slow, and none of the
  47441. // internal component options needs special treatment.
  47442. initInternalComponent(vm, options);
  47443. } else {
  47444. vm.$options = mergeOptions(
  47445. resolveConstructorOptions(vm.constructor),
  47446. options || {},
  47447. vm
  47448. );
  47449. }
  47450. /* istanbul ignore else */
  47451. {
  47452. initProxy(vm);
  47453. }
  47454. // expose real self
  47455. vm._self = vm;
  47456. initLifecycle(vm);
  47457. initEvents(vm);
  47458. initRender(vm);
  47459. callHook(vm, 'beforeCreate');
  47460. initInjections(vm); // resolve injections before data/props
  47461. initState(vm);
  47462. initProvide(vm); // resolve provide after data/props
  47463. callHook(vm, 'created');
  47464. /* istanbul ignore if */
  47465. if (config.performance && mark) {
  47466. vm._name = formatComponentName(vm, false);
  47467. mark(endTag);
  47468. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  47469. }
  47470. if (vm.$options.el) {
  47471. vm.$mount(vm.$options.el);
  47472. }
  47473. };
  47474. }
  47475. function initInternalComponent (vm, options) {
  47476. var opts = vm.$options = Object.create(vm.constructor.options);
  47477. // doing this because it's faster than dynamic enumeration.
  47478. var parentVnode = options._parentVnode;
  47479. opts.parent = options.parent;
  47480. opts._parentVnode = parentVnode;
  47481. var vnodeComponentOptions = parentVnode.componentOptions;
  47482. opts.propsData = vnodeComponentOptions.propsData;
  47483. opts._parentListeners = vnodeComponentOptions.listeners;
  47484. opts._renderChildren = vnodeComponentOptions.children;
  47485. opts._componentTag = vnodeComponentOptions.tag;
  47486. if (options.render) {
  47487. opts.render = options.render;
  47488. opts.staticRenderFns = options.staticRenderFns;
  47489. }
  47490. }
  47491. function resolveConstructorOptions (Ctor) {
  47492. var options = Ctor.options;
  47493. if (Ctor.super) {
  47494. var superOptions = resolveConstructorOptions(Ctor.super);
  47495. var cachedSuperOptions = Ctor.superOptions;
  47496. if (superOptions !== cachedSuperOptions) {
  47497. // super option changed,
  47498. // need to resolve new options.
  47499. Ctor.superOptions = superOptions;
  47500. // check if there are any late-modified/attached options (#4976)
  47501. var modifiedOptions = resolveModifiedOptions(Ctor);
  47502. // update base extend options
  47503. if (modifiedOptions) {
  47504. extend(Ctor.extendOptions, modifiedOptions);
  47505. }
  47506. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  47507. if (options.name) {
  47508. options.components[options.name] = Ctor;
  47509. }
  47510. }
  47511. }
  47512. return options
  47513. }
  47514. function resolveModifiedOptions (Ctor) {
  47515. var modified;
  47516. var latest = Ctor.options;
  47517. var sealed = Ctor.sealedOptions;
  47518. for (var key in latest) {
  47519. if (latest[key] !== sealed[key]) {
  47520. if (!modified) { modified = {}; }
  47521. modified[key] = latest[key];
  47522. }
  47523. }
  47524. return modified
  47525. }
  47526. function Vue (options) {
  47527. if (!(this instanceof Vue)
  47528. ) {
  47529. warn('Vue is a constructor and should be called with the `new` keyword');
  47530. }
  47531. this._init(options);
  47532. }
  47533. initMixin(Vue);
  47534. stateMixin(Vue);
  47535. eventsMixin(Vue);
  47536. lifecycleMixin(Vue);
  47537. renderMixin(Vue);
  47538. /* */
  47539. function initUse (Vue) {
  47540. Vue.use = function (plugin) {
  47541. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  47542. if (installedPlugins.indexOf(plugin) > -1) {
  47543. return this
  47544. }
  47545. // additional parameters
  47546. var args = toArray(arguments, 1);
  47547. args.unshift(this);
  47548. if (typeof plugin.install === 'function') {
  47549. plugin.install.apply(plugin, args);
  47550. } else if (typeof plugin === 'function') {
  47551. plugin.apply(null, args);
  47552. }
  47553. installedPlugins.push(plugin);
  47554. return this
  47555. };
  47556. }
  47557. /* */
  47558. function initMixin$1 (Vue) {
  47559. Vue.mixin = function (mixin) {
  47560. this.options = mergeOptions(this.options, mixin);
  47561. return this
  47562. };
  47563. }
  47564. /* */
  47565. function initExtend (Vue) {
  47566. /**
  47567. * Each instance constructor, including Vue, has a unique
  47568. * cid. This enables us to create wrapped "child
  47569. * constructors" for prototypal inheritance and cache them.
  47570. */
  47571. Vue.cid = 0;
  47572. var cid = 1;
  47573. /**
  47574. * Class inheritance
  47575. */
  47576. Vue.extend = function (extendOptions) {
  47577. extendOptions = extendOptions || {};
  47578. var Super = this;
  47579. var SuperId = Super.cid;
  47580. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  47581. if (cachedCtors[SuperId]) {
  47582. return cachedCtors[SuperId]
  47583. }
  47584. var name = extendOptions.name || Super.options.name;
  47585. if (name) {
  47586. validateComponentName(name);
  47587. }
  47588. var Sub = function VueComponent (options) {
  47589. this._init(options);
  47590. };
  47591. Sub.prototype = Object.create(Super.prototype);
  47592. Sub.prototype.constructor = Sub;
  47593. Sub.cid = cid++;
  47594. Sub.options = mergeOptions(
  47595. Super.options,
  47596. extendOptions
  47597. );
  47598. Sub['super'] = Super;
  47599. // For props and computed properties, we define the proxy getters on
  47600. // the Vue instances at extension time, on the extended prototype. This
  47601. // avoids Object.defineProperty calls for each instance created.
  47602. if (Sub.options.props) {
  47603. initProps$1(Sub);
  47604. }
  47605. if (Sub.options.computed) {
  47606. initComputed$1(Sub);
  47607. }
  47608. // allow further extension/mixin/plugin usage
  47609. Sub.extend = Super.extend;
  47610. Sub.mixin = Super.mixin;
  47611. Sub.use = Super.use;
  47612. // create asset registers, so extended classes
  47613. // can have their private assets too.
  47614. ASSET_TYPES.forEach(function (type) {
  47615. Sub[type] = Super[type];
  47616. });
  47617. // enable recursive self-lookup
  47618. if (name) {
  47619. Sub.options.components[name] = Sub;
  47620. }
  47621. // keep a reference to the super options at extension time.
  47622. // later at instantiation we can check if Super's options have
  47623. // been updated.
  47624. Sub.superOptions = Super.options;
  47625. Sub.extendOptions = extendOptions;
  47626. Sub.sealedOptions = extend({}, Sub.options);
  47627. // cache constructor
  47628. cachedCtors[SuperId] = Sub;
  47629. return Sub
  47630. };
  47631. }
  47632. function initProps$1 (Comp) {
  47633. var props = Comp.options.props;
  47634. for (var key in props) {
  47635. proxy(Comp.prototype, "_props", key);
  47636. }
  47637. }
  47638. function initComputed$1 (Comp) {
  47639. var computed = Comp.options.computed;
  47640. for (var key in computed) {
  47641. defineComputed(Comp.prototype, key, computed[key]);
  47642. }
  47643. }
  47644. /* */
  47645. function initAssetRegisters (Vue) {
  47646. /**
  47647. * Create asset registration methods.
  47648. */
  47649. ASSET_TYPES.forEach(function (type) {
  47650. Vue[type] = function (
  47651. id,
  47652. definition
  47653. ) {
  47654. if (!definition) {
  47655. return this.options[type + 's'][id]
  47656. } else {
  47657. /* istanbul ignore if */
  47658. if (type === 'component') {
  47659. validateComponentName(id);
  47660. }
  47661. if (type === 'component' && isPlainObject(definition)) {
  47662. definition.name = definition.name || id;
  47663. definition = this.options._base.extend(definition);
  47664. }
  47665. if (type === 'directive' && typeof definition === 'function') {
  47666. definition = { bind: definition, update: definition };
  47667. }
  47668. this.options[type + 's'][id] = definition;
  47669. return definition
  47670. }
  47671. };
  47672. });
  47673. }
  47674. /* */
  47675. function getComponentName (opts) {
  47676. return opts && (opts.Ctor.options.name || opts.tag)
  47677. }
  47678. function matches (pattern, name) {
  47679. if (Array.isArray(pattern)) {
  47680. return pattern.indexOf(name) > -1
  47681. } else if (typeof pattern === 'string') {
  47682. return pattern.split(',').indexOf(name) > -1
  47683. } else if (isRegExp(pattern)) {
  47684. return pattern.test(name)
  47685. }
  47686. /* istanbul ignore next */
  47687. return false
  47688. }
  47689. function pruneCache (keepAliveInstance, filter) {
  47690. var cache = keepAliveInstance.cache;
  47691. var keys = keepAliveInstance.keys;
  47692. var _vnode = keepAliveInstance._vnode;
  47693. for (var key in cache) {
  47694. var cachedNode = cache[key];
  47695. if (cachedNode) {
  47696. var name = getComponentName(cachedNode.componentOptions);
  47697. if (name && !filter(name)) {
  47698. pruneCacheEntry(cache, key, keys, _vnode);
  47699. }
  47700. }
  47701. }
  47702. }
  47703. function pruneCacheEntry (
  47704. cache,
  47705. key,
  47706. keys,
  47707. current
  47708. ) {
  47709. var cached$$1 = cache[key];
  47710. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  47711. cached$$1.componentInstance.$destroy();
  47712. }
  47713. cache[key] = null;
  47714. remove(keys, key);
  47715. }
  47716. var patternTypes = [String, RegExp, Array];
  47717. var KeepAlive = {
  47718. name: 'keep-alive',
  47719. abstract: true,
  47720. props: {
  47721. include: patternTypes,
  47722. exclude: patternTypes,
  47723. max: [String, Number]
  47724. },
  47725. created: function created () {
  47726. this.cache = Object.create(null);
  47727. this.keys = [];
  47728. },
  47729. destroyed: function destroyed () {
  47730. for (var key in this.cache) {
  47731. pruneCacheEntry(this.cache, key, this.keys);
  47732. }
  47733. },
  47734. mounted: function mounted () {
  47735. var this$1 = this;
  47736. this.$watch('include', function (val) {
  47737. pruneCache(this$1, function (name) { return matches(val, name); });
  47738. });
  47739. this.$watch('exclude', function (val) {
  47740. pruneCache(this$1, function (name) { return !matches(val, name); });
  47741. });
  47742. },
  47743. render: function render () {
  47744. var slot = this.$slots.default;
  47745. var vnode = getFirstComponentChild(slot);
  47746. var componentOptions = vnode && vnode.componentOptions;
  47747. if (componentOptions) {
  47748. // check pattern
  47749. var name = getComponentName(componentOptions);
  47750. var ref = this;
  47751. var include = ref.include;
  47752. var exclude = ref.exclude;
  47753. if (
  47754. // not included
  47755. (include && (!name || !matches(include, name))) ||
  47756. // excluded
  47757. (exclude && name && matches(exclude, name))
  47758. ) {
  47759. return vnode
  47760. }
  47761. var ref$1 = this;
  47762. var cache = ref$1.cache;
  47763. var keys = ref$1.keys;
  47764. var key = vnode.key == null
  47765. // same constructor may get registered as different local components
  47766. // so cid alone is not enough (#3269)
  47767. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  47768. : vnode.key;
  47769. if (cache[key]) {
  47770. vnode.componentInstance = cache[key].componentInstance;
  47771. // make current key freshest
  47772. remove(keys, key);
  47773. keys.push(key);
  47774. } else {
  47775. cache[key] = vnode;
  47776. keys.push(key);
  47777. // prune oldest entry
  47778. if (this.max && keys.length > parseInt(this.max)) {
  47779. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  47780. }
  47781. }
  47782. vnode.data.keepAlive = true;
  47783. }
  47784. return vnode || (slot && slot[0])
  47785. }
  47786. };
  47787. var builtInComponents = {
  47788. KeepAlive: KeepAlive
  47789. };
  47790. /* */
  47791. function initGlobalAPI (Vue) {
  47792. // config
  47793. var configDef = {};
  47794. configDef.get = function () { return config; };
  47795. {
  47796. configDef.set = function () {
  47797. warn(
  47798. 'Do not replace the Vue.config object, set individual fields instead.'
  47799. );
  47800. };
  47801. }
  47802. Object.defineProperty(Vue, 'config', configDef);
  47803. // exposed util methods.
  47804. // NOTE: these are not considered part of the public API - avoid relying on
  47805. // them unless you are aware of the risk.
  47806. Vue.util = {
  47807. warn: warn,
  47808. extend: extend,
  47809. mergeOptions: mergeOptions,
  47810. defineReactive: defineReactive$$1
  47811. };
  47812. Vue.set = set;
  47813. Vue.delete = del;
  47814. Vue.nextTick = nextTick;
  47815. // 2.6 explicit observable API
  47816. Vue.observable = function (obj) {
  47817. observe(obj);
  47818. return obj
  47819. };
  47820. Vue.options = Object.create(null);
  47821. ASSET_TYPES.forEach(function (type) {
  47822. Vue.options[type + 's'] = Object.create(null);
  47823. });
  47824. // this is used to identify the "base" constructor to extend all plain-object
  47825. // components with in Weex's multi-instance scenarios.
  47826. Vue.options._base = Vue;
  47827. extend(Vue.options.components, builtInComponents);
  47828. initUse(Vue);
  47829. initMixin$1(Vue);
  47830. initExtend(Vue);
  47831. initAssetRegisters(Vue);
  47832. }
  47833. initGlobalAPI(Vue);
  47834. Object.defineProperty(Vue.prototype, '$isServer', {
  47835. get: isServerRendering
  47836. });
  47837. Object.defineProperty(Vue.prototype, '$ssrContext', {
  47838. get: function get () {
  47839. /* istanbul ignore next */
  47840. return this.$vnode && this.$vnode.ssrContext
  47841. }
  47842. });
  47843. // expose FunctionalRenderContext for ssr runtime helper installation
  47844. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  47845. value: FunctionalRenderContext
  47846. });
  47847. Vue.version = '2.6.11';
  47848. /* */
  47849. // these are reserved for web because they are directly compiled away
  47850. // during template compilation
  47851. var isReservedAttr = makeMap('style,class');
  47852. // attributes that should be using props for binding
  47853. var acceptValue = makeMap('input,textarea,option,select,progress');
  47854. var mustUseProp = function (tag, type, attr) {
  47855. return (
  47856. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  47857. (attr === 'selected' && tag === 'option') ||
  47858. (attr === 'checked' && tag === 'input') ||
  47859. (attr === 'muted' && tag === 'video')
  47860. )
  47861. };
  47862. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  47863. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  47864. var convertEnumeratedValue = function (key, value) {
  47865. return isFalsyAttrValue(value) || value === 'false'
  47866. ? 'false'
  47867. // allow arbitrary string value for contenteditable
  47868. : key === 'contenteditable' && isValidContentEditableValue(value)
  47869. ? value
  47870. : 'true'
  47871. };
  47872. var isBooleanAttr = makeMap(
  47873. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  47874. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  47875. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  47876. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  47877. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  47878. 'truespeed,typemustmatch,visible'
  47879. );
  47880. var xlinkNS = 'http://www.w3.org/1999/xlink';
  47881. var isXlink = function (name) {
  47882. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  47883. };
  47884. var getXlinkProp = function (name) {
  47885. return isXlink(name) ? name.slice(6, name.length) : ''
  47886. };
  47887. var isFalsyAttrValue = function (val) {
  47888. return val == null || val === false
  47889. };
  47890. /* */
  47891. function genClassForVnode (vnode) {
  47892. var data = vnode.data;
  47893. var parentNode = vnode;
  47894. var childNode = vnode;
  47895. while (isDef(childNode.componentInstance)) {
  47896. childNode = childNode.componentInstance._vnode;
  47897. if (childNode && childNode.data) {
  47898. data = mergeClassData(childNode.data, data);
  47899. }
  47900. }
  47901. while (isDef(parentNode = parentNode.parent)) {
  47902. if (parentNode && parentNode.data) {
  47903. data = mergeClassData(data, parentNode.data);
  47904. }
  47905. }
  47906. return renderClass(data.staticClass, data.class)
  47907. }
  47908. function mergeClassData (child, parent) {
  47909. return {
  47910. staticClass: concat(child.staticClass, parent.staticClass),
  47911. class: isDef(child.class)
  47912. ? [child.class, parent.class]
  47913. : parent.class
  47914. }
  47915. }
  47916. function renderClass (
  47917. staticClass,
  47918. dynamicClass
  47919. ) {
  47920. if (isDef(staticClass) || isDef(dynamicClass)) {
  47921. return concat(staticClass, stringifyClass(dynamicClass))
  47922. }
  47923. /* istanbul ignore next */
  47924. return ''
  47925. }
  47926. function concat (a, b) {
  47927. return a ? b ? (a + ' ' + b) : a : (b || '')
  47928. }
  47929. function stringifyClass (value) {
  47930. if (Array.isArray(value)) {
  47931. return stringifyArray(value)
  47932. }
  47933. if (isObject(value)) {
  47934. return stringifyObject(value)
  47935. }
  47936. if (typeof value === 'string') {
  47937. return value
  47938. }
  47939. /* istanbul ignore next */
  47940. return ''
  47941. }
  47942. function stringifyArray (value) {
  47943. var res = '';
  47944. var stringified;
  47945. for (var i = 0, l = value.length; i < l; i++) {
  47946. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  47947. if (res) { res += ' '; }
  47948. res += stringified;
  47949. }
  47950. }
  47951. return res
  47952. }
  47953. function stringifyObject (value) {
  47954. var res = '';
  47955. for (var key in value) {
  47956. if (value[key]) {
  47957. if (res) { res += ' '; }
  47958. res += key;
  47959. }
  47960. }
  47961. return res
  47962. }
  47963. /* */
  47964. var namespaceMap = {
  47965. svg: 'http://www.w3.org/2000/svg',
  47966. math: 'http://www.w3.org/1998/Math/MathML'
  47967. };
  47968. var isHTMLTag = makeMap(
  47969. 'html,body,base,head,link,meta,style,title,' +
  47970. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  47971. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  47972. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  47973. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  47974. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  47975. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  47976. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  47977. 'output,progress,select,textarea,' +
  47978. 'details,dialog,menu,menuitem,summary,' +
  47979. 'content,element,shadow,template,blockquote,iframe,tfoot'
  47980. );
  47981. // this map is intentionally selective, only covering SVG elements that may
  47982. // contain child elements.
  47983. var isSVG = makeMap(
  47984. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  47985. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  47986. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  47987. true
  47988. );
  47989. var isPreTag = function (tag) { return tag === 'pre'; };
  47990. var isReservedTag = function (tag) {
  47991. return isHTMLTag(tag) || isSVG(tag)
  47992. };
  47993. function getTagNamespace (tag) {
  47994. if (isSVG(tag)) {
  47995. return 'svg'
  47996. }
  47997. // basic support for MathML
  47998. // note it doesn't support other MathML elements being component roots
  47999. if (tag === 'math') {
  48000. return 'math'
  48001. }
  48002. }
  48003. var unknownElementCache = Object.create(null);
  48004. function isUnknownElement (tag) {
  48005. /* istanbul ignore if */
  48006. if (!inBrowser) {
  48007. return true
  48008. }
  48009. if (isReservedTag(tag)) {
  48010. return false
  48011. }
  48012. tag = tag.toLowerCase();
  48013. /* istanbul ignore if */
  48014. if (unknownElementCache[tag] != null) {
  48015. return unknownElementCache[tag]
  48016. }
  48017. var el = document.createElement(tag);
  48018. if (tag.indexOf('-') > -1) {
  48019. // http://stackoverflow.com/a/28210364/1070244
  48020. return (unknownElementCache[tag] = (
  48021. el.constructor === window.HTMLUnknownElement ||
  48022. el.constructor === window.HTMLElement
  48023. ))
  48024. } else {
  48025. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  48026. }
  48027. }
  48028. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  48029. /* */
  48030. /**
  48031. * Query an element selector if it's not an element already.
  48032. */
  48033. function query (el) {
  48034. if (typeof el === 'string') {
  48035. var selected = document.querySelector(el);
  48036. if (!selected) {
  48037. warn(
  48038. 'Cannot find element: ' + el
  48039. );
  48040. return document.createElement('div')
  48041. }
  48042. return selected
  48043. } else {
  48044. return el
  48045. }
  48046. }
  48047. /* */
  48048. function createElement$1 (tagName, vnode) {
  48049. var elm = document.createElement(tagName);
  48050. if (tagName !== 'select') {
  48051. return elm
  48052. }
  48053. // false or null will remove the attribute but undefined will not
  48054. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  48055. elm.setAttribute('multiple', 'multiple');
  48056. }
  48057. return elm
  48058. }
  48059. function createElementNS (namespace, tagName) {
  48060. return document.createElementNS(namespaceMap[namespace], tagName)
  48061. }
  48062. function createTextNode (text) {
  48063. return document.createTextNode(text)
  48064. }
  48065. function createComment (text) {
  48066. return document.createComment(text)
  48067. }
  48068. function insertBefore (parentNode, newNode, referenceNode) {
  48069. parentNode.insertBefore(newNode, referenceNode);
  48070. }
  48071. function removeChild (node, child) {
  48072. node.removeChild(child);
  48073. }
  48074. function appendChild (node, child) {
  48075. node.appendChild(child);
  48076. }
  48077. function parentNode (node) {
  48078. return node.parentNode
  48079. }
  48080. function nextSibling (node) {
  48081. return node.nextSibling
  48082. }
  48083. function tagName (node) {
  48084. return node.tagName
  48085. }
  48086. function setTextContent (node, text) {
  48087. node.textContent = text;
  48088. }
  48089. function setStyleScope (node, scopeId) {
  48090. node.setAttribute(scopeId, '');
  48091. }
  48092. var nodeOps = /*#__PURE__*/Object.freeze({
  48093. createElement: createElement$1,
  48094. createElementNS: createElementNS,
  48095. createTextNode: createTextNode,
  48096. createComment: createComment,
  48097. insertBefore: insertBefore,
  48098. removeChild: removeChild,
  48099. appendChild: appendChild,
  48100. parentNode: parentNode,
  48101. nextSibling: nextSibling,
  48102. tagName: tagName,
  48103. setTextContent: setTextContent,
  48104. setStyleScope: setStyleScope
  48105. });
  48106. /* */
  48107. var ref = {
  48108. create: function create (_, vnode) {
  48109. registerRef(vnode);
  48110. },
  48111. update: function update (oldVnode, vnode) {
  48112. if (oldVnode.data.ref !== vnode.data.ref) {
  48113. registerRef(oldVnode, true);
  48114. registerRef(vnode);
  48115. }
  48116. },
  48117. destroy: function destroy (vnode) {
  48118. registerRef(vnode, true);
  48119. }
  48120. };
  48121. function registerRef (vnode, isRemoval) {
  48122. var key = vnode.data.ref;
  48123. if (!isDef(key)) { return }
  48124. var vm = vnode.context;
  48125. var ref = vnode.componentInstance || vnode.elm;
  48126. var refs = vm.$refs;
  48127. if (isRemoval) {
  48128. if (Array.isArray(refs[key])) {
  48129. remove(refs[key], ref);
  48130. } else if (refs[key] === ref) {
  48131. refs[key] = undefined;
  48132. }
  48133. } else {
  48134. if (vnode.data.refInFor) {
  48135. if (!Array.isArray(refs[key])) {
  48136. refs[key] = [ref];
  48137. } else if (refs[key].indexOf(ref) < 0) {
  48138. // $flow-disable-line
  48139. refs[key].push(ref);
  48140. }
  48141. } else {
  48142. refs[key] = ref;
  48143. }
  48144. }
  48145. }
  48146. /**
  48147. * Virtual DOM patching algorithm based on Snabbdom by
  48148. * Simon Friis Vindum (@paldepind)
  48149. * Licensed under the MIT License
  48150. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  48151. *
  48152. * modified by Evan You (@yyx990803)
  48153. *
  48154. * Not type-checking this because this file is perf-critical and the cost
  48155. * of making flow understand it is not worth it.
  48156. */
  48157. var emptyNode = new VNode('', {}, []);
  48158. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  48159. function sameVnode (a, b) {
  48160. return (
  48161. a.key === b.key && (
  48162. (
  48163. a.tag === b.tag &&
  48164. a.isComment === b.isComment &&
  48165. isDef(a.data) === isDef(b.data) &&
  48166. sameInputType(a, b)
  48167. ) || (
  48168. isTrue(a.isAsyncPlaceholder) &&
  48169. a.asyncFactory === b.asyncFactory &&
  48170. isUndef(b.asyncFactory.error)
  48171. )
  48172. )
  48173. )
  48174. }
  48175. function sameInputType (a, b) {
  48176. if (a.tag !== 'input') { return true }
  48177. var i;
  48178. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  48179. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  48180. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  48181. }
  48182. function createKeyToOldIdx (children, beginIdx, endIdx) {
  48183. var i, key;
  48184. var map = {};
  48185. for (i = beginIdx; i <= endIdx; ++i) {
  48186. key = children[i].key;
  48187. if (isDef(key)) { map[key] = i; }
  48188. }
  48189. return map
  48190. }
  48191. function createPatchFunction (backend) {
  48192. var i, j;
  48193. var cbs = {};
  48194. var modules = backend.modules;
  48195. var nodeOps = backend.nodeOps;
  48196. for (i = 0; i < hooks.length; ++i) {
  48197. cbs[hooks[i]] = [];
  48198. for (j = 0; j < modules.length; ++j) {
  48199. if (isDef(modules[j][hooks[i]])) {
  48200. cbs[hooks[i]].push(modules[j][hooks[i]]);
  48201. }
  48202. }
  48203. }
  48204. function emptyNodeAt (elm) {
  48205. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  48206. }
  48207. function createRmCb (childElm, listeners) {
  48208. function remove$$1 () {
  48209. if (--remove$$1.listeners === 0) {
  48210. removeNode(childElm);
  48211. }
  48212. }
  48213. remove$$1.listeners = listeners;
  48214. return remove$$1
  48215. }
  48216. function removeNode (el) {
  48217. var parent = nodeOps.parentNode(el);
  48218. // element may have already been removed due to v-html / v-text
  48219. if (isDef(parent)) {
  48220. nodeOps.removeChild(parent, el);
  48221. }
  48222. }
  48223. function isUnknownElement$$1 (vnode, inVPre) {
  48224. return (
  48225. !inVPre &&
  48226. !vnode.ns &&
  48227. !(
  48228. config.ignoredElements.length &&
  48229. config.ignoredElements.some(function (ignore) {
  48230. return isRegExp(ignore)
  48231. ? ignore.test(vnode.tag)
  48232. : ignore === vnode.tag
  48233. })
  48234. ) &&
  48235. config.isUnknownElement(vnode.tag)
  48236. )
  48237. }
  48238. var creatingElmInVPre = 0;
  48239. function createElm (
  48240. vnode,
  48241. insertedVnodeQueue,
  48242. parentElm,
  48243. refElm,
  48244. nested,
  48245. ownerArray,
  48246. index
  48247. ) {
  48248. if (isDef(vnode.elm) && isDef(ownerArray)) {
  48249. // This vnode was used in a previous render!
  48250. // now it's used as a new node, overwriting its elm would cause
  48251. // potential patch errors down the road when it's used as an insertion
  48252. // reference node. Instead, we clone the node on-demand before creating
  48253. // associated DOM element for it.
  48254. vnode = ownerArray[index] = cloneVNode(vnode);
  48255. }
  48256. vnode.isRootInsert = !nested; // for transition enter check
  48257. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  48258. return
  48259. }
  48260. var data = vnode.data;
  48261. var children = vnode.children;
  48262. var tag = vnode.tag;
  48263. if (isDef(tag)) {
  48264. {
  48265. if (data && data.pre) {
  48266. creatingElmInVPre++;
  48267. }
  48268. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  48269. warn(
  48270. 'Unknown custom element: <' + tag + '> - did you ' +
  48271. 'register the component correctly? For recursive components, ' +
  48272. 'make sure to provide the "name" option.',
  48273. vnode.context
  48274. );
  48275. }
  48276. }
  48277. vnode.elm = vnode.ns
  48278. ? nodeOps.createElementNS(vnode.ns, tag)
  48279. : nodeOps.createElement(tag, vnode);
  48280. setScope(vnode);
  48281. /* istanbul ignore if */
  48282. {
  48283. createChildren(vnode, children, insertedVnodeQueue);
  48284. if (isDef(data)) {
  48285. invokeCreateHooks(vnode, insertedVnodeQueue);
  48286. }
  48287. insert(parentElm, vnode.elm, refElm);
  48288. }
  48289. if (data && data.pre) {
  48290. creatingElmInVPre--;
  48291. }
  48292. } else if (isTrue(vnode.isComment)) {
  48293. vnode.elm = nodeOps.createComment(vnode.text);
  48294. insert(parentElm, vnode.elm, refElm);
  48295. } else {
  48296. vnode.elm = nodeOps.createTextNode(vnode.text);
  48297. insert(parentElm, vnode.elm, refElm);
  48298. }
  48299. }
  48300. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  48301. var i = vnode.data;
  48302. if (isDef(i)) {
  48303. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  48304. if (isDef(i = i.hook) && isDef(i = i.init)) {
  48305. i(vnode, false /* hydrating */);
  48306. }
  48307. // after calling the init hook, if the vnode is a child component
  48308. // it should've created a child instance and mounted it. the child
  48309. // component also has set the placeholder vnode's elm.
  48310. // in that case we can just return the element and be done.
  48311. if (isDef(vnode.componentInstance)) {
  48312. initComponent(vnode, insertedVnodeQueue);
  48313. insert(parentElm, vnode.elm, refElm);
  48314. if (isTrue(isReactivated)) {
  48315. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  48316. }
  48317. return true
  48318. }
  48319. }
  48320. }
  48321. function initComponent (vnode, insertedVnodeQueue) {
  48322. if (isDef(vnode.data.pendingInsert)) {
  48323. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  48324. vnode.data.pendingInsert = null;
  48325. }
  48326. vnode.elm = vnode.componentInstance.$el;
  48327. if (isPatchable(vnode)) {
  48328. invokeCreateHooks(vnode, insertedVnodeQueue);
  48329. setScope(vnode);
  48330. } else {
  48331. // empty component root.
  48332. // skip all element-related modules except for ref (#3455)
  48333. registerRef(vnode);
  48334. // make sure to invoke the insert hook
  48335. insertedVnodeQueue.push(vnode);
  48336. }
  48337. }
  48338. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  48339. var i;
  48340. // hack for #4339: a reactivated component with inner transition
  48341. // does not trigger because the inner node's created hooks are not called
  48342. // again. It's not ideal to involve module-specific logic in here but
  48343. // there doesn't seem to be a better way to do it.
  48344. var innerNode = vnode;
  48345. while (innerNode.componentInstance) {
  48346. innerNode = innerNode.componentInstance._vnode;
  48347. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  48348. for (i = 0; i < cbs.activate.length; ++i) {
  48349. cbs.activate[i](emptyNode, innerNode);
  48350. }
  48351. insertedVnodeQueue.push(innerNode);
  48352. break
  48353. }
  48354. }
  48355. // unlike a newly created component,
  48356. // a reactivated keep-alive component doesn't insert itself
  48357. insert(parentElm, vnode.elm, refElm);
  48358. }
  48359. function insert (parent, elm, ref$$1) {
  48360. if (isDef(parent)) {
  48361. if (isDef(ref$$1)) {
  48362. if (nodeOps.parentNode(ref$$1) === parent) {
  48363. nodeOps.insertBefore(parent, elm, ref$$1);
  48364. }
  48365. } else {
  48366. nodeOps.appendChild(parent, elm);
  48367. }
  48368. }
  48369. }
  48370. function createChildren (vnode, children, insertedVnodeQueue) {
  48371. if (Array.isArray(children)) {
  48372. {
  48373. checkDuplicateKeys(children);
  48374. }
  48375. for (var i = 0; i < children.length; ++i) {
  48376. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  48377. }
  48378. } else if (isPrimitive(vnode.text)) {
  48379. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  48380. }
  48381. }
  48382. function isPatchable (vnode) {
  48383. while (vnode.componentInstance) {
  48384. vnode = vnode.componentInstance._vnode;
  48385. }
  48386. return isDef(vnode.tag)
  48387. }
  48388. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  48389. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  48390. cbs.create[i$1](emptyNode, vnode);
  48391. }
  48392. i = vnode.data.hook; // Reuse variable
  48393. if (isDef(i)) {
  48394. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  48395. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  48396. }
  48397. }
  48398. // set scope id attribute for scoped CSS.
  48399. // this is implemented as a special case to avoid the overhead
  48400. // of going through the normal attribute patching process.
  48401. function setScope (vnode) {
  48402. var i;
  48403. if (isDef(i = vnode.fnScopeId)) {
  48404. nodeOps.setStyleScope(vnode.elm, i);
  48405. } else {
  48406. var ancestor = vnode;
  48407. while (ancestor) {
  48408. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  48409. nodeOps.setStyleScope(vnode.elm, i);
  48410. }
  48411. ancestor = ancestor.parent;
  48412. }
  48413. }
  48414. // for slot content they should also get the scopeId from the host instance.
  48415. if (isDef(i = activeInstance) &&
  48416. i !== vnode.context &&
  48417. i !== vnode.fnContext &&
  48418. isDef(i = i.$options._scopeId)
  48419. ) {
  48420. nodeOps.setStyleScope(vnode.elm, i);
  48421. }
  48422. }
  48423. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  48424. for (; startIdx <= endIdx; ++startIdx) {
  48425. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  48426. }
  48427. }
  48428. function invokeDestroyHook (vnode) {
  48429. var i, j;
  48430. var data = vnode.data;
  48431. if (isDef(data)) {
  48432. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  48433. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  48434. }
  48435. if (isDef(i = vnode.children)) {
  48436. for (j = 0; j < vnode.children.length; ++j) {
  48437. invokeDestroyHook(vnode.children[j]);
  48438. }
  48439. }
  48440. }
  48441. function removeVnodes (vnodes, startIdx, endIdx) {
  48442. for (; startIdx <= endIdx; ++startIdx) {
  48443. var ch = vnodes[startIdx];
  48444. if (isDef(ch)) {
  48445. if (isDef(ch.tag)) {
  48446. removeAndInvokeRemoveHook(ch);
  48447. invokeDestroyHook(ch);
  48448. } else { // Text node
  48449. removeNode(ch.elm);
  48450. }
  48451. }
  48452. }
  48453. }
  48454. function removeAndInvokeRemoveHook (vnode, rm) {
  48455. if (isDef(rm) || isDef(vnode.data)) {
  48456. var i;
  48457. var listeners = cbs.remove.length + 1;
  48458. if (isDef(rm)) {
  48459. // we have a recursively passed down rm callback
  48460. // increase the listeners count
  48461. rm.listeners += listeners;
  48462. } else {
  48463. // directly removing
  48464. rm = createRmCb(vnode.elm, listeners);
  48465. }
  48466. // recursively invoke hooks on child component root node
  48467. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  48468. removeAndInvokeRemoveHook(i, rm);
  48469. }
  48470. for (i = 0; i < cbs.remove.length; ++i) {
  48471. cbs.remove[i](vnode, rm);
  48472. }
  48473. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  48474. i(vnode, rm);
  48475. } else {
  48476. rm();
  48477. }
  48478. } else {
  48479. removeNode(vnode.elm);
  48480. }
  48481. }
  48482. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  48483. var oldStartIdx = 0;
  48484. var newStartIdx = 0;
  48485. var oldEndIdx = oldCh.length - 1;
  48486. var oldStartVnode = oldCh[0];
  48487. var oldEndVnode = oldCh[oldEndIdx];
  48488. var newEndIdx = newCh.length - 1;
  48489. var newStartVnode = newCh[0];
  48490. var newEndVnode = newCh[newEndIdx];
  48491. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  48492. // removeOnly is a special flag used only by <transition-group>
  48493. // to ensure removed elements stay in correct relative positions
  48494. // during leaving transitions
  48495. var canMove = !removeOnly;
  48496. {
  48497. checkDuplicateKeys(newCh);
  48498. }
  48499. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  48500. if (isUndef(oldStartVnode)) {
  48501. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  48502. } else if (isUndef(oldEndVnode)) {
  48503. oldEndVnode = oldCh[--oldEndIdx];
  48504. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  48505. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  48506. oldStartVnode = oldCh[++oldStartIdx];
  48507. newStartVnode = newCh[++newStartIdx];
  48508. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  48509. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  48510. oldEndVnode = oldCh[--oldEndIdx];
  48511. newEndVnode = newCh[--newEndIdx];
  48512. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  48513. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  48514. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  48515. oldStartVnode = oldCh[++oldStartIdx];
  48516. newEndVnode = newCh[--newEndIdx];
  48517. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  48518. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  48519. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  48520. oldEndVnode = oldCh[--oldEndIdx];
  48521. newStartVnode = newCh[++newStartIdx];
  48522. } else {
  48523. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  48524. idxInOld = isDef(newStartVnode.key)
  48525. ? oldKeyToIdx[newStartVnode.key]
  48526. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  48527. if (isUndef(idxInOld)) { // New element
  48528. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  48529. } else {
  48530. vnodeToMove = oldCh[idxInOld];
  48531. if (sameVnode(vnodeToMove, newStartVnode)) {
  48532. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  48533. oldCh[idxInOld] = undefined;
  48534. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  48535. } else {
  48536. // same key but different element. treat as new element
  48537. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  48538. }
  48539. }
  48540. newStartVnode = newCh[++newStartIdx];
  48541. }
  48542. }
  48543. if (oldStartIdx > oldEndIdx) {
  48544. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  48545. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  48546. } else if (newStartIdx > newEndIdx) {
  48547. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  48548. }
  48549. }
  48550. function checkDuplicateKeys (children) {
  48551. var seenKeys = {};
  48552. for (var i = 0; i < children.length; i++) {
  48553. var vnode = children[i];
  48554. var key = vnode.key;
  48555. if (isDef(key)) {
  48556. if (seenKeys[key]) {
  48557. warn(
  48558. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  48559. vnode.context
  48560. );
  48561. } else {
  48562. seenKeys[key] = true;
  48563. }
  48564. }
  48565. }
  48566. }
  48567. function findIdxInOld (node, oldCh, start, end) {
  48568. for (var i = start; i < end; i++) {
  48569. var c = oldCh[i];
  48570. if (isDef(c) && sameVnode(node, c)) { return i }
  48571. }
  48572. }
  48573. function patchVnode (
  48574. oldVnode,
  48575. vnode,
  48576. insertedVnodeQueue,
  48577. ownerArray,
  48578. index,
  48579. removeOnly
  48580. ) {
  48581. if (oldVnode === vnode) {
  48582. return
  48583. }
  48584. if (isDef(vnode.elm) && isDef(ownerArray)) {
  48585. // clone reused vnode
  48586. vnode = ownerArray[index] = cloneVNode(vnode);
  48587. }
  48588. var elm = vnode.elm = oldVnode.elm;
  48589. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  48590. if (isDef(vnode.asyncFactory.resolved)) {
  48591. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  48592. } else {
  48593. vnode.isAsyncPlaceholder = true;
  48594. }
  48595. return
  48596. }
  48597. // reuse element for static trees.
  48598. // note we only do this if the vnode is cloned -
  48599. // if the new node is not cloned it means the render functions have been
  48600. // reset by the hot-reload-api and we need to do a proper re-render.
  48601. if (isTrue(vnode.isStatic) &&
  48602. isTrue(oldVnode.isStatic) &&
  48603. vnode.key === oldVnode.key &&
  48604. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  48605. ) {
  48606. vnode.componentInstance = oldVnode.componentInstance;
  48607. return
  48608. }
  48609. var i;
  48610. var data = vnode.data;
  48611. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  48612. i(oldVnode, vnode);
  48613. }
  48614. var oldCh = oldVnode.children;
  48615. var ch = vnode.children;
  48616. if (isDef(data) && isPatchable(vnode)) {
  48617. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  48618. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  48619. }
  48620. if (isUndef(vnode.text)) {
  48621. if (isDef(oldCh) && isDef(ch)) {
  48622. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  48623. } else if (isDef(ch)) {
  48624. {
  48625. checkDuplicateKeys(ch);
  48626. }
  48627. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  48628. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  48629. } else if (isDef(oldCh)) {
  48630. removeVnodes(oldCh, 0, oldCh.length - 1);
  48631. } else if (isDef(oldVnode.text)) {
  48632. nodeOps.setTextContent(elm, '');
  48633. }
  48634. } else if (oldVnode.text !== vnode.text) {
  48635. nodeOps.setTextContent(elm, vnode.text);
  48636. }
  48637. if (isDef(data)) {
  48638. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  48639. }
  48640. }
  48641. function invokeInsertHook (vnode, queue, initial) {
  48642. // delay insert hooks for component root nodes, invoke them after the
  48643. // element is really inserted
  48644. if (isTrue(initial) && isDef(vnode.parent)) {
  48645. vnode.parent.data.pendingInsert = queue;
  48646. } else {
  48647. for (var i = 0; i < queue.length; ++i) {
  48648. queue[i].data.hook.insert(queue[i]);
  48649. }
  48650. }
  48651. }
  48652. var hydrationBailed = false;
  48653. // list of modules that can skip create hook during hydration because they
  48654. // are already rendered on the client or has no need for initialization
  48655. // Note: style is excluded because it relies on initial clone for future
  48656. // deep updates (#7063).
  48657. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  48658. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  48659. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  48660. var i;
  48661. var tag = vnode.tag;
  48662. var data = vnode.data;
  48663. var children = vnode.children;
  48664. inVPre = inVPre || (data && data.pre);
  48665. vnode.elm = elm;
  48666. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  48667. vnode.isAsyncPlaceholder = true;
  48668. return true
  48669. }
  48670. // assert node match
  48671. {
  48672. if (!assertNodeMatch(elm, vnode, inVPre)) {
  48673. return false
  48674. }
  48675. }
  48676. if (isDef(data)) {
  48677. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  48678. if (isDef(i = vnode.componentInstance)) {
  48679. // child component. it should have hydrated its own tree.
  48680. initComponent(vnode, insertedVnodeQueue);
  48681. return true
  48682. }
  48683. }
  48684. if (isDef(tag)) {
  48685. if (isDef(children)) {
  48686. // empty element, allow client to pick up and populate children
  48687. if (!elm.hasChildNodes()) {
  48688. createChildren(vnode, children, insertedVnodeQueue);
  48689. } else {
  48690. // v-html and domProps: innerHTML
  48691. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  48692. if (i !== elm.innerHTML) {
  48693. /* istanbul ignore if */
  48694. if (typeof console !== 'undefined' &&
  48695. !hydrationBailed
  48696. ) {
  48697. hydrationBailed = true;
  48698. console.warn('Parent: ', elm);
  48699. console.warn('server innerHTML: ', i);
  48700. console.warn('client innerHTML: ', elm.innerHTML);
  48701. }
  48702. return false
  48703. }
  48704. } else {
  48705. // iterate and compare children lists
  48706. var childrenMatch = true;
  48707. var childNode = elm.firstChild;
  48708. for (var i$1 = 0; i$1 < children.length; i$1++) {
  48709. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  48710. childrenMatch = false;
  48711. break
  48712. }
  48713. childNode = childNode.nextSibling;
  48714. }
  48715. // if childNode is not null, it means the actual childNodes list is
  48716. // longer than the virtual children list.
  48717. if (!childrenMatch || childNode) {
  48718. /* istanbul ignore if */
  48719. if (typeof console !== 'undefined' &&
  48720. !hydrationBailed
  48721. ) {
  48722. hydrationBailed = true;
  48723. console.warn('Parent: ', elm);
  48724. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  48725. }
  48726. return false
  48727. }
  48728. }
  48729. }
  48730. }
  48731. if (isDef(data)) {
  48732. var fullInvoke = false;
  48733. for (var key in data) {
  48734. if (!isRenderedModule(key)) {
  48735. fullInvoke = true;
  48736. invokeCreateHooks(vnode, insertedVnodeQueue);
  48737. break
  48738. }
  48739. }
  48740. if (!fullInvoke && data['class']) {
  48741. // ensure collecting deps for deep class bindings for future updates
  48742. traverse(data['class']);
  48743. }
  48744. }
  48745. } else if (elm.data !== vnode.text) {
  48746. elm.data = vnode.text;
  48747. }
  48748. return true
  48749. }
  48750. function assertNodeMatch (node, vnode, inVPre) {
  48751. if (isDef(vnode.tag)) {
  48752. return vnode.tag.indexOf('vue-component') === 0 || (
  48753. !isUnknownElement$$1(vnode, inVPre) &&
  48754. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  48755. )
  48756. } else {
  48757. return node.nodeType === (vnode.isComment ? 8 : 3)
  48758. }
  48759. }
  48760. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  48761. if (isUndef(vnode)) {
  48762. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  48763. return
  48764. }
  48765. var isInitialPatch = false;
  48766. var insertedVnodeQueue = [];
  48767. if (isUndef(oldVnode)) {
  48768. // empty mount (likely as component), create new root element
  48769. isInitialPatch = true;
  48770. createElm(vnode, insertedVnodeQueue);
  48771. } else {
  48772. var isRealElement = isDef(oldVnode.nodeType);
  48773. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  48774. // patch existing root node
  48775. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  48776. } else {
  48777. if (isRealElement) {
  48778. // mounting to a real element
  48779. // check if this is server-rendered content and if we can perform
  48780. // a successful hydration.
  48781. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  48782. oldVnode.removeAttribute(SSR_ATTR);
  48783. hydrating = true;
  48784. }
  48785. if (isTrue(hydrating)) {
  48786. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  48787. invokeInsertHook(vnode, insertedVnodeQueue, true);
  48788. return oldVnode
  48789. } else {
  48790. warn(
  48791. 'The client-side rendered virtual DOM tree is not matching ' +
  48792. 'server-rendered content. This is likely caused by incorrect ' +
  48793. 'HTML markup, for example nesting block-level elements inside ' +
  48794. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  48795. 'full client-side render.'
  48796. );
  48797. }
  48798. }
  48799. // either not server-rendered, or hydration failed.
  48800. // create an empty node and replace it
  48801. oldVnode = emptyNodeAt(oldVnode);
  48802. }
  48803. // replacing existing element
  48804. var oldElm = oldVnode.elm;
  48805. var parentElm = nodeOps.parentNode(oldElm);
  48806. // create new node
  48807. createElm(
  48808. vnode,
  48809. insertedVnodeQueue,
  48810. // extremely rare edge case: do not insert if old element is in a
  48811. // leaving transition. Only happens when combining transition +
  48812. // keep-alive + HOCs. (#4590)
  48813. oldElm._leaveCb ? null : parentElm,
  48814. nodeOps.nextSibling(oldElm)
  48815. );
  48816. // update parent placeholder node element, recursively
  48817. if (isDef(vnode.parent)) {
  48818. var ancestor = vnode.parent;
  48819. var patchable = isPatchable(vnode);
  48820. while (ancestor) {
  48821. for (var i = 0; i < cbs.destroy.length; ++i) {
  48822. cbs.destroy[i](ancestor);
  48823. }
  48824. ancestor.elm = vnode.elm;
  48825. if (patchable) {
  48826. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  48827. cbs.create[i$1](emptyNode, ancestor);
  48828. }
  48829. // #6513
  48830. // invoke insert hooks that may have been merged by create hooks.
  48831. // e.g. for directives that uses the "inserted" hook.
  48832. var insert = ancestor.data.hook.insert;
  48833. if (insert.merged) {
  48834. // start at index 1 to avoid re-invoking component mounted hook
  48835. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  48836. insert.fns[i$2]();
  48837. }
  48838. }
  48839. } else {
  48840. registerRef(ancestor);
  48841. }
  48842. ancestor = ancestor.parent;
  48843. }
  48844. }
  48845. // destroy old node
  48846. if (isDef(parentElm)) {
  48847. removeVnodes([oldVnode], 0, 0);
  48848. } else if (isDef(oldVnode.tag)) {
  48849. invokeDestroyHook(oldVnode);
  48850. }
  48851. }
  48852. }
  48853. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  48854. return vnode.elm
  48855. }
  48856. }
  48857. /* */
  48858. var directives = {
  48859. create: updateDirectives,
  48860. update: updateDirectives,
  48861. destroy: function unbindDirectives (vnode) {
  48862. updateDirectives(vnode, emptyNode);
  48863. }
  48864. };
  48865. function updateDirectives (oldVnode, vnode) {
  48866. if (oldVnode.data.directives || vnode.data.directives) {
  48867. _update(oldVnode, vnode);
  48868. }
  48869. }
  48870. function _update (oldVnode, vnode) {
  48871. var isCreate = oldVnode === emptyNode;
  48872. var isDestroy = vnode === emptyNode;
  48873. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  48874. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  48875. var dirsWithInsert = [];
  48876. var dirsWithPostpatch = [];
  48877. var key, oldDir, dir;
  48878. for (key in newDirs) {
  48879. oldDir = oldDirs[key];
  48880. dir = newDirs[key];
  48881. if (!oldDir) {
  48882. // new directive, bind
  48883. callHook$1(dir, 'bind', vnode, oldVnode);
  48884. if (dir.def && dir.def.inserted) {
  48885. dirsWithInsert.push(dir);
  48886. }
  48887. } else {
  48888. // existing directive, update
  48889. dir.oldValue = oldDir.value;
  48890. dir.oldArg = oldDir.arg;
  48891. callHook$1(dir, 'update', vnode, oldVnode);
  48892. if (dir.def && dir.def.componentUpdated) {
  48893. dirsWithPostpatch.push(dir);
  48894. }
  48895. }
  48896. }
  48897. if (dirsWithInsert.length) {
  48898. var callInsert = function () {
  48899. for (var i = 0; i < dirsWithInsert.length; i++) {
  48900. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  48901. }
  48902. };
  48903. if (isCreate) {
  48904. mergeVNodeHook(vnode, 'insert', callInsert);
  48905. } else {
  48906. callInsert();
  48907. }
  48908. }
  48909. if (dirsWithPostpatch.length) {
  48910. mergeVNodeHook(vnode, 'postpatch', function () {
  48911. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  48912. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  48913. }
  48914. });
  48915. }
  48916. if (!isCreate) {
  48917. for (key in oldDirs) {
  48918. if (!newDirs[key]) {
  48919. // no longer present, unbind
  48920. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  48921. }
  48922. }
  48923. }
  48924. }
  48925. var emptyModifiers = Object.create(null);
  48926. function normalizeDirectives$1 (
  48927. dirs,
  48928. vm
  48929. ) {
  48930. var res = Object.create(null);
  48931. if (!dirs) {
  48932. // $flow-disable-line
  48933. return res
  48934. }
  48935. var i, dir;
  48936. for (i = 0; i < dirs.length; i++) {
  48937. dir = dirs[i];
  48938. if (!dir.modifiers) {
  48939. // $flow-disable-line
  48940. dir.modifiers = emptyModifiers;
  48941. }
  48942. res[getRawDirName(dir)] = dir;
  48943. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  48944. }
  48945. // $flow-disable-line
  48946. return res
  48947. }
  48948. function getRawDirName (dir) {
  48949. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  48950. }
  48951. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  48952. var fn = dir.def && dir.def[hook];
  48953. if (fn) {
  48954. try {
  48955. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  48956. } catch (e) {
  48957. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  48958. }
  48959. }
  48960. }
  48961. var baseModules = [
  48962. ref,
  48963. directives
  48964. ];
  48965. /* */
  48966. function updateAttrs (oldVnode, vnode) {
  48967. var opts = vnode.componentOptions;
  48968. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  48969. return
  48970. }
  48971. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  48972. return
  48973. }
  48974. var key, cur, old;
  48975. var elm = vnode.elm;
  48976. var oldAttrs = oldVnode.data.attrs || {};
  48977. var attrs = vnode.data.attrs || {};
  48978. // clone observed objects, as the user probably wants to mutate it
  48979. if (isDef(attrs.__ob__)) {
  48980. attrs = vnode.data.attrs = extend({}, attrs);
  48981. }
  48982. for (key in attrs) {
  48983. cur = attrs[key];
  48984. old = oldAttrs[key];
  48985. if (old !== cur) {
  48986. setAttr(elm, key, cur);
  48987. }
  48988. }
  48989. // #4391: in IE9, setting type can reset value for input[type=radio]
  48990. // #6666: IE/Edge forces progress value down to 1 before setting a max
  48991. /* istanbul ignore if */
  48992. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  48993. setAttr(elm, 'value', attrs.value);
  48994. }
  48995. for (key in oldAttrs) {
  48996. if (isUndef(attrs[key])) {
  48997. if (isXlink(key)) {
  48998. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  48999. } else if (!isEnumeratedAttr(key)) {
  49000. elm.removeAttribute(key);
  49001. }
  49002. }
  49003. }
  49004. }
  49005. function setAttr (el, key, value) {
  49006. if (el.tagName.indexOf('-') > -1) {
  49007. baseSetAttr(el, key, value);
  49008. } else if (isBooleanAttr(key)) {
  49009. // set attribute for blank value
  49010. // e.g. <option disabled>Select one</option>
  49011. if (isFalsyAttrValue(value)) {
  49012. el.removeAttribute(key);
  49013. } else {
  49014. // technically allowfullscreen is a boolean attribute for <iframe>,
  49015. // but Flash expects a value of "true" when used on <embed> tag
  49016. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  49017. ? 'true'
  49018. : key;
  49019. el.setAttribute(key, value);
  49020. }
  49021. } else if (isEnumeratedAttr(key)) {
  49022. el.setAttribute(key, convertEnumeratedValue(key, value));
  49023. } else if (isXlink(key)) {
  49024. if (isFalsyAttrValue(value)) {
  49025. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  49026. } else {
  49027. el.setAttributeNS(xlinkNS, key, value);
  49028. }
  49029. } else {
  49030. baseSetAttr(el, key, value);
  49031. }
  49032. }
  49033. function baseSetAttr (el, key, value) {
  49034. if (isFalsyAttrValue(value)) {
  49035. el.removeAttribute(key);
  49036. } else {
  49037. // #7138: IE10 & 11 fires input event when setting placeholder on
  49038. // <textarea>... block the first input event and remove the blocker
  49039. // immediately.
  49040. /* istanbul ignore if */
  49041. if (
  49042. isIE && !isIE9 &&
  49043. el.tagName === 'TEXTAREA' &&
  49044. key === 'placeholder' && value !== '' && !el.__ieph
  49045. ) {
  49046. var blocker = function (e) {
  49047. e.stopImmediatePropagation();
  49048. el.removeEventListener('input', blocker);
  49049. };
  49050. el.addEventListener('input', blocker);
  49051. // $flow-disable-line
  49052. el.__ieph = true; /* IE placeholder patched */
  49053. }
  49054. el.setAttribute(key, value);
  49055. }
  49056. }
  49057. var attrs = {
  49058. create: updateAttrs,
  49059. update: updateAttrs
  49060. };
  49061. /* */
  49062. function updateClass (oldVnode, vnode) {
  49063. var el = vnode.elm;
  49064. var data = vnode.data;
  49065. var oldData = oldVnode.data;
  49066. if (
  49067. isUndef(data.staticClass) &&
  49068. isUndef(data.class) && (
  49069. isUndef(oldData) || (
  49070. isUndef(oldData.staticClass) &&
  49071. isUndef(oldData.class)
  49072. )
  49073. )
  49074. ) {
  49075. return
  49076. }
  49077. var cls = genClassForVnode(vnode);
  49078. // handle transition classes
  49079. var transitionClass = el._transitionClasses;
  49080. if (isDef(transitionClass)) {
  49081. cls = concat(cls, stringifyClass(transitionClass));
  49082. }
  49083. // set the class
  49084. if (cls !== el._prevClass) {
  49085. el.setAttribute('class', cls);
  49086. el._prevClass = cls;
  49087. }
  49088. }
  49089. var klass = {
  49090. create: updateClass,
  49091. update: updateClass
  49092. };
  49093. /* */
  49094. var validDivisionCharRE = /[\w).+\-_$\]]/;
  49095. function parseFilters (exp) {
  49096. var inSingle = false;
  49097. var inDouble = false;
  49098. var inTemplateString = false;
  49099. var inRegex = false;
  49100. var curly = 0;
  49101. var square = 0;
  49102. var paren = 0;
  49103. var lastFilterIndex = 0;
  49104. var c, prev, i, expression, filters;
  49105. for (i = 0; i < exp.length; i++) {
  49106. prev = c;
  49107. c = exp.charCodeAt(i);
  49108. if (inSingle) {
  49109. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  49110. } else if (inDouble) {
  49111. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  49112. } else if (inTemplateString) {
  49113. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  49114. } else if (inRegex) {
  49115. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  49116. } else if (
  49117. c === 0x7C && // pipe
  49118. exp.charCodeAt(i + 1) !== 0x7C &&
  49119. exp.charCodeAt(i - 1) !== 0x7C &&
  49120. !curly && !square && !paren
  49121. ) {
  49122. if (expression === undefined) {
  49123. // first filter, end of expression
  49124. lastFilterIndex = i + 1;
  49125. expression = exp.slice(0, i).trim();
  49126. } else {
  49127. pushFilter();
  49128. }
  49129. } else {
  49130. switch (c) {
  49131. case 0x22: inDouble = true; break // "
  49132. case 0x27: inSingle = true; break // '
  49133. case 0x60: inTemplateString = true; break // `
  49134. case 0x28: paren++; break // (
  49135. case 0x29: paren--; break // )
  49136. case 0x5B: square++; break // [
  49137. case 0x5D: square--; break // ]
  49138. case 0x7B: curly++; break // {
  49139. case 0x7D: curly--; break // }
  49140. }
  49141. if (c === 0x2f) { // /
  49142. var j = i - 1;
  49143. var p = (void 0);
  49144. // find first non-whitespace prev char
  49145. for (; j >= 0; j--) {
  49146. p = exp.charAt(j);
  49147. if (p !== ' ') { break }
  49148. }
  49149. if (!p || !validDivisionCharRE.test(p)) {
  49150. inRegex = true;
  49151. }
  49152. }
  49153. }
  49154. }
  49155. if (expression === undefined) {
  49156. expression = exp.slice(0, i).trim();
  49157. } else if (lastFilterIndex !== 0) {
  49158. pushFilter();
  49159. }
  49160. function pushFilter () {
  49161. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  49162. lastFilterIndex = i + 1;
  49163. }
  49164. if (filters) {
  49165. for (i = 0; i < filters.length; i++) {
  49166. expression = wrapFilter(expression, filters[i]);
  49167. }
  49168. }
  49169. return expression
  49170. }
  49171. function wrapFilter (exp, filter) {
  49172. var i = filter.indexOf('(');
  49173. if (i < 0) {
  49174. // _f: resolveFilter
  49175. return ("_f(\"" + filter + "\")(" + exp + ")")
  49176. } else {
  49177. var name = filter.slice(0, i);
  49178. var args = filter.slice(i + 1);
  49179. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  49180. }
  49181. }
  49182. /* */
  49183. /* eslint-disable no-unused-vars */
  49184. function baseWarn (msg, range) {
  49185. console.error(("[Vue compiler]: " + msg));
  49186. }
  49187. /* eslint-enable no-unused-vars */
  49188. function pluckModuleFunction (
  49189. modules,
  49190. key
  49191. ) {
  49192. return modules
  49193. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  49194. : []
  49195. }
  49196. function addProp (el, name, value, range, dynamic) {
  49197. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  49198. el.plain = false;
  49199. }
  49200. function addAttr (el, name, value, range, dynamic) {
  49201. var attrs = dynamic
  49202. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  49203. : (el.attrs || (el.attrs = []));
  49204. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  49205. el.plain = false;
  49206. }
  49207. // add a raw attr (use this in preTransforms)
  49208. function addRawAttr (el, name, value, range) {
  49209. el.attrsMap[name] = value;
  49210. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  49211. }
  49212. function addDirective (
  49213. el,
  49214. name,
  49215. rawName,
  49216. value,
  49217. arg,
  49218. isDynamicArg,
  49219. modifiers,
  49220. range
  49221. ) {
  49222. (el.directives || (el.directives = [])).push(rangeSetItem({
  49223. name: name,
  49224. rawName: rawName,
  49225. value: value,
  49226. arg: arg,
  49227. isDynamicArg: isDynamicArg,
  49228. modifiers: modifiers
  49229. }, range));
  49230. el.plain = false;
  49231. }
  49232. function prependModifierMarker (symbol, name, dynamic) {
  49233. return dynamic
  49234. ? ("_p(" + name + ",\"" + symbol + "\")")
  49235. : symbol + name // mark the event as captured
  49236. }
  49237. function addHandler (
  49238. el,
  49239. name,
  49240. value,
  49241. modifiers,
  49242. important,
  49243. warn,
  49244. range,
  49245. dynamic
  49246. ) {
  49247. modifiers = modifiers || emptyObject;
  49248. // warn prevent and passive modifier
  49249. /* istanbul ignore if */
  49250. if (
  49251. warn &&
  49252. modifiers.prevent && modifiers.passive
  49253. ) {
  49254. warn(
  49255. 'passive and prevent can\'t be used together. ' +
  49256. 'Passive handler can\'t prevent default event.',
  49257. range
  49258. );
  49259. }
  49260. // normalize click.right and click.middle since they don't actually fire
  49261. // this is technically browser-specific, but at least for now browsers are
  49262. // the only target envs that have right/middle clicks.
  49263. if (modifiers.right) {
  49264. if (dynamic) {
  49265. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  49266. } else if (name === 'click') {
  49267. name = 'contextmenu';
  49268. delete modifiers.right;
  49269. }
  49270. } else if (modifiers.middle) {
  49271. if (dynamic) {
  49272. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  49273. } else if (name === 'click') {
  49274. name = 'mouseup';
  49275. }
  49276. }
  49277. // check capture modifier
  49278. if (modifiers.capture) {
  49279. delete modifiers.capture;
  49280. name = prependModifierMarker('!', name, dynamic);
  49281. }
  49282. if (modifiers.once) {
  49283. delete modifiers.once;
  49284. name = prependModifierMarker('~', name, dynamic);
  49285. }
  49286. /* istanbul ignore if */
  49287. if (modifiers.passive) {
  49288. delete modifiers.passive;
  49289. name = prependModifierMarker('&', name, dynamic);
  49290. }
  49291. var events;
  49292. if (modifiers.native) {
  49293. delete modifiers.native;
  49294. events = el.nativeEvents || (el.nativeEvents = {});
  49295. } else {
  49296. events = el.events || (el.events = {});
  49297. }
  49298. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  49299. if (modifiers !== emptyObject) {
  49300. newHandler.modifiers = modifiers;
  49301. }
  49302. var handlers = events[name];
  49303. /* istanbul ignore if */
  49304. if (Array.isArray(handlers)) {
  49305. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  49306. } else if (handlers) {
  49307. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  49308. } else {
  49309. events[name] = newHandler;
  49310. }
  49311. el.plain = false;
  49312. }
  49313. function getRawBindingAttr (
  49314. el,
  49315. name
  49316. ) {
  49317. return el.rawAttrsMap[':' + name] ||
  49318. el.rawAttrsMap['v-bind:' + name] ||
  49319. el.rawAttrsMap[name]
  49320. }
  49321. function getBindingAttr (
  49322. el,
  49323. name,
  49324. getStatic
  49325. ) {
  49326. var dynamicValue =
  49327. getAndRemoveAttr(el, ':' + name) ||
  49328. getAndRemoveAttr(el, 'v-bind:' + name);
  49329. if (dynamicValue != null) {
  49330. return parseFilters(dynamicValue)
  49331. } else if (getStatic !== false) {
  49332. var staticValue = getAndRemoveAttr(el, name);
  49333. if (staticValue != null) {
  49334. return JSON.stringify(staticValue)
  49335. }
  49336. }
  49337. }
  49338. // note: this only removes the attr from the Array (attrsList) so that it
  49339. // doesn't get processed by processAttrs.
  49340. // By default it does NOT remove it from the map (attrsMap) because the map is
  49341. // needed during codegen.
  49342. function getAndRemoveAttr (
  49343. el,
  49344. name,
  49345. removeFromMap
  49346. ) {
  49347. var val;
  49348. if ((val = el.attrsMap[name]) != null) {
  49349. var list = el.attrsList;
  49350. for (var i = 0, l = list.length; i < l; i++) {
  49351. if (list[i].name === name) {
  49352. list.splice(i, 1);
  49353. break
  49354. }
  49355. }
  49356. }
  49357. if (removeFromMap) {
  49358. delete el.attrsMap[name];
  49359. }
  49360. return val
  49361. }
  49362. function getAndRemoveAttrByRegex (
  49363. el,
  49364. name
  49365. ) {
  49366. var list = el.attrsList;
  49367. for (var i = 0, l = list.length; i < l; i++) {
  49368. var attr = list[i];
  49369. if (name.test(attr.name)) {
  49370. list.splice(i, 1);
  49371. return attr
  49372. }
  49373. }
  49374. }
  49375. function rangeSetItem (
  49376. item,
  49377. range
  49378. ) {
  49379. if (range) {
  49380. if (range.start != null) {
  49381. item.start = range.start;
  49382. }
  49383. if (range.end != null) {
  49384. item.end = range.end;
  49385. }
  49386. }
  49387. return item
  49388. }
  49389. /* */
  49390. /**
  49391. * Cross-platform code generation for component v-model
  49392. */
  49393. function genComponentModel (
  49394. el,
  49395. value,
  49396. modifiers
  49397. ) {
  49398. var ref = modifiers || {};
  49399. var number = ref.number;
  49400. var trim = ref.trim;
  49401. var baseValueExpression = '$$v';
  49402. var valueExpression = baseValueExpression;
  49403. if (trim) {
  49404. valueExpression =
  49405. "(typeof " + baseValueExpression + " === 'string'" +
  49406. "? " + baseValueExpression + ".trim()" +
  49407. ": " + baseValueExpression + ")";
  49408. }
  49409. if (number) {
  49410. valueExpression = "_n(" + valueExpression + ")";
  49411. }
  49412. var assignment = genAssignmentCode(value, valueExpression);
  49413. el.model = {
  49414. value: ("(" + value + ")"),
  49415. expression: JSON.stringify(value),
  49416. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  49417. };
  49418. }
  49419. /**
  49420. * Cross-platform codegen helper for generating v-model value assignment code.
  49421. */
  49422. function genAssignmentCode (
  49423. value,
  49424. assignment
  49425. ) {
  49426. var res = parseModel(value);
  49427. if (res.key === null) {
  49428. return (value + "=" + assignment)
  49429. } else {
  49430. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  49431. }
  49432. }
  49433. /**
  49434. * Parse a v-model expression into a base path and a final key segment.
  49435. * Handles both dot-path and possible square brackets.
  49436. *
  49437. * Possible cases:
  49438. *
  49439. * - test
  49440. * - test[key]
  49441. * - test[test1[key]]
  49442. * - test["a"][key]
  49443. * - xxx.test[a[a].test1[key]]
  49444. * - test.xxx.a["asa"][test1[key]]
  49445. *
  49446. */
  49447. var len, str, chr, index$1, expressionPos, expressionEndPos;
  49448. function parseModel (val) {
  49449. // Fix https://github.com/vuejs/vue/pull/7730
  49450. // allow v-model="obj.val " (trailing whitespace)
  49451. val = val.trim();
  49452. len = val.length;
  49453. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  49454. index$1 = val.lastIndexOf('.');
  49455. if (index$1 > -1) {
  49456. return {
  49457. exp: val.slice(0, index$1),
  49458. key: '"' + val.slice(index$1 + 1) + '"'
  49459. }
  49460. } else {
  49461. return {
  49462. exp: val,
  49463. key: null
  49464. }
  49465. }
  49466. }
  49467. str = val;
  49468. index$1 = expressionPos = expressionEndPos = 0;
  49469. while (!eof()) {
  49470. chr = next();
  49471. /* istanbul ignore if */
  49472. if (isStringStart(chr)) {
  49473. parseString(chr);
  49474. } else if (chr === 0x5B) {
  49475. parseBracket(chr);
  49476. }
  49477. }
  49478. return {
  49479. exp: val.slice(0, expressionPos),
  49480. key: val.slice(expressionPos + 1, expressionEndPos)
  49481. }
  49482. }
  49483. function next () {
  49484. return str.charCodeAt(++index$1)
  49485. }
  49486. function eof () {
  49487. return index$1 >= len
  49488. }
  49489. function isStringStart (chr) {
  49490. return chr === 0x22 || chr === 0x27
  49491. }
  49492. function parseBracket (chr) {
  49493. var inBracket = 1;
  49494. expressionPos = index$1;
  49495. while (!eof()) {
  49496. chr = next();
  49497. if (isStringStart(chr)) {
  49498. parseString(chr);
  49499. continue
  49500. }
  49501. if (chr === 0x5B) { inBracket++; }
  49502. if (chr === 0x5D) { inBracket--; }
  49503. if (inBracket === 0) {
  49504. expressionEndPos = index$1;
  49505. break
  49506. }
  49507. }
  49508. }
  49509. function parseString (chr) {
  49510. var stringQuote = chr;
  49511. while (!eof()) {
  49512. chr = next();
  49513. if (chr === stringQuote) {
  49514. break
  49515. }
  49516. }
  49517. }
  49518. /* */
  49519. var warn$1;
  49520. // in some cases, the event used has to be determined at runtime
  49521. // so we used some reserved tokens during compile.
  49522. var RANGE_TOKEN = '__r';
  49523. var CHECKBOX_RADIO_TOKEN = '__c';
  49524. function model (
  49525. el,
  49526. dir,
  49527. _warn
  49528. ) {
  49529. warn$1 = _warn;
  49530. var value = dir.value;
  49531. var modifiers = dir.modifiers;
  49532. var tag = el.tag;
  49533. var type = el.attrsMap.type;
  49534. {
  49535. // inputs with type="file" are read only and setting the input's
  49536. // value will throw an error.
  49537. if (tag === 'input' && type === 'file') {
  49538. warn$1(
  49539. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  49540. "File inputs are read only. Use a v-on:change listener instead.",
  49541. el.rawAttrsMap['v-model']
  49542. );
  49543. }
  49544. }
  49545. if (el.component) {
  49546. genComponentModel(el, value, modifiers);
  49547. // component v-model doesn't need extra runtime
  49548. return false
  49549. } else if (tag === 'select') {
  49550. genSelect(el, value, modifiers);
  49551. } else if (tag === 'input' && type === 'checkbox') {
  49552. genCheckboxModel(el, value, modifiers);
  49553. } else if (tag === 'input' && type === 'radio') {
  49554. genRadioModel(el, value, modifiers);
  49555. } else if (tag === 'input' || tag === 'textarea') {
  49556. genDefaultModel(el, value, modifiers);
  49557. } else if (!config.isReservedTag(tag)) {
  49558. genComponentModel(el, value, modifiers);
  49559. // component v-model doesn't need extra runtime
  49560. return false
  49561. } else {
  49562. warn$1(
  49563. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  49564. "v-model is not supported on this element type. " +
  49565. 'If you are working with contenteditable, it\'s recommended to ' +
  49566. 'wrap a library dedicated for that purpose inside a custom component.',
  49567. el.rawAttrsMap['v-model']
  49568. );
  49569. }
  49570. // ensure runtime directive metadata
  49571. return true
  49572. }
  49573. function genCheckboxModel (
  49574. el,
  49575. value,
  49576. modifiers
  49577. ) {
  49578. var number = modifiers && modifiers.number;
  49579. var valueBinding = getBindingAttr(el, 'value') || 'null';
  49580. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  49581. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  49582. addProp(el, 'checked',
  49583. "Array.isArray(" + value + ")" +
  49584. "?_i(" + value + "," + valueBinding + ")>-1" + (
  49585. trueValueBinding === 'true'
  49586. ? (":(" + value + ")")
  49587. : (":_q(" + value + "," + trueValueBinding + ")")
  49588. )
  49589. );
  49590. addHandler(el, 'change',
  49591. "var $$a=" + value + "," +
  49592. '$$el=$event.target,' +
  49593. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  49594. 'if(Array.isArray($$a)){' +
  49595. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  49596. '$$i=_i($$a,$$v);' +
  49597. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  49598. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  49599. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  49600. null, true
  49601. );
  49602. }
  49603. function genRadioModel (
  49604. el,
  49605. value,
  49606. modifiers
  49607. ) {
  49608. var number = modifiers && modifiers.number;
  49609. var valueBinding = getBindingAttr(el, 'value') || 'null';
  49610. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  49611. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  49612. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  49613. }
  49614. function genSelect (
  49615. el,
  49616. value,
  49617. modifiers
  49618. ) {
  49619. var number = modifiers && modifiers.number;
  49620. var selectedVal = "Array.prototype.filter" +
  49621. ".call($event.target.options,function(o){return o.selected})" +
  49622. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  49623. "return " + (number ? '_n(val)' : 'val') + "})";
  49624. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  49625. var code = "var $$selectedVal = " + selectedVal + ";";
  49626. code = code + " " + (genAssignmentCode(value, assignment));
  49627. addHandler(el, 'change', code, null, true);
  49628. }
  49629. function genDefaultModel (
  49630. el,
  49631. value,
  49632. modifiers
  49633. ) {
  49634. var type = el.attrsMap.type;
  49635. // warn if v-bind:value conflicts with v-model
  49636. // except for inputs with v-bind:type
  49637. {
  49638. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  49639. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  49640. if (value$1 && !typeBinding) {
  49641. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  49642. warn$1(
  49643. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  49644. 'because the latter already expands to a value binding internally',
  49645. el.rawAttrsMap[binding]
  49646. );
  49647. }
  49648. }
  49649. var ref = modifiers || {};
  49650. var lazy = ref.lazy;
  49651. var number = ref.number;
  49652. var trim = ref.trim;
  49653. var needCompositionGuard = !lazy && type !== 'range';
  49654. var event = lazy
  49655. ? 'change'
  49656. : type === 'range'
  49657. ? RANGE_TOKEN
  49658. : 'input';
  49659. var valueExpression = '$event.target.value';
  49660. if (trim) {
  49661. valueExpression = "$event.target.value.trim()";
  49662. }
  49663. if (number) {
  49664. valueExpression = "_n(" + valueExpression + ")";
  49665. }
  49666. var code = genAssignmentCode(value, valueExpression);
  49667. if (needCompositionGuard) {
  49668. code = "if($event.target.composing)return;" + code;
  49669. }
  49670. addProp(el, 'value', ("(" + value + ")"));
  49671. addHandler(el, event, code, null, true);
  49672. if (trim || number) {
  49673. addHandler(el, 'blur', '$forceUpdate()');
  49674. }
  49675. }
  49676. /* */
  49677. // normalize v-model event tokens that can only be determined at runtime.
  49678. // it's important to place the event as the first in the array because
  49679. // the whole point is ensuring the v-model callback gets called before
  49680. // user-attached handlers.
  49681. function normalizeEvents (on) {
  49682. /* istanbul ignore if */
  49683. if (isDef(on[RANGE_TOKEN])) {
  49684. // IE input[type=range] only supports `change` event
  49685. var event = isIE ? 'change' : 'input';
  49686. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  49687. delete on[RANGE_TOKEN];
  49688. }
  49689. // This was originally intended to fix #4521 but no longer necessary
  49690. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  49691. /* istanbul ignore if */
  49692. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  49693. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  49694. delete on[CHECKBOX_RADIO_TOKEN];
  49695. }
  49696. }
  49697. var target$1;
  49698. function createOnceHandler$1 (event, handler, capture) {
  49699. var _target = target$1; // save current target element in closure
  49700. return function onceHandler () {
  49701. var res = handler.apply(null, arguments);
  49702. if (res !== null) {
  49703. remove$2(event, onceHandler, capture, _target);
  49704. }
  49705. }
  49706. }
  49707. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  49708. // implementation and does not fire microtasks in between event propagation, so
  49709. // safe to exclude.
  49710. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  49711. function add$1 (
  49712. name,
  49713. handler,
  49714. capture,
  49715. passive
  49716. ) {
  49717. // async edge case #6566: inner click event triggers patch, event handler
  49718. // attached to outer element during patch, and triggered again. This
  49719. // happens because browsers fire microtask ticks between event propagation.
  49720. // the solution is simple: we save the timestamp when a handler is attached,
  49721. // and the handler would only fire if the event passed to it was fired
  49722. // AFTER it was attached.
  49723. if (useMicrotaskFix) {
  49724. var attachedTimestamp = currentFlushTimestamp;
  49725. var original = handler;
  49726. handler = original._wrapper = function (e) {
  49727. if (
  49728. // no bubbling, should always fire.
  49729. // this is just a safety net in case event.timeStamp is unreliable in
  49730. // certain weird environments...
  49731. e.target === e.currentTarget ||
  49732. // event is fired after handler attachment
  49733. e.timeStamp >= attachedTimestamp ||
  49734. // bail for environments that have buggy event.timeStamp implementations
  49735. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  49736. // #9681 QtWebEngine event.timeStamp is negative value
  49737. e.timeStamp <= 0 ||
  49738. // #9448 bail if event is fired in another document in a multi-page
  49739. // electron/nw.js app, since event.timeStamp will be using a different
  49740. // starting reference
  49741. e.target.ownerDocument !== document
  49742. ) {
  49743. return original.apply(this, arguments)
  49744. }
  49745. };
  49746. }
  49747. target$1.addEventListener(
  49748. name,
  49749. handler,
  49750. supportsPassive
  49751. ? { capture: capture, passive: passive }
  49752. : capture
  49753. );
  49754. }
  49755. function remove$2 (
  49756. name,
  49757. handler,
  49758. capture,
  49759. _target
  49760. ) {
  49761. (_target || target$1).removeEventListener(
  49762. name,
  49763. handler._wrapper || handler,
  49764. capture
  49765. );
  49766. }
  49767. function updateDOMListeners (oldVnode, vnode) {
  49768. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  49769. return
  49770. }
  49771. var on = vnode.data.on || {};
  49772. var oldOn = oldVnode.data.on || {};
  49773. target$1 = vnode.elm;
  49774. normalizeEvents(on);
  49775. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  49776. target$1 = undefined;
  49777. }
  49778. var events = {
  49779. create: updateDOMListeners,
  49780. update: updateDOMListeners
  49781. };
  49782. /* */
  49783. var svgContainer;
  49784. function updateDOMProps (oldVnode, vnode) {
  49785. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  49786. return
  49787. }
  49788. var key, cur;
  49789. var elm = vnode.elm;
  49790. var oldProps = oldVnode.data.domProps || {};
  49791. var props = vnode.data.domProps || {};
  49792. // clone observed objects, as the user probably wants to mutate it
  49793. if (isDef(props.__ob__)) {
  49794. props = vnode.data.domProps = extend({}, props);
  49795. }
  49796. for (key in oldProps) {
  49797. if (!(key in props)) {
  49798. elm[key] = '';
  49799. }
  49800. }
  49801. for (key in props) {
  49802. cur = props[key];
  49803. // ignore children if the node has textContent or innerHTML,
  49804. // as these will throw away existing DOM nodes and cause removal errors
  49805. // on subsequent patches (#3360)
  49806. if (key === 'textContent' || key === 'innerHTML') {
  49807. if (vnode.children) { vnode.children.length = 0; }
  49808. if (cur === oldProps[key]) { continue }
  49809. // #6601 work around Chrome version <= 55 bug where single textNode
  49810. // replaced by innerHTML/textContent retains its parentNode property
  49811. if (elm.childNodes.length === 1) {
  49812. elm.removeChild(elm.childNodes[0]);
  49813. }
  49814. }
  49815. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  49816. // store value as _value as well since
  49817. // non-string values will be stringified
  49818. elm._value = cur;
  49819. // avoid resetting cursor position when value is the same
  49820. var strCur = isUndef(cur) ? '' : String(cur);
  49821. if (shouldUpdateValue(elm, strCur)) {
  49822. elm.value = strCur;
  49823. }
  49824. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  49825. // IE doesn't support innerHTML for SVG elements
  49826. svgContainer = svgContainer || document.createElement('div');
  49827. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  49828. var svg = svgContainer.firstChild;
  49829. while (elm.firstChild) {
  49830. elm.removeChild(elm.firstChild);
  49831. }
  49832. while (svg.firstChild) {
  49833. elm.appendChild(svg.firstChild);
  49834. }
  49835. } else if (
  49836. // skip the update if old and new VDOM state is the same.
  49837. // `value` is handled separately because the DOM value may be temporarily
  49838. // out of sync with VDOM state due to focus, composition and modifiers.
  49839. // This #4521 by skipping the unnecesarry `checked` update.
  49840. cur !== oldProps[key]
  49841. ) {
  49842. // some property updates can throw
  49843. // e.g. `value` on <progress> w/ non-finite value
  49844. try {
  49845. elm[key] = cur;
  49846. } catch (e) {}
  49847. }
  49848. }
  49849. }
  49850. // check platforms/web/util/attrs.js acceptValue
  49851. function shouldUpdateValue (elm, checkVal) {
  49852. return (!elm.composing && (
  49853. elm.tagName === 'OPTION' ||
  49854. isNotInFocusAndDirty(elm, checkVal) ||
  49855. isDirtyWithModifiers(elm, checkVal)
  49856. ))
  49857. }
  49858. function isNotInFocusAndDirty (elm, checkVal) {
  49859. // return true when textbox (.number and .trim) loses focus and its value is
  49860. // not equal to the updated value
  49861. var notInFocus = true;
  49862. // #6157
  49863. // work around IE bug when accessing document.activeElement in an iframe
  49864. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  49865. return notInFocus && elm.value !== checkVal
  49866. }
  49867. function isDirtyWithModifiers (elm, newVal) {
  49868. var value = elm.value;
  49869. var modifiers = elm._vModifiers; // injected by v-model runtime
  49870. if (isDef(modifiers)) {
  49871. if (modifiers.number) {
  49872. return toNumber(value) !== toNumber(newVal)
  49873. }
  49874. if (modifiers.trim) {
  49875. return value.trim() !== newVal.trim()
  49876. }
  49877. }
  49878. return value !== newVal
  49879. }
  49880. var domProps = {
  49881. create: updateDOMProps,
  49882. update: updateDOMProps
  49883. };
  49884. /* */
  49885. var parseStyleText = cached(function (cssText) {
  49886. var res = {};
  49887. var listDelimiter = /;(?![^(]*\))/g;
  49888. var propertyDelimiter = /:(.+)/;
  49889. cssText.split(listDelimiter).forEach(function (item) {
  49890. if (item) {
  49891. var tmp = item.split(propertyDelimiter);
  49892. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  49893. }
  49894. });
  49895. return res
  49896. });
  49897. // merge static and dynamic style data on the same vnode
  49898. function normalizeStyleData (data) {
  49899. var style = normalizeStyleBinding(data.style);
  49900. // static style is pre-processed into an object during compilation
  49901. // and is always a fresh object, so it's safe to merge into it
  49902. return data.staticStyle
  49903. ? extend(data.staticStyle, style)
  49904. : style
  49905. }
  49906. // normalize possible array / string values into Object
  49907. function normalizeStyleBinding (bindingStyle) {
  49908. if (Array.isArray(bindingStyle)) {
  49909. return toObject(bindingStyle)
  49910. }
  49911. if (typeof bindingStyle === 'string') {
  49912. return parseStyleText(bindingStyle)
  49913. }
  49914. return bindingStyle
  49915. }
  49916. /**
  49917. * parent component style should be after child's
  49918. * so that parent component's style could override it
  49919. */
  49920. function getStyle (vnode, checkChild) {
  49921. var res = {};
  49922. var styleData;
  49923. if (checkChild) {
  49924. var childNode = vnode;
  49925. while (childNode.componentInstance) {
  49926. childNode = childNode.componentInstance._vnode;
  49927. if (
  49928. childNode && childNode.data &&
  49929. (styleData = normalizeStyleData(childNode.data))
  49930. ) {
  49931. extend(res, styleData);
  49932. }
  49933. }
  49934. }
  49935. if ((styleData = normalizeStyleData(vnode.data))) {
  49936. extend(res, styleData);
  49937. }
  49938. var parentNode = vnode;
  49939. while ((parentNode = parentNode.parent)) {
  49940. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  49941. extend(res, styleData);
  49942. }
  49943. }
  49944. return res
  49945. }
  49946. /* */
  49947. var cssVarRE = /^--/;
  49948. var importantRE = /\s*!important$/;
  49949. var setProp = function (el, name, val) {
  49950. /* istanbul ignore if */
  49951. if (cssVarRE.test(name)) {
  49952. el.style.setProperty(name, val);
  49953. } else if (importantRE.test(val)) {
  49954. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  49955. } else {
  49956. var normalizedName = normalize(name);
  49957. if (Array.isArray(val)) {
  49958. // Support values array created by autoprefixer, e.g.
  49959. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  49960. // Set them one by one, and the browser will only set those it can recognize
  49961. for (var i = 0, len = val.length; i < len; i++) {
  49962. el.style[normalizedName] = val[i];
  49963. }
  49964. } else {
  49965. el.style[normalizedName] = val;
  49966. }
  49967. }
  49968. };
  49969. var vendorNames = ['Webkit', 'Moz', 'ms'];
  49970. var emptyStyle;
  49971. var normalize = cached(function (prop) {
  49972. emptyStyle = emptyStyle || document.createElement('div').style;
  49973. prop = camelize(prop);
  49974. if (prop !== 'filter' && (prop in emptyStyle)) {
  49975. return prop
  49976. }
  49977. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  49978. for (var i = 0; i < vendorNames.length; i++) {
  49979. var name = vendorNames[i] + capName;
  49980. if (name in emptyStyle) {
  49981. return name
  49982. }
  49983. }
  49984. });
  49985. function updateStyle (oldVnode, vnode) {
  49986. var data = vnode.data;
  49987. var oldData = oldVnode.data;
  49988. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  49989. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  49990. ) {
  49991. return
  49992. }
  49993. var cur, name;
  49994. var el = vnode.elm;
  49995. var oldStaticStyle = oldData.staticStyle;
  49996. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  49997. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  49998. var oldStyle = oldStaticStyle || oldStyleBinding;
  49999. var style = normalizeStyleBinding(vnode.data.style) || {};
  50000. // store normalized style under a different key for next diff
  50001. // make sure to clone it if it's reactive, since the user likely wants
  50002. // to mutate it.
  50003. vnode.data.normalizedStyle = isDef(style.__ob__)
  50004. ? extend({}, style)
  50005. : style;
  50006. var newStyle = getStyle(vnode, true);
  50007. for (name in oldStyle) {
  50008. if (isUndef(newStyle[name])) {
  50009. setProp(el, name, '');
  50010. }
  50011. }
  50012. for (name in newStyle) {
  50013. cur = newStyle[name];
  50014. if (cur !== oldStyle[name]) {
  50015. // ie9 setting to null has no effect, must use empty string
  50016. setProp(el, name, cur == null ? '' : cur);
  50017. }
  50018. }
  50019. }
  50020. var style = {
  50021. create: updateStyle,
  50022. update: updateStyle
  50023. };
  50024. /* */
  50025. var whitespaceRE = /\s+/;
  50026. /**
  50027. * Add class with compatibility for SVG since classList is not supported on
  50028. * SVG elements in IE
  50029. */
  50030. function addClass (el, cls) {
  50031. /* istanbul ignore if */
  50032. if (!cls || !(cls = cls.trim())) {
  50033. return
  50034. }
  50035. /* istanbul ignore else */
  50036. if (el.classList) {
  50037. if (cls.indexOf(' ') > -1) {
  50038. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  50039. } else {
  50040. el.classList.add(cls);
  50041. }
  50042. } else {
  50043. var cur = " " + (el.getAttribute('class') || '') + " ";
  50044. if (cur.indexOf(' ' + cls + ' ') < 0) {
  50045. el.setAttribute('class', (cur + cls).trim());
  50046. }
  50047. }
  50048. }
  50049. /**
  50050. * Remove class with compatibility for SVG since classList is not supported on
  50051. * SVG elements in IE
  50052. */
  50053. function removeClass (el, cls) {
  50054. /* istanbul ignore if */
  50055. if (!cls || !(cls = cls.trim())) {
  50056. return
  50057. }
  50058. /* istanbul ignore else */
  50059. if (el.classList) {
  50060. if (cls.indexOf(' ') > -1) {
  50061. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  50062. } else {
  50063. el.classList.remove(cls);
  50064. }
  50065. if (!el.classList.length) {
  50066. el.removeAttribute('class');
  50067. }
  50068. } else {
  50069. var cur = " " + (el.getAttribute('class') || '') + " ";
  50070. var tar = ' ' + cls + ' ';
  50071. while (cur.indexOf(tar) >= 0) {
  50072. cur = cur.replace(tar, ' ');
  50073. }
  50074. cur = cur.trim();
  50075. if (cur) {
  50076. el.setAttribute('class', cur);
  50077. } else {
  50078. el.removeAttribute('class');
  50079. }
  50080. }
  50081. }
  50082. /* */
  50083. function resolveTransition (def$$1) {
  50084. if (!def$$1) {
  50085. return
  50086. }
  50087. /* istanbul ignore else */
  50088. if (typeof def$$1 === 'object') {
  50089. var res = {};
  50090. if (def$$1.css !== false) {
  50091. extend(res, autoCssTransition(def$$1.name || 'v'));
  50092. }
  50093. extend(res, def$$1);
  50094. return res
  50095. } else if (typeof def$$1 === 'string') {
  50096. return autoCssTransition(def$$1)
  50097. }
  50098. }
  50099. var autoCssTransition = cached(function (name) {
  50100. return {
  50101. enterClass: (name + "-enter"),
  50102. enterToClass: (name + "-enter-to"),
  50103. enterActiveClass: (name + "-enter-active"),
  50104. leaveClass: (name + "-leave"),
  50105. leaveToClass: (name + "-leave-to"),
  50106. leaveActiveClass: (name + "-leave-active")
  50107. }
  50108. });
  50109. var hasTransition = inBrowser && !isIE9;
  50110. var TRANSITION = 'transition';
  50111. var ANIMATION = 'animation';
  50112. // Transition property/event sniffing
  50113. var transitionProp = 'transition';
  50114. var transitionEndEvent = 'transitionend';
  50115. var animationProp = 'animation';
  50116. var animationEndEvent = 'animationend';
  50117. if (hasTransition) {
  50118. /* istanbul ignore if */
  50119. if (window.ontransitionend === undefined &&
  50120. window.onwebkittransitionend !== undefined
  50121. ) {
  50122. transitionProp = 'WebkitTransition';
  50123. transitionEndEvent = 'webkitTransitionEnd';
  50124. }
  50125. if (window.onanimationend === undefined &&
  50126. window.onwebkitanimationend !== undefined
  50127. ) {
  50128. animationProp = 'WebkitAnimation';
  50129. animationEndEvent = 'webkitAnimationEnd';
  50130. }
  50131. }
  50132. // binding to window is necessary to make hot reload work in IE in strict mode
  50133. var raf = inBrowser
  50134. ? window.requestAnimationFrame
  50135. ? window.requestAnimationFrame.bind(window)
  50136. : setTimeout
  50137. : /* istanbul ignore next */ function (fn) { return fn(); };
  50138. function nextFrame (fn) {
  50139. raf(function () {
  50140. raf(fn);
  50141. });
  50142. }
  50143. function addTransitionClass (el, cls) {
  50144. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  50145. if (transitionClasses.indexOf(cls) < 0) {
  50146. transitionClasses.push(cls);
  50147. addClass(el, cls);
  50148. }
  50149. }
  50150. function removeTransitionClass (el, cls) {
  50151. if (el._transitionClasses) {
  50152. remove(el._transitionClasses, cls);
  50153. }
  50154. removeClass(el, cls);
  50155. }
  50156. function whenTransitionEnds (
  50157. el,
  50158. expectedType,
  50159. cb
  50160. ) {
  50161. var ref = getTransitionInfo(el, expectedType);
  50162. var type = ref.type;
  50163. var timeout = ref.timeout;
  50164. var propCount = ref.propCount;
  50165. if (!type) { return cb() }
  50166. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  50167. var ended = 0;
  50168. var end = function () {
  50169. el.removeEventListener(event, onEnd);
  50170. cb();
  50171. };
  50172. var onEnd = function (e) {
  50173. if (e.target === el) {
  50174. if (++ended >= propCount) {
  50175. end();
  50176. }
  50177. }
  50178. };
  50179. setTimeout(function () {
  50180. if (ended < propCount) {
  50181. end();
  50182. }
  50183. }, timeout + 1);
  50184. el.addEventListener(event, onEnd);
  50185. }
  50186. var transformRE = /\b(transform|all)(,|$)/;
  50187. function getTransitionInfo (el, expectedType) {
  50188. var styles = window.getComputedStyle(el);
  50189. // JSDOM may return undefined for transition properties
  50190. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  50191. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  50192. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  50193. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  50194. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  50195. var animationTimeout = getTimeout(animationDelays, animationDurations);
  50196. var type;
  50197. var timeout = 0;
  50198. var propCount = 0;
  50199. /* istanbul ignore if */
  50200. if (expectedType === TRANSITION) {
  50201. if (transitionTimeout > 0) {
  50202. type = TRANSITION;
  50203. timeout = transitionTimeout;
  50204. propCount = transitionDurations.length;
  50205. }
  50206. } else if (expectedType === ANIMATION) {
  50207. if (animationTimeout > 0) {
  50208. type = ANIMATION;
  50209. timeout = animationTimeout;
  50210. propCount = animationDurations.length;
  50211. }
  50212. } else {
  50213. timeout = Math.max(transitionTimeout, animationTimeout);
  50214. type = timeout > 0
  50215. ? transitionTimeout > animationTimeout
  50216. ? TRANSITION
  50217. : ANIMATION
  50218. : null;
  50219. propCount = type
  50220. ? type === TRANSITION
  50221. ? transitionDurations.length
  50222. : animationDurations.length
  50223. : 0;
  50224. }
  50225. var hasTransform =
  50226. type === TRANSITION &&
  50227. transformRE.test(styles[transitionProp + 'Property']);
  50228. return {
  50229. type: type,
  50230. timeout: timeout,
  50231. propCount: propCount,
  50232. hasTransform: hasTransform
  50233. }
  50234. }
  50235. function getTimeout (delays, durations) {
  50236. /* istanbul ignore next */
  50237. while (delays.length < durations.length) {
  50238. delays = delays.concat(delays);
  50239. }
  50240. return Math.max.apply(null, durations.map(function (d, i) {
  50241. return toMs(d) + toMs(delays[i])
  50242. }))
  50243. }
  50244. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  50245. // in a locale-dependent way, using a comma instead of a dot.
  50246. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  50247. // as a floor function) causing unexpected behaviors
  50248. function toMs (s) {
  50249. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  50250. }
  50251. /* */
  50252. function enter (vnode, toggleDisplay) {
  50253. var el = vnode.elm;
  50254. // call leave callback now
  50255. if (isDef(el._leaveCb)) {
  50256. el._leaveCb.cancelled = true;
  50257. el._leaveCb();
  50258. }
  50259. var data = resolveTransition(vnode.data.transition);
  50260. if (isUndef(data)) {
  50261. return
  50262. }
  50263. /* istanbul ignore if */
  50264. if (isDef(el._enterCb) || el.nodeType !== 1) {
  50265. return
  50266. }
  50267. var css = data.css;
  50268. var type = data.type;
  50269. var enterClass = data.enterClass;
  50270. var enterToClass = data.enterToClass;
  50271. var enterActiveClass = data.enterActiveClass;
  50272. var appearClass = data.appearClass;
  50273. var appearToClass = data.appearToClass;
  50274. var appearActiveClass = data.appearActiveClass;
  50275. var beforeEnter = data.beforeEnter;
  50276. var enter = data.enter;
  50277. var afterEnter = data.afterEnter;
  50278. var enterCancelled = data.enterCancelled;
  50279. var beforeAppear = data.beforeAppear;
  50280. var appear = data.appear;
  50281. var afterAppear = data.afterAppear;
  50282. var appearCancelled = data.appearCancelled;
  50283. var duration = data.duration;
  50284. // activeInstance will always be the <transition> component managing this
  50285. // transition. One edge case to check is when the <transition> is placed
  50286. // as the root node of a child component. In that case we need to check
  50287. // <transition>'s parent for appear check.
  50288. var context = activeInstance;
  50289. var transitionNode = activeInstance.$vnode;
  50290. while (transitionNode && transitionNode.parent) {
  50291. context = transitionNode.context;
  50292. transitionNode = transitionNode.parent;
  50293. }
  50294. var isAppear = !context._isMounted || !vnode.isRootInsert;
  50295. if (isAppear && !appear && appear !== '') {
  50296. return
  50297. }
  50298. var startClass = isAppear && appearClass
  50299. ? appearClass
  50300. : enterClass;
  50301. var activeClass = isAppear && appearActiveClass
  50302. ? appearActiveClass
  50303. : enterActiveClass;
  50304. var toClass = isAppear && appearToClass
  50305. ? appearToClass
  50306. : enterToClass;
  50307. var beforeEnterHook = isAppear
  50308. ? (beforeAppear || beforeEnter)
  50309. : beforeEnter;
  50310. var enterHook = isAppear
  50311. ? (typeof appear === 'function' ? appear : enter)
  50312. : enter;
  50313. var afterEnterHook = isAppear
  50314. ? (afterAppear || afterEnter)
  50315. : afterEnter;
  50316. var enterCancelledHook = isAppear
  50317. ? (appearCancelled || enterCancelled)
  50318. : enterCancelled;
  50319. var explicitEnterDuration = toNumber(
  50320. isObject(duration)
  50321. ? duration.enter
  50322. : duration
  50323. );
  50324. if (explicitEnterDuration != null) {
  50325. checkDuration(explicitEnterDuration, 'enter', vnode);
  50326. }
  50327. var expectsCSS = css !== false && !isIE9;
  50328. var userWantsControl = getHookArgumentsLength(enterHook);
  50329. var cb = el._enterCb = once(function () {
  50330. if (expectsCSS) {
  50331. removeTransitionClass(el, toClass);
  50332. removeTransitionClass(el, activeClass);
  50333. }
  50334. if (cb.cancelled) {
  50335. if (expectsCSS) {
  50336. removeTransitionClass(el, startClass);
  50337. }
  50338. enterCancelledHook && enterCancelledHook(el);
  50339. } else {
  50340. afterEnterHook && afterEnterHook(el);
  50341. }
  50342. el._enterCb = null;
  50343. });
  50344. if (!vnode.data.show) {
  50345. // remove pending leave element on enter by injecting an insert hook
  50346. mergeVNodeHook(vnode, 'insert', function () {
  50347. var parent = el.parentNode;
  50348. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  50349. if (pendingNode &&
  50350. pendingNode.tag === vnode.tag &&
  50351. pendingNode.elm._leaveCb
  50352. ) {
  50353. pendingNode.elm._leaveCb();
  50354. }
  50355. enterHook && enterHook(el, cb);
  50356. });
  50357. }
  50358. // start enter transition
  50359. beforeEnterHook && beforeEnterHook(el);
  50360. if (expectsCSS) {
  50361. addTransitionClass(el, startClass);
  50362. addTransitionClass(el, activeClass);
  50363. nextFrame(function () {
  50364. removeTransitionClass(el, startClass);
  50365. if (!cb.cancelled) {
  50366. addTransitionClass(el, toClass);
  50367. if (!userWantsControl) {
  50368. if (isValidDuration(explicitEnterDuration)) {
  50369. setTimeout(cb, explicitEnterDuration);
  50370. } else {
  50371. whenTransitionEnds(el, type, cb);
  50372. }
  50373. }
  50374. }
  50375. });
  50376. }
  50377. if (vnode.data.show) {
  50378. toggleDisplay && toggleDisplay();
  50379. enterHook && enterHook(el, cb);
  50380. }
  50381. if (!expectsCSS && !userWantsControl) {
  50382. cb();
  50383. }
  50384. }
  50385. function leave (vnode, rm) {
  50386. var el = vnode.elm;
  50387. // call enter callback now
  50388. if (isDef(el._enterCb)) {
  50389. el._enterCb.cancelled = true;
  50390. el._enterCb();
  50391. }
  50392. var data = resolveTransition(vnode.data.transition);
  50393. if (isUndef(data) || el.nodeType !== 1) {
  50394. return rm()
  50395. }
  50396. /* istanbul ignore if */
  50397. if (isDef(el._leaveCb)) {
  50398. return
  50399. }
  50400. var css = data.css;
  50401. var type = data.type;
  50402. var leaveClass = data.leaveClass;
  50403. var leaveToClass = data.leaveToClass;
  50404. var leaveActiveClass = data.leaveActiveClass;
  50405. var beforeLeave = data.beforeLeave;
  50406. var leave = data.leave;
  50407. var afterLeave = data.afterLeave;
  50408. var leaveCancelled = data.leaveCancelled;
  50409. var delayLeave = data.delayLeave;
  50410. var duration = data.duration;
  50411. var expectsCSS = css !== false && !isIE9;
  50412. var userWantsControl = getHookArgumentsLength(leave);
  50413. var explicitLeaveDuration = toNumber(
  50414. isObject(duration)
  50415. ? duration.leave
  50416. : duration
  50417. );
  50418. if (isDef(explicitLeaveDuration)) {
  50419. checkDuration(explicitLeaveDuration, 'leave', vnode);
  50420. }
  50421. var cb = el._leaveCb = once(function () {
  50422. if (el.parentNode && el.parentNode._pending) {
  50423. el.parentNode._pending[vnode.key] = null;
  50424. }
  50425. if (expectsCSS) {
  50426. removeTransitionClass(el, leaveToClass);
  50427. removeTransitionClass(el, leaveActiveClass);
  50428. }
  50429. if (cb.cancelled) {
  50430. if (expectsCSS) {
  50431. removeTransitionClass(el, leaveClass);
  50432. }
  50433. leaveCancelled && leaveCancelled(el);
  50434. } else {
  50435. rm();
  50436. afterLeave && afterLeave(el);
  50437. }
  50438. el._leaveCb = null;
  50439. });
  50440. if (delayLeave) {
  50441. delayLeave(performLeave);
  50442. } else {
  50443. performLeave();
  50444. }
  50445. function performLeave () {
  50446. // the delayed leave may have already been cancelled
  50447. if (cb.cancelled) {
  50448. return
  50449. }
  50450. // record leaving element
  50451. if (!vnode.data.show && el.parentNode) {
  50452. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  50453. }
  50454. beforeLeave && beforeLeave(el);
  50455. if (expectsCSS) {
  50456. addTransitionClass(el, leaveClass);
  50457. addTransitionClass(el, leaveActiveClass);
  50458. nextFrame(function () {
  50459. removeTransitionClass(el, leaveClass);
  50460. if (!cb.cancelled) {
  50461. addTransitionClass(el, leaveToClass);
  50462. if (!userWantsControl) {
  50463. if (isValidDuration(explicitLeaveDuration)) {
  50464. setTimeout(cb, explicitLeaveDuration);
  50465. } else {
  50466. whenTransitionEnds(el, type, cb);
  50467. }
  50468. }
  50469. }
  50470. });
  50471. }
  50472. leave && leave(el, cb);
  50473. if (!expectsCSS && !userWantsControl) {
  50474. cb();
  50475. }
  50476. }
  50477. }
  50478. // only used in dev mode
  50479. function checkDuration (val, name, vnode) {
  50480. if (typeof val !== 'number') {
  50481. warn(
  50482. "<transition> explicit " + name + " duration is not a valid number - " +
  50483. "got " + (JSON.stringify(val)) + ".",
  50484. vnode.context
  50485. );
  50486. } else if (isNaN(val)) {
  50487. warn(
  50488. "<transition> explicit " + name + " duration is NaN - " +
  50489. 'the duration expression might be incorrect.',
  50490. vnode.context
  50491. );
  50492. }
  50493. }
  50494. function isValidDuration (val) {
  50495. return typeof val === 'number' && !isNaN(val)
  50496. }
  50497. /**
  50498. * Normalize a transition hook's argument length. The hook may be:
  50499. * - a merged hook (invoker) with the original in .fns
  50500. * - a wrapped component method (check ._length)
  50501. * - a plain function (.length)
  50502. */
  50503. function getHookArgumentsLength (fn) {
  50504. if (isUndef(fn)) {
  50505. return false
  50506. }
  50507. var invokerFns = fn.fns;
  50508. if (isDef(invokerFns)) {
  50509. // invoker
  50510. return getHookArgumentsLength(
  50511. Array.isArray(invokerFns)
  50512. ? invokerFns[0]
  50513. : invokerFns
  50514. )
  50515. } else {
  50516. return (fn._length || fn.length) > 1
  50517. }
  50518. }
  50519. function _enter (_, vnode) {
  50520. if (vnode.data.show !== true) {
  50521. enter(vnode);
  50522. }
  50523. }
  50524. var transition = inBrowser ? {
  50525. create: _enter,
  50526. activate: _enter,
  50527. remove: function remove$$1 (vnode, rm) {
  50528. /* istanbul ignore else */
  50529. if (vnode.data.show !== true) {
  50530. leave(vnode, rm);
  50531. } else {
  50532. rm();
  50533. }
  50534. }
  50535. } : {};
  50536. var platformModules = [
  50537. attrs,
  50538. klass,
  50539. events,
  50540. domProps,
  50541. style,
  50542. transition
  50543. ];
  50544. /* */
  50545. // the directive module should be applied last, after all
  50546. // built-in modules have been applied.
  50547. var modules = platformModules.concat(baseModules);
  50548. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  50549. /**
  50550. * Not type checking this file because flow doesn't like attaching
  50551. * properties to Elements.
  50552. */
  50553. /* istanbul ignore if */
  50554. if (isIE9) {
  50555. // http://www.matts411.com/post/internet-explorer-9-oninput/
  50556. document.addEventListener('selectionchange', function () {
  50557. var el = document.activeElement;
  50558. if (el && el.vmodel) {
  50559. trigger(el, 'input');
  50560. }
  50561. });
  50562. }
  50563. var directive = {
  50564. inserted: function inserted (el, binding, vnode, oldVnode) {
  50565. if (vnode.tag === 'select') {
  50566. // #6903
  50567. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  50568. mergeVNodeHook(vnode, 'postpatch', function () {
  50569. directive.componentUpdated(el, binding, vnode);
  50570. });
  50571. } else {
  50572. setSelected(el, binding, vnode.context);
  50573. }
  50574. el._vOptions = [].map.call(el.options, getValue);
  50575. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  50576. el._vModifiers = binding.modifiers;
  50577. if (!binding.modifiers.lazy) {
  50578. el.addEventListener('compositionstart', onCompositionStart);
  50579. el.addEventListener('compositionend', onCompositionEnd);
  50580. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  50581. // switching focus before confirming composition choice
  50582. // this also fixes the issue where some browsers e.g. iOS Chrome
  50583. // fires "change" instead of "input" on autocomplete.
  50584. el.addEventListener('change', onCompositionEnd);
  50585. /* istanbul ignore if */
  50586. if (isIE9) {
  50587. el.vmodel = true;
  50588. }
  50589. }
  50590. }
  50591. },
  50592. componentUpdated: function componentUpdated (el, binding, vnode) {
  50593. if (vnode.tag === 'select') {
  50594. setSelected(el, binding, vnode.context);
  50595. // in case the options rendered by v-for have changed,
  50596. // it's possible that the value is out-of-sync with the rendered options.
  50597. // detect such cases and filter out values that no longer has a matching
  50598. // option in the DOM.
  50599. var prevOptions = el._vOptions;
  50600. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  50601. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  50602. // trigger change event if
  50603. // no matching option found for at least one value
  50604. var needReset = el.multiple
  50605. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  50606. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  50607. if (needReset) {
  50608. trigger(el, 'change');
  50609. }
  50610. }
  50611. }
  50612. }
  50613. };
  50614. function setSelected (el, binding, vm) {
  50615. actuallySetSelected(el, binding, vm);
  50616. /* istanbul ignore if */
  50617. if (isIE || isEdge) {
  50618. setTimeout(function () {
  50619. actuallySetSelected(el, binding, vm);
  50620. }, 0);
  50621. }
  50622. }
  50623. function actuallySetSelected (el, binding, vm) {
  50624. var value = binding.value;
  50625. var isMultiple = el.multiple;
  50626. if (isMultiple && !Array.isArray(value)) {
  50627. warn(
  50628. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  50629. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  50630. vm
  50631. );
  50632. return
  50633. }
  50634. var selected, option;
  50635. for (var i = 0, l = el.options.length; i < l; i++) {
  50636. option = el.options[i];
  50637. if (isMultiple) {
  50638. selected = looseIndexOf(value, getValue(option)) > -1;
  50639. if (option.selected !== selected) {
  50640. option.selected = selected;
  50641. }
  50642. } else {
  50643. if (looseEqual(getValue(option), value)) {
  50644. if (el.selectedIndex !== i) {
  50645. el.selectedIndex = i;
  50646. }
  50647. return
  50648. }
  50649. }
  50650. }
  50651. if (!isMultiple) {
  50652. el.selectedIndex = -1;
  50653. }
  50654. }
  50655. function hasNoMatchingOption (value, options) {
  50656. return options.every(function (o) { return !looseEqual(o, value); })
  50657. }
  50658. function getValue (option) {
  50659. return '_value' in option
  50660. ? option._value
  50661. : option.value
  50662. }
  50663. function onCompositionStart (e) {
  50664. e.target.composing = true;
  50665. }
  50666. function onCompositionEnd (e) {
  50667. // prevent triggering an input event for no reason
  50668. if (!e.target.composing) { return }
  50669. e.target.composing = false;
  50670. trigger(e.target, 'input');
  50671. }
  50672. function trigger (el, type) {
  50673. var e = document.createEvent('HTMLEvents');
  50674. e.initEvent(type, true, true);
  50675. el.dispatchEvent(e);
  50676. }
  50677. /* */
  50678. // recursively search for possible transition defined inside the component root
  50679. function locateNode (vnode) {
  50680. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  50681. ? locateNode(vnode.componentInstance._vnode)
  50682. : vnode
  50683. }
  50684. var show = {
  50685. bind: function bind (el, ref, vnode) {
  50686. var value = ref.value;
  50687. vnode = locateNode(vnode);
  50688. var transition$$1 = vnode.data && vnode.data.transition;
  50689. var originalDisplay = el.__vOriginalDisplay =
  50690. el.style.display === 'none' ? '' : el.style.display;
  50691. if (value && transition$$1) {
  50692. vnode.data.show = true;
  50693. enter(vnode, function () {
  50694. el.style.display = originalDisplay;
  50695. });
  50696. } else {
  50697. el.style.display = value ? originalDisplay : 'none';
  50698. }
  50699. },
  50700. update: function update (el, ref, vnode) {
  50701. var value = ref.value;
  50702. var oldValue = ref.oldValue;
  50703. /* istanbul ignore if */
  50704. if (!value === !oldValue) { return }
  50705. vnode = locateNode(vnode);
  50706. var transition$$1 = vnode.data && vnode.data.transition;
  50707. if (transition$$1) {
  50708. vnode.data.show = true;
  50709. if (value) {
  50710. enter(vnode, function () {
  50711. el.style.display = el.__vOriginalDisplay;
  50712. });
  50713. } else {
  50714. leave(vnode, function () {
  50715. el.style.display = 'none';
  50716. });
  50717. }
  50718. } else {
  50719. el.style.display = value ? el.__vOriginalDisplay : 'none';
  50720. }
  50721. },
  50722. unbind: function unbind (
  50723. el,
  50724. binding,
  50725. vnode,
  50726. oldVnode,
  50727. isDestroy
  50728. ) {
  50729. if (!isDestroy) {
  50730. el.style.display = el.__vOriginalDisplay;
  50731. }
  50732. }
  50733. };
  50734. var platformDirectives = {
  50735. model: directive,
  50736. show: show
  50737. };
  50738. /* */
  50739. var transitionProps = {
  50740. name: String,
  50741. appear: Boolean,
  50742. css: Boolean,
  50743. mode: String,
  50744. type: String,
  50745. enterClass: String,
  50746. leaveClass: String,
  50747. enterToClass: String,
  50748. leaveToClass: String,
  50749. enterActiveClass: String,
  50750. leaveActiveClass: String,
  50751. appearClass: String,
  50752. appearActiveClass: String,
  50753. appearToClass: String,
  50754. duration: [Number, String, Object]
  50755. };
  50756. // in case the child is also an abstract component, e.g. <keep-alive>
  50757. // we want to recursively retrieve the real component to be rendered
  50758. function getRealChild (vnode) {
  50759. var compOptions = vnode && vnode.componentOptions;
  50760. if (compOptions && compOptions.Ctor.options.abstract) {
  50761. return getRealChild(getFirstComponentChild(compOptions.children))
  50762. } else {
  50763. return vnode
  50764. }
  50765. }
  50766. function extractTransitionData (comp) {
  50767. var data = {};
  50768. var options = comp.$options;
  50769. // props
  50770. for (var key in options.propsData) {
  50771. data[key] = comp[key];
  50772. }
  50773. // events.
  50774. // extract listeners and pass them directly to the transition methods
  50775. var listeners = options._parentListeners;
  50776. for (var key$1 in listeners) {
  50777. data[camelize(key$1)] = listeners[key$1];
  50778. }
  50779. return data
  50780. }
  50781. function placeholder (h, rawChild) {
  50782. if (/\d-keep-alive$/.test(rawChild.tag)) {
  50783. return h('keep-alive', {
  50784. props: rawChild.componentOptions.propsData
  50785. })
  50786. }
  50787. }
  50788. function hasParentTransition (vnode) {
  50789. while ((vnode = vnode.parent)) {
  50790. if (vnode.data.transition) {
  50791. return true
  50792. }
  50793. }
  50794. }
  50795. function isSameChild (child, oldChild) {
  50796. return oldChild.key === child.key && oldChild.tag === child.tag
  50797. }
  50798. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  50799. var isVShowDirective = function (d) { return d.name === 'show'; };
  50800. var Transition = {
  50801. name: 'transition',
  50802. props: transitionProps,
  50803. abstract: true,
  50804. render: function render (h) {
  50805. var this$1 = this;
  50806. var children = this.$slots.default;
  50807. if (!children) {
  50808. return
  50809. }
  50810. // filter out text nodes (possible whitespaces)
  50811. children = children.filter(isNotTextNode);
  50812. /* istanbul ignore if */
  50813. if (!children.length) {
  50814. return
  50815. }
  50816. // warn multiple elements
  50817. if (children.length > 1) {
  50818. warn(
  50819. '<transition> can only be used on a single element. Use ' +
  50820. '<transition-group> for lists.',
  50821. this.$parent
  50822. );
  50823. }
  50824. var mode = this.mode;
  50825. // warn invalid mode
  50826. if (mode && mode !== 'in-out' && mode !== 'out-in'
  50827. ) {
  50828. warn(
  50829. 'invalid <transition> mode: ' + mode,
  50830. this.$parent
  50831. );
  50832. }
  50833. var rawChild = children[0];
  50834. // if this is a component root node and the component's
  50835. // parent container node also has transition, skip.
  50836. if (hasParentTransition(this.$vnode)) {
  50837. return rawChild
  50838. }
  50839. // apply transition data to child
  50840. // use getRealChild() to ignore abstract components e.g. keep-alive
  50841. var child = getRealChild(rawChild);
  50842. /* istanbul ignore if */
  50843. if (!child) {
  50844. return rawChild
  50845. }
  50846. if (this._leaving) {
  50847. return placeholder(h, rawChild)
  50848. }
  50849. // ensure a key that is unique to the vnode type and to this transition
  50850. // component instance. This key will be used to remove pending leaving nodes
  50851. // during entering.
  50852. var id = "__transition-" + (this._uid) + "-";
  50853. child.key = child.key == null
  50854. ? child.isComment
  50855. ? id + 'comment'
  50856. : id + child.tag
  50857. : isPrimitive(child.key)
  50858. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  50859. : child.key;
  50860. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  50861. var oldRawChild = this._vnode;
  50862. var oldChild = getRealChild(oldRawChild);
  50863. // mark v-show
  50864. // so that the transition module can hand over the control to the directive
  50865. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  50866. child.data.show = true;
  50867. }
  50868. if (
  50869. oldChild &&
  50870. oldChild.data &&
  50871. !isSameChild(child, oldChild) &&
  50872. !isAsyncPlaceholder(oldChild) &&
  50873. // #6687 component root is a comment node
  50874. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  50875. ) {
  50876. // replace old child transition data with fresh one
  50877. // important for dynamic transitions!
  50878. var oldData = oldChild.data.transition = extend({}, data);
  50879. // handle transition mode
  50880. if (mode === 'out-in') {
  50881. // return placeholder node and queue update when leave finishes
  50882. this._leaving = true;
  50883. mergeVNodeHook(oldData, 'afterLeave', function () {
  50884. this$1._leaving = false;
  50885. this$1.$forceUpdate();
  50886. });
  50887. return placeholder(h, rawChild)
  50888. } else if (mode === 'in-out') {
  50889. if (isAsyncPlaceholder(child)) {
  50890. return oldRawChild
  50891. }
  50892. var delayedLeave;
  50893. var performLeave = function () { delayedLeave(); };
  50894. mergeVNodeHook(data, 'afterEnter', performLeave);
  50895. mergeVNodeHook(data, 'enterCancelled', performLeave);
  50896. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  50897. }
  50898. }
  50899. return rawChild
  50900. }
  50901. };
  50902. /* */
  50903. var props = extend({
  50904. tag: String,
  50905. moveClass: String
  50906. }, transitionProps);
  50907. delete props.mode;
  50908. var TransitionGroup = {
  50909. props: props,
  50910. beforeMount: function beforeMount () {
  50911. var this$1 = this;
  50912. var update = this._update;
  50913. this._update = function (vnode, hydrating) {
  50914. var restoreActiveInstance = setActiveInstance(this$1);
  50915. // force removing pass
  50916. this$1.__patch__(
  50917. this$1._vnode,
  50918. this$1.kept,
  50919. false, // hydrating
  50920. true // removeOnly (!important, avoids unnecessary moves)
  50921. );
  50922. this$1._vnode = this$1.kept;
  50923. restoreActiveInstance();
  50924. update.call(this$1, vnode, hydrating);
  50925. };
  50926. },
  50927. render: function render (h) {
  50928. var tag = this.tag || this.$vnode.data.tag || 'span';
  50929. var map = Object.create(null);
  50930. var prevChildren = this.prevChildren = this.children;
  50931. var rawChildren = this.$slots.default || [];
  50932. var children = this.children = [];
  50933. var transitionData = extractTransitionData(this);
  50934. for (var i = 0; i < rawChildren.length; i++) {
  50935. var c = rawChildren[i];
  50936. if (c.tag) {
  50937. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  50938. children.push(c);
  50939. map[c.key] = c
  50940. ;(c.data || (c.data = {})).transition = transitionData;
  50941. } else {
  50942. var opts = c.componentOptions;
  50943. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  50944. warn(("<transition-group> children must be keyed: <" + name + ">"));
  50945. }
  50946. }
  50947. }
  50948. if (prevChildren) {
  50949. var kept = [];
  50950. var removed = [];
  50951. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  50952. var c$1 = prevChildren[i$1];
  50953. c$1.data.transition = transitionData;
  50954. c$1.data.pos = c$1.elm.getBoundingClientRect();
  50955. if (map[c$1.key]) {
  50956. kept.push(c$1);
  50957. } else {
  50958. removed.push(c$1);
  50959. }
  50960. }
  50961. this.kept = h(tag, null, kept);
  50962. this.removed = removed;
  50963. }
  50964. return h(tag, null, children)
  50965. },
  50966. updated: function updated () {
  50967. var children = this.prevChildren;
  50968. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  50969. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  50970. return
  50971. }
  50972. // we divide the work into three loops to avoid mixing DOM reads and writes
  50973. // in each iteration - which helps prevent layout thrashing.
  50974. children.forEach(callPendingCbs);
  50975. children.forEach(recordPosition);
  50976. children.forEach(applyTranslation);
  50977. // force reflow to put everything in position
  50978. // assign to this to avoid being removed in tree-shaking
  50979. // $flow-disable-line
  50980. this._reflow = document.body.offsetHeight;
  50981. children.forEach(function (c) {
  50982. if (c.data.moved) {
  50983. var el = c.elm;
  50984. var s = el.style;
  50985. addTransitionClass(el, moveClass);
  50986. s.transform = s.WebkitTransform = s.transitionDuration = '';
  50987. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  50988. if (e && e.target !== el) {
  50989. return
  50990. }
  50991. if (!e || /transform$/.test(e.propertyName)) {
  50992. el.removeEventListener(transitionEndEvent, cb);
  50993. el._moveCb = null;
  50994. removeTransitionClass(el, moveClass);
  50995. }
  50996. });
  50997. }
  50998. });
  50999. },
  51000. methods: {
  51001. hasMove: function hasMove (el, moveClass) {
  51002. /* istanbul ignore if */
  51003. if (!hasTransition) {
  51004. return false
  51005. }
  51006. /* istanbul ignore if */
  51007. if (this._hasMove) {
  51008. return this._hasMove
  51009. }
  51010. // Detect whether an element with the move class applied has
  51011. // CSS transitions. Since the element may be inside an entering
  51012. // transition at this very moment, we make a clone of it and remove
  51013. // all other transition classes applied to ensure only the move class
  51014. // is applied.
  51015. var clone = el.cloneNode();
  51016. if (el._transitionClasses) {
  51017. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  51018. }
  51019. addClass(clone, moveClass);
  51020. clone.style.display = 'none';
  51021. this.$el.appendChild(clone);
  51022. var info = getTransitionInfo(clone);
  51023. this.$el.removeChild(clone);
  51024. return (this._hasMove = info.hasTransform)
  51025. }
  51026. }
  51027. };
  51028. function callPendingCbs (c) {
  51029. /* istanbul ignore if */
  51030. if (c.elm._moveCb) {
  51031. c.elm._moveCb();
  51032. }
  51033. /* istanbul ignore if */
  51034. if (c.elm._enterCb) {
  51035. c.elm._enterCb();
  51036. }
  51037. }
  51038. function recordPosition (c) {
  51039. c.data.newPos = c.elm.getBoundingClientRect();
  51040. }
  51041. function applyTranslation (c) {
  51042. var oldPos = c.data.pos;
  51043. var newPos = c.data.newPos;
  51044. var dx = oldPos.left - newPos.left;
  51045. var dy = oldPos.top - newPos.top;
  51046. if (dx || dy) {
  51047. c.data.moved = true;
  51048. var s = c.elm.style;
  51049. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  51050. s.transitionDuration = '0s';
  51051. }
  51052. }
  51053. var platformComponents = {
  51054. Transition: Transition,
  51055. TransitionGroup: TransitionGroup
  51056. };
  51057. /* */
  51058. // install platform specific utils
  51059. Vue.config.mustUseProp = mustUseProp;
  51060. Vue.config.isReservedTag = isReservedTag;
  51061. Vue.config.isReservedAttr = isReservedAttr;
  51062. Vue.config.getTagNamespace = getTagNamespace;
  51063. Vue.config.isUnknownElement = isUnknownElement;
  51064. // install platform runtime directives & components
  51065. extend(Vue.options.directives, platformDirectives);
  51066. extend(Vue.options.components, platformComponents);
  51067. // install platform patch function
  51068. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  51069. // public mount method
  51070. Vue.prototype.$mount = function (
  51071. el,
  51072. hydrating
  51073. ) {
  51074. el = el && inBrowser ? query(el) : undefined;
  51075. return mountComponent(this, el, hydrating)
  51076. };
  51077. // devtools global hook
  51078. /* istanbul ignore next */
  51079. if (inBrowser) {
  51080. setTimeout(function () {
  51081. if (config.devtools) {
  51082. if (devtools) {
  51083. devtools.emit('init', Vue);
  51084. } else {
  51085. console[console.info ? 'info' : 'log'](
  51086. 'Download the Vue Devtools extension for a better development experience:\n' +
  51087. 'https://github.com/vuejs/vue-devtools'
  51088. );
  51089. }
  51090. }
  51091. if (config.productionTip !== false &&
  51092. typeof console !== 'undefined'
  51093. ) {
  51094. console[console.info ? 'info' : 'log'](
  51095. "You are running Vue in development mode.\n" +
  51096. "Make sure to turn on production mode when deploying for production.\n" +
  51097. "See more tips at https://vuejs.org/guide/deployment.html"
  51098. );
  51099. }
  51100. }, 0);
  51101. }
  51102. /* */
  51103. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  51104. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  51105. var buildRegex = cached(function (delimiters) {
  51106. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  51107. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  51108. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  51109. });
  51110. function parseText (
  51111. text,
  51112. delimiters
  51113. ) {
  51114. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  51115. if (!tagRE.test(text)) {
  51116. return
  51117. }
  51118. var tokens = [];
  51119. var rawTokens = [];
  51120. var lastIndex = tagRE.lastIndex = 0;
  51121. var match, index, tokenValue;
  51122. while ((match = tagRE.exec(text))) {
  51123. index = match.index;
  51124. // push text token
  51125. if (index > lastIndex) {
  51126. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  51127. tokens.push(JSON.stringify(tokenValue));
  51128. }
  51129. // tag token
  51130. var exp = parseFilters(match[1].trim());
  51131. tokens.push(("_s(" + exp + ")"));
  51132. rawTokens.push({ '@binding': exp });
  51133. lastIndex = index + match[0].length;
  51134. }
  51135. if (lastIndex < text.length) {
  51136. rawTokens.push(tokenValue = text.slice(lastIndex));
  51137. tokens.push(JSON.stringify(tokenValue));
  51138. }
  51139. return {
  51140. expression: tokens.join('+'),
  51141. tokens: rawTokens
  51142. }
  51143. }
  51144. /* */
  51145. function transformNode (el, options) {
  51146. var warn = options.warn || baseWarn;
  51147. var staticClass = getAndRemoveAttr(el, 'class');
  51148. if (staticClass) {
  51149. var res = parseText(staticClass, options.delimiters);
  51150. if (res) {
  51151. warn(
  51152. "class=\"" + staticClass + "\": " +
  51153. 'Interpolation inside attributes has been removed. ' +
  51154. 'Use v-bind or the colon shorthand instead. For example, ' +
  51155. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  51156. el.rawAttrsMap['class']
  51157. );
  51158. }
  51159. }
  51160. if (staticClass) {
  51161. el.staticClass = JSON.stringify(staticClass);
  51162. }
  51163. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  51164. if (classBinding) {
  51165. el.classBinding = classBinding;
  51166. }
  51167. }
  51168. function genData (el) {
  51169. var data = '';
  51170. if (el.staticClass) {
  51171. data += "staticClass:" + (el.staticClass) + ",";
  51172. }
  51173. if (el.classBinding) {
  51174. data += "class:" + (el.classBinding) + ",";
  51175. }
  51176. return data
  51177. }
  51178. var klass$1 = {
  51179. staticKeys: ['staticClass'],
  51180. transformNode: transformNode,
  51181. genData: genData
  51182. };
  51183. /* */
  51184. function transformNode$1 (el, options) {
  51185. var warn = options.warn || baseWarn;
  51186. var staticStyle = getAndRemoveAttr(el, 'style');
  51187. if (staticStyle) {
  51188. /* istanbul ignore if */
  51189. {
  51190. var res = parseText(staticStyle, options.delimiters);
  51191. if (res) {
  51192. warn(
  51193. "style=\"" + staticStyle + "\": " +
  51194. 'Interpolation inside attributes has been removed. ' +
  51195. 'Use v-bind or the colon shorthand instead. For example, ' +
  51196. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  51197. el.rawAttrsMap['style']
  51198. );
  51199. }
  51200. }
  51201. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  51202. }
  51203. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  51204. if (styleBinding) {
  51205. el.styleBinding = styleBinding;
  51206. }
  51207. }
  51208. function genData$1 (el) {
  51209. var data = '';
  51210. if (el.staticStyle) {
  51211. data += "staticStyle:" + (el.staticStyle) + ",";
  51212. }
  51213. if (el.styleBinding) {
  51214. data += "style:(" + (el.styleBinding) + "),";
  51215. }
  51216. return data
  51217. }
  51218. var style$1 = {
  51219. staticKeys: ['staticStyle'],
  51220. transformNode: transformNode$1,
  51221. genData: genData$1
  51222. };
  51223. /* */
  51224. var decoder;
  51225. var he = {
  51226. decode: function decode (html) {
  51227. decoder = decoder || document.createElement('div');
  51228. decoder.innerHTML = html;
  51229. return decoder.textContent
  51230. }
  51231. };
  51232. /* */
  51233. var isUnaryTag = makeMap(
  51234. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  51235. 'link,meta,param,source,track,wbr'
  51236. );
  51237. // Elements that you can, intentionally, leave open
  51238. // (and which close themselves)
  51239. var canBeLeftOpenTag = makeMap(
  51240. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  51241. );
  51242. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  51243. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  51244. var isNonPhrasingTag = makeMap(
  51245. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  51246. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  51247. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  51248. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  51249. 'title,tr,track'
  51250. );
  51251. /**
  51252. * Not type-checking this file because it's mostly vendor code.
  51253. */
  51254. // Regular Expressions for parsing tags and attributes
  51255. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  51256. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  51257. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  51258. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  51259. var startTagOpen = new RegExp(("^<" + qnameCapture));
  51260. var startTagClose = /^\s*(\/?)>/;
  51261. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  51262. var doctype = /^<!DOCTYPE [^>]+>/i;
  51263. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  51264. var comment = /^<!\--/;
  51265. var conditionalComment = /^<!\[/;
  51266. // Special Elements (can contain anything)
  51267. var isPlainTextElement = makeMap('script,style,textarea', true);
  51268. var reCache = {};
  51269. var decodingMap = {
  51270. '&lt;': '<',
  51271. '&gt;': '>',
  51272. '&quot;': '"',
  51273. '&amp;': '&',
  51274. '&#10;': '\n',
  51275. '&#9;': '\t',
  51276. '&#39;': "'"
  51277. };
  51278. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  51279. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  51280. // #5992
  51281. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  51282. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  51283. function decodeAttr (value, shouldDecodeNewlines) {
  51284. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  51285. return value.replace(re, function (match) { return decodingMap[match]; })
  51286. }
  51287. function parseHTML (html, options) {
  51288. var stack = [];
  51289. var expectHTML = options.expectHTML;
  51290. var isUnaryTag$$1 = options.isUnaryTag || no;
  51291. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  51292. var index = 0;
  51293. var last, lastTag;
  51294. while (html) {
  51295. last = html;
  51296. // Make sure we're not in a plaintext content element like script/style
  51297. if (!lastTag || !isPlainTextElement(lastTag)) {
  51298. var textEnd = html.indexOf('<');
  51299. if (textEnd === 0) {
  51300. // Comment:
  51301. if (comment.test(html)) {
  51302. var commentEnd = html.indexOf('-->');
  51303. if (commentEnd >= 0) {
  51304. if (options.shouldKeepComment) {
  51305. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  51306. }
  51307. advance(commentEnd + 3);
  51308. continue
  51309. }
  51310. }
  51311. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  51312. if (conditionalComment.test(html)) {
  51313. var conditionalEnd = html.indexOf(']>');
  51314. if (conditionalEnd >= 0) {
  51315. advance(conditionalEnd + 2);
  51316. continue
  51317. }
  51318. }
  51319. // Doctype:
  51320. var doctypeMatch = html.match(doctype);
  51321. if (doctypeMatch) {
  51322. advance(doctypeMatch[0].length);
  51323. continue
  51324. }
  51325. // End tag:
  51326. var endTagMatch = html.match(endTag);
  51327. if (endTagMatch) {
  51328. var curIndex = index;
  51329. advance(endTagMatch[0].length);
  51330. parseEndTag(endTagMatch[1], curIndex, index);
  51331. continue
  51332. }
  51333. // Start tag:
  51334. var startTagMatch = parseStartTag();
  51335. if (startTagMatch) {
  51336. handleStartTag(startTagMatch);
  51337. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  51338. advance(1);
  51339. }
  51340. continue
  51341. }
  51342. }
  51343. var text = (void 0), rest = (void 0), next = (void 0);
  51344. if (textEnd >= 0) {
  51345. rest = html.slice(textEnd);
  51346. while (
  51347. !endTag.test(rest) &&
  51348. !startTagOpen.test(rest) &&
  51349. !comment.test(rest) &&
  51350. !conditionalComment.test(rest)
  51351. ) {
  51352. // < in plain text, be forgiving and treat it as text
  51353. next = rest.indexOf('<', 1);
  51354. if (next < 0) { break }
  51355. textEnd += next;
  51356. rest = html.slice(textEnd);
  51357. }
  51358. text = html.substring(0, textEnd);
  51359. }
  51360. if (textEnd < 0) {
  51361. text = html;
  51362. }
  51363. if (text) {
  51364. advance(text.length);
  51365. }
  51366. if (options.chars && text) {
  51367. options.chars(text, index - text.length, index);
  51368. }
  51369. } else {
  51370. var endTagLength = 0;
  51371. var stackedTag = lastTag.toLowerCase();
  51372. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  51373. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  51374. endTagLength = endTag.length;
  51375. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  51376. text = text
  51377. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  51378. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  51379. }
  51380. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  51381. text = text.slice(1);
  51382. }
  51383. if (options.chars) {
  51384. options.chars(text);
  51385. }
  51386. return ''
  51387. });
  51388. index += html.length - rest$1.length;
  51389. html = rest$1;
  51390. parseEndTag(stackedTag, index - endTagLength, index);
  51391. }
  51392. if (html === last) {
  51393. options.chars && options.chars(html);
  51394. if (!stack.length && options.warn) {
  51395. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  51396. }
  51397. break
  51398. }
  51399. }
  51400. // Clean up any remaining tags
  51401. parseEndTag();
  51402. function advance (n) {
  51403. index += n;
  51404. html = html.substring(n);
  51405. }
  51406. function parseStartTag () {
  51407. var start = html.match(startTagOpen);
  51408. if (start) {
  51409. var match = {
  51410. tagName: start[1],
  51411. attrs: [],
  51412. start: index
  51413. };
  51414. advance(start[0].length);
  51415. var end, attr;
  51416. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  51417. attr.start = index;
  51418. advance(attr[0].length);
  51419. attr.end = index;
  51420. match.attrs.push(attr);
  51421. }
  51422. if (end) {
  51423. match.unarySlash = end[1];
  51424. advance(end[0].length);
  51425. match.end = index;
  51426. return match
  51427. }
  51428. }
  51429. }
  51430. function handleStartTag (match) {
  51431. var tagName = match.tagName;
  51432. var unarySlash = match.unarySlash;
  51433. if (expectHTML) {
  51434. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  51435. parseEndTag(lastTag);
  51436. }
  51437. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  51438. parseEndTag(tagName);
  51439. }
  51440. }
  51441. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  51442. var l = match.attrs.length;
  51443. var attrs = new Array(l);
  51444. for (var i = 0; i < l; i++) {
  51445. var args = match.attrs[i];
  51446. var value = args[3] || args[4] || args[5] || '';
  51447. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  51448. ? options.shouldDecodeNewlinesForHref
  51449. : options.shouldDecodeNewlines;
  51450. attrs[i] = {
  51451. name: args[1],
  51452. value: decodeAttr(value, shouldDecodeNewlines)
  51453. };
  51454. if (options.outputSourceRange) {
  51455. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  51456. attrs[i].end = args.end;
  51457. }
  51458. }
  51459. if (!unary) {
  51460. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  51461. lastTag = tagName;
  51462. }
  51463. if (options.start) {
  51464. options.start(tagName, attrs, unary, match.start, match.end);
  51465. }
  51466. }
  51467. function parseEndTag (tagName, start, end) {
  51468. var pos, lowerCasedTagName;
  51469. if (start == null) { start = index; }
  51470. if (end == null) { end = index; }
  51471. // Find the closest opened tag of the same type
  51472. if (tagName) {
  51473. lowerCasedTagName = tagName.toLowerCase();
  51474. for (pos = stack.length - 1; pos >= 0; pos--) {
  51475. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  51476. break
  51477. }
  51478. }
  51479. } else {
  51480. // If no tag name is provided, clean shop
  51481. pos = 0;
  51482. }
  51483. if (pos >= 0) {
  51484. // Close all the open elements, up the stack
  51485. for (var i = stack.length - 1; i >= pos; i--) {
  51486. if (i > pos || !tagName &&
  51487. options.warn
  51488. ) {
  51489. options.warn(
  51490. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  51491. { start: stack[i].start, end: stack[i].end }
  51492. );
  51493. }
  51494. if (options.end) {
  51495. options.end(stack[i].tag, start, end);
  51496. }
  51497. }
  51498. // Remove the open elements from the stack
  51499. stack.length = pos;
  51500. lastTag = pos && stack[pos - 1].tag;
  51501. } else if (lowerCasedTagName === 'br') {
  51502. if (options.start) {
  51503. options.start(tagName, [], true, start, end);
  51504. }
  51505. } else if (lowerCasedTagName === 'p') {
  51506. if (options.start) {
  51507. options.start(tagName, [], false, start, end);
  51508. }
  51509. if (options.end) {
  51510. options.end(tagName, start, end);
  51511. }
  51512. }
  51513. }
  51514. }
  51515. /* */
  51516. var onRE = /^@|^v-on:/;
  51517. var dirRE = /^v-|^@|^:|^#/;
  51518. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  51519. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  51520. var stripParensRE = /^\(|\)$/g;
  51521. var dynamicArgRE = /^\[.*\]$/;
  51522. var argRE = /:(.*)$/;
  51523. var bindRE = /^:|^\.|^v-bind:/;
  51524. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  51525. var slotRE = /^v-slot(:|$)|^#/;
  51526. var lineBreakRE = /[\r\n]/;
  51527. var whitespaceRE$1 = /\s+/g;
  51528. var invalidAttributeRE = /[\s"'<>\/=]/;
  51529. var decodeHTMLCached = cached(he.decode);
  51530. var emptySlotScopeToken = "_empty_";
  51531. // configurable state
  51532. var warn$2;
  51533. var delimiters;
  51534. var transforms;
  51535. var preTransforms;
  51536. var postTransforms;
  51537. var platformIsPreTag;
  51538. var platformMustUseProp;
  51539. var platformGetTagNamespace;
  51540. var maybeComponent;
  51541. function createASTElement (
  51542. tag,
  51543. attrs,
  51544. parent
  51545. ) {
  51546. return {
  51547. type: 1,
  51548. tag: tag,
  51549. attrsList: attrs,
  51550. attrsMap: makeAttrsMap(attrs),
  51551. rawAttrsMap: {},
  51552. parent: parent,
  51553. children: []
  51554. }
  51555. }
  51556. /**
  51557. * Convert HTML string to AST.
  51558. */
  51559. function parse (
  51560. template,
  51561. options
  51562. ) {
  51563. warn$2 = options.warn || baseWarn;
  51564. platformIsPreTag = options.isPreTag || no;
  51565. platformMustUseProp = options.mustUseProp || no;
  51566. platformGetTagNamespace = options.getTagNamespace || no;
  51567. var isReservedTag = options.isReservedTag || no;
  51568. maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  51569. transforms = pluckModuleFunction(options.modules, 'transformNode');
  51570. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  51571. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  51572. delimiters = options.delimiters;
  51573. var stack = [];
  51574. var preserveWhitespace = options.preserveWhitespace !== false;
  51575. var whitespaceOption = options.whitespace;
  51576. var root;
  51577. var currentParent;
  51578. var inVPre = false;
  51579. var inPre = false;
  51580. var warned = false;
  51581. function warnOnce (msg, range) {
  51582. if (!warned) {
  51583. warned = true;
  51584. warn$2(msg, range);
  51585. }
  51586. }
  51587. function closeElement (element) {
  51588. trimEndingWhitespace(element);
  51589. if (!inVPre && !element.processed) {
  51590. element = processElement(element, options);
  51591. }
  51592. // tree management
  51593. if (!stack.length && element !== root) {
  51594. // allow root elements with v-if, v-else-if and v-else
  51595. if (root.if && (element.elseif || element.else)) {
  51596. {
  51597. checkRootConstraints(element);
  51598. }
  51599. addIfCondition(root, {
  51600. exp: element.elseif,
  51601. block: element
  51602. });
  51603. } else {
  51604. warnOnce(
  51605. "Component template should contain exactly one root element. " +
  51606. "If you are using v-if on multiple elements, " +
  51607. "use v-else-if to chain them instead.",
  51608. { start: element.start }
  51609. );
  51610. }
  51611. }
  51612. if (currentParent && !element.forbidden) {
  51613. if (element.elseif || element.else) {
  51614. processIfConditions(element, currentParent);
  51615. } else {
  51616. if (element.slotScope) {
  51617. // scoped slot
  51618. // keep it in the children list so that v-else(-if) conditions can
  51619. // find it as the prev node.
  51620. var name = element.slotTarget || '"default"'
  51621. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  51622. }
  51623. currentParent.children.push(element);
  51624. element.parent = currentParent;
  51625. }
  51626. }
  51627. // final children cleanup
  51628. // filter out scoped slots
  51629. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  51630. // remove trailing whitespace node again
  51631. trimEndingWhitespace(element);
  51632. // check pre state
  51633. if (element.pre) {
  51634. inVPre = false;
  51635. }
  51636. if (platformIsPreTag(element.tag)) {
  51637. inPre = false;
  51638. }
  51639. // apply post-transforms
  51640. for (var i = 0; i < postTransforms.length; i++) {
  51641. postTransforms[i](element, options);
  51642. }
  51643. }
  51644. function trimEndingWhitespace (el) {
  51645. // remove trailing whitespace node
  51646. if (!inPre) {
  51647. var lastNode;
  51648. while (
  51649. (lastNode = el.children[el.children.length - 1]) &&
  51650. lastNode.type === 3 &&
  51651. lastNode.text === ' '
  51652. ) {
  51653. el.children.pop();
  51654. }
  51655. }
  51656. }
  51657. function checkRootConstraints (el) {
  51658. if (el.tag === 'slot' || el.tag === 'template') {
  51659. warnOnce(
  51660. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  51661. 'contain multiple nodes.',
  51662. { start: el.start }
  51663. );
  51664. }
  51665. if (el.attrsMap.hasOwnProperty('v-for')) {
  51666. warnOnce(
  51667. 'Cannot use v-for on stateful component root element because ' +
  51668. 'it renders multiple elements.',
  51669. el.rawAttrsMap['v-for']
  51670. );
  51671. }
  51672. }
  51673. parseHTML(template, {
  51674. warn: warn$2,
  51675. expectHTML: options.expectHTML,
  51676. isUnaryTag: options.isUnaryTag,
  51677. canBeLeftOpenTag: options.canBeLeftOpenTag,
  51678. shouldDecodeNewlines: options.shouldDecodeNewlines,
  51679. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  51680. shouldKeepComment: options.comments,
  51681. outputSourceRange: options.outputSourceRange,
  51682. start: function start (tag, attrs, unary, start$1, end) {
  51683. // check namespace.
  51684. // inherit parent ns if there is one
  51685. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  51686. // handle IE svg bug
  51687. /* istanbul ignore if */
  51688. if (isIE && ns === 'svg') {
  51689. attrs = guardIESVGBug(attrs);
  51690. }
  51691. var element = createASTElement(tag, attrs, currentParent);
  51692. if (ns) {
  51693. element.ns = ns;
  51694. }
  51695. {
  51696. if (options.outputSourceRange) {
  51697. element.start = start$1;
  51698. element.end = end;
  51699. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  51700. cumulated[attr.name] = attr;
  51701. return cumulated
  51702. }, {});
  51703. }
  51704. attrs.forEach(function (attr) {
  51705. if (invalidAttributeRE.test(attr.name)) {
  51706. warn$2(
  51707. "Invalid dynamic argument expression: attribute names cannot contain " +
  51708. "spaces, quotes, <, >, / or =.",
  51709. {
  51710. start: attr.start + attr.name.indexOf("["),
  51711. end: attr.start + attr.name.length
  51712. }
  51713. );
  51714. }
  51715. });
  51716. }
  51717. if (isForbiddenTag(element) && !isServerRendering()) {
  51718. element.forbidden = true;
  51719. warn$2(
  51720. 'Templates should only be responsible for mapping the state to the ' +
  51721. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  51722. "<" + tag + ">" + ', as they will not be parsed.',
  51723. { start: element.start }
  51724. );
  51725. }
  51726. // apply pre-transforms
  51727. for (var i = 0; i < preTransforms.length; i++) {
  51728. element = preTransforms[i](element, options) || element;
  51729. }
  51730. if (!inVPre) {
  51731. processPre(element);
  51732. if (element.pre) {
  51733. inVPre = true;
  51734. }
  51735. }
  51736. if (platformIsPreTag(element.tag)) {
  51737. inPre = true;
  51738. }
  51739. if (inVPre) {
  51740. processRawAttrs(element);
  51741. } else if (!element.processed) {
  51742. // structural directives
  51743. processFor(element);
  51744. processIf(element);
  51745. processOnce(element);
  51746. }
  51747. if (!root) {
  51748. root = element;
  51749. {
  51750. checkRootConstraints(root);
  51751. }
  51752. }
  51753. if (!unary) {
  51754. currentParent = element;
  51755. stack.push(element);
  51756. } else {
  51757. closeElement(element);
  51758. }
  51759. },
  51760. end: function end (tag, start, end$1) {
  51761. var element = stack[stack.length - 1];
  51762. // pop stack
  51763. stack.length -= 1;
  51764. currentParent = stack[stack.length - 1];
  51765. if (options.outputSourceRange) {
  51766. element.end = end$1;
  51767. }
  51768. closeElement(element);
  51769. },
  51770. chars: function chars (text, start, end) {
  51771. if (!currentParent) {
  51772. {
  51773. if (text === template) {
  51774. warnOnce(
  51775. 'Component template requires a root element, rather than just text.',
  51776. { start: start }
  51777. );
  51778. } else if ((text = text.trim())) {
  51779. warnOnce(
  51780. ("text \"" + text + "\" outside root element will be ignored."),
  51781. { start: start }
  51782. );
  51783. }
  51784. }
  51785. return
  51786. }
  51787. // IE textarea placeholder bug
  51788. /* istanbul ignore if */
  51789. if (isIE &&
  51790. currentParent.tag === 'textarea' &&
  51791. currentParent.attrsMap.placeholder === text
  51792. ) {
  51793. return
  51794. }
  51795. var children = currentParent.children;
  51796. if (inPre || text.trim()) {
  51797. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  51798. } else if (!children.length) {
  51799. // remove the whitespace-only node right after an opening tag
  51800. text = '';
  51801. } else if (whitespaceOption) {
  51802. if (whitespaceOption === 'condense') {
  51803. // in condense mode, remove the whitespace node if it contains
  51804. // line break, otherwise condense to a single space
  51805. text = lineBreakRE.test(text) ? '' : ' ';
  51806. } else {
  51807. text = ' ';
  51808. }
  51809. } else {
  51810. text = preserveWhitespace ? ' ' : '';
  51811. }
  51812. if (text) {
  51813. if (!inPre && whitespaceOption === 'condense') {
  51814. // condense consecutive whitespaces into single space
  51815. text = text.replace(whitespaceRE$1, ' ');
  51816. }
  51817. var res;
  51818. var child;
  51819. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  51820. child = {
  51821. type: 2,
  51822. expression: res.expression,
  51823. tokens: res.tokens,
  51824. text: text
  51825. };
  51826. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  51827. child = {
  51828. type: 3,
  51829. text: text
  51830. };
  51831. }
  51832. if (child) {
  51833. if (options.outputSourceRange) {
  51834. child.start = start;
  51835. child.end = end;
  51836. }
  51837. children.push(child);
  51838. }
  51839. }
  51840. },
  51841. comment: function comment (text, start, end) {
  51842. // adding anyting as a sibling to the root node is forbidden
  51843. // comments should still be allowed, but ignored
  51844. if (currentParent) {
  51845. var child = {
  51846. type: 3,
  51847. text: text,
  51848. isComment: true
  51849. };
  51850. if (options.outputSourceRange) {
  51851. child.start = start;
  51852. child.end = end;
  51853. }
  51854. currentParent.children.push(child);
  51855. }
  51856. }
  51857. });
  51858. return root
  51859. }
  51860. function processPre (el) {
  51861. if (getAndRemoveAttr(el, 'v-pre') != null) {
  51862. el.pre = true;
  51863. }
  51864. }
  51865. function processRawAttrs (el) {
  51866. var list = el.attrsList;
  51867. var len = list.length;
  51868. if (len) {
  51869. var attrs = el.attrs = new Array(len);
  51870. for (var i = 0; i < len; i++) {
  51871. attrs[i] = {
  51872. name: list[i].name,
  51873. value: JSON.stringify(list[i].value)
  51874. };
  51875. if (list[i].start != null) {
  51876. attrs[i].start = list[i].start;
  51877. attrs[i].end = list[i].end;
  51878. }
  51879. }
  51880. } else if (!el.pre) {
  51881. // non root node in pre blocks with no attributes
  51882. el.plain = true;
  51883. }
  51884. }
  51885. function processElement (
  51886. element,
  51887. options
  51888. ) {
  51889. processKey(element);
  51890. // determine whether this is a plain element after
  51891. // removing structural attributes
  51892. element.plain = (
  51893. !element.key &&
  51894. !element.scopedSlots &&
  51895. !element.attrsList.length
  51896. );
  51897. processRef(element);
  51898. processSlotContent(element);
  51899. processSlotOutlet(element);
  51900. processComponent(element);
  51901. for (var i = 0; i < transforms.length; i++) {
  51902. element = transforms[i](element, options) || element;
  51903. }
  51904. processAttrs(element);
  51905. return element
  51906. }
  51907. function processKey (el) {
  51908. var exp = getBindingAttr(el, 'key');
  51909. if (exp) {
  51910. {
  51911. if (el.tag === 'template') {
  51912. warn$2(
  51913. "<template> cannot be keyed. Place the key on real elements instead.",
  51914. getRawBindingAttr(el, 'key')
  51915. );
  51916. }
  51917. if (el.for) {
  51918. var iterator = el.iterator2 || el.iterator1;
  51919. var parent = el.parent;
  51920. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  51921. warn$2(
  51922. "Do not use v-for index as key on <transition-group> children, " +
  51923. "this is the same as not using keys.",
  51924. getRawBindingAttr(el, 'key'),
  51925. true /* tip */
  51926. );
  51927. }
  51928. }
  51929. }
  51930. el.key = exp;
  51931. }
  51932. }
  51933. function processRef (el) {
  51934. var ref = getBindingAttr(el, 'ref');
  51935. if (ref) {
  51936. el.ref = ref;
  51937. el.refInFor = checkInFor(el);
  51938. }
  51939. }
  51940. function processFor (el) {
  51941. var exp;
  51942. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  51943. var res = parseFor(exp);
  51944. if (res) {
  51945. extend(el, res);
  51946. } else {
  51947. warn$2(
  51948. ("Invalid v-for expression: " + exp),
  51949. el.rawAttrsMap['v-for']
  51950. );
  51951. }
  51952. }
  51953. }
  51954. function parseFor (exp) {
  51955. var inMatch = exp.match(forAliasRE);
  51956. if (!inMatch) { return }
  51957. var res = {};
  51958. res.for = inMatch[2].trim();
  51959. var alias = inMatch[1].trim().replace(stripParensRE, '');
  51960. var iteratorMatch = alias.match(forIteratorRE);
  51961. if (iteratorMatch) {
  51962. res.alias = alias.replace(forIteratorRE, '').trim();
  51963. res.iterator1 = iteratorMatch[1].trim();
  51964. if (iteratorMatch[2]) {
  51965. res.iterator2 = iteratorMatch[2].trim();
  51966. }
  51967. } else {
  51968. res.alias = alias;
  51969. }
  51970. return res
  51971. }
  51972. function processIf (el) {
  51973. var exp = getAndRemoveAttr(el, 'v-if');
  51974. if (exp) {
  51975. el.if = exp;
  51976. addIfCondition(el, {
  51977. exp: exp,
  51978. block: el
  51979. });
  51980. } else {
  51981. if (getAndRemoveAttr(el, 'v-else') != null) {
  51982. el.else = true;
  51983. }
  51984. var elseif = getAndRemoveAttr(el, 'v-else-if');
  51985. if (elseif) {
  51986. el.elseif = elseif;
  51987. }
  51988. }
  51989. }
  51990. function processIfConditions (el, parent) {
  51991. var prev = findPrevElement(parent.children);
  51992. if (prev && prev.if) {
  51993. addIfCondition(prev, {
  51994. exp: el.elseif,
  51995. block: el
  51996. });
  51997. } else {
  51998. warn$2(
  51999. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  52000. "used on element <" + (el.tag) + "> without corresponding v-if.",
  52001. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  52002. );
  52003. }
  52004. }
  52005. function findPrevElement (children) {
  52006. var i = children.length;
  52007. while (i--) {
  52008. if (children[i].type === 1) {
  52009. return children[i]
  52010. } else {
  52011. if (children[i].text !== ' ') {
  52012. warn$2(
  52013. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  52014. "will be ignored.",
  52015. children[i]
  52016. );
  52017. }
  52018. children.pop();
  52019. }
  52020. }
  52021. }
  52022. function addIfCondition (el, condition) {
  52023. if (!el.ifConditions) {
  52024. el.ifConditions = [];
  52025. }
  52026. el.ifConditions.push(condition);
  52027. }
  52028. function processOnce (el) {
  52029. var once$$1 = getAndRemoveAttr(el, 'v-once');
  52030. if (once$$1 != null) {
  52031. el.once = true;
  52032. }
  52033. }
  52034. // handle content being passed to a component as slot,
  52035. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  52036. function processSlotContent (el) {
  52037. var slotScope;
  52038. if (el.tag === 'template') {
  52039. slotScope = getAndRemoveAttr(el, 'scope');
  52040. /* istanbul ignore if */
  52041. if (slotScope) {
  52042. warn$2(
  52043. "the \"scope\" attribute for scoped slots have been deprecated and " +
  52044. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  52045. "can also be used on plain elements in addition to <template> to " +
  52046. "denote scoped slots.",
  52047. el.rawAttrsMap['scope'],
  52048. true
  52049. );
  52050. }
  52051. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  52052. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  52053. /* istanbul ignore if */
  52054. if (el.attrsMap['v-for']) {
  52055. warn$2(
  52056. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  52057. "(v-for takes higher priority). Use a wrapper <template> for the " +
  52058. "scoped slot to make it clearer.",
  52059. el.rawAttrsMap['slot-scope'],
  52060. true
  52061. );
  52062. }
  52063. el.slotScope = slotScope;
  52064. }
  52065. // slot="xxx"
  52066. var slotTarget = getBindingAttr(el, 'slot');
  52067. if (slotTarget) {
  52068. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  52069. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  52070. // preserve slot as an attribute for native shadow DOM compat
  52071. // only for non-scoped slots.
  52072. if (el.tag !== 'template' && !el.slotScope) {
  52073. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  52074. }
  52075. }
  52076. // 2.6 v-slot syntax
  52077. {
  52078. if (el.tag === 'template') {
  52079. // v-slot on <template>
  52080. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  52081. if (slotBinding) {
  52082. {
  52083. if (el.slotTarget || el.slotScope) {
  52084. warn$2(
  52085. "Unexpected mixed usage of different slot syntaxes.",
  52086. el
  52087. );
  52088. }
  52089. if (el.parent && !maybeComponent(el.parent)) {
  52090. warn$2(
  52091. "<template v-slot> can only appear at the root level inside " +
  52092. "the receiving component",
  52093. el
  52094. );
  52095. }
  52096. }
  52097. var ref = getSlotName(slotBinding);
  52098. var name = ref.name;
  52099. var dynamic = ref.dynamic;
  52100. el.slotTarget = name;
  52101. el.slotTargetDynamic = dynamic;
  52102. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  52103. }
  52104. } else {
  52105. // v-slot on component, denotes default slot
  52106. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  52107. if (slotBinding$1) {
  52108. {
  52109. if (!maybeComponent(el)) {
  52110. warn$2(
  52111. "v-slot can only be used on components or <template>.",
  52112. slotBinding$1
  52113. );
  52114. }
  52115. if (el.slotScope || el.slotTarget) {
  52116. warn$2(
  52117. "Unexpected mixed usage of different slot syntaxes.",
  52118. el
  52119. );
  52120. }
  52121. if (el.scopedSlots) {
  52122. warn$2(
  52123. "To avoid scope ambiguity, the default slot should also use " +
  52124. "<template> syntax when there are other named slots.",
  52125. slotBinding$1
  52126. );
  52127. }
  52128. }
  52129. // add the component's children to its default slot
  52130. var slots = el.scopedSlots || (el.scopedSlots = {});
  52131. var ref$1 = getSlotName(slotBinding$1);
  52132. var name$1 = ref$1.name;
  52133. var dynamic$1 = ref$1.dynamic;
  52134. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  52135. slotContainer.slotTarget = name$1;
  52136. slotContainer.slotTargetDynamic = dynamic$1;
  52137. slotContainer.children = el.children.filter(function (c) {
  52138. if (!c.slotScope) {
  52139. c.parent = slotContainer;
  52140. return true
  52141. }
  52142. });
  52143. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  52144. // remove children as they are returned from scopedSlots now
  52145. el.children = [];
  52146. // mark el non-plain so data gets generated
  52147. el.plain = false;
  52148. }
  52149. }
  52150. }
  52151. }
  52152. function getSlotName (binding) {
  52153. var name = binding.name.replace(slotRE, '');
  52154. if (!name) {
  52155. if (binding.name[0] !== '#') {
  52156. name = 'default';
  52157. } else {
  52158. warn$2(
  52159. "v-slot shorthand syntax requires a slot name.",
  52160. binding
  52161. );
  52162. }
  52163. }
  52164. return dynamicArgRE.test(name)
  52165. // dynamic [name]
  52166. ? { name: name.slice(1, -1), dynamic: true }
  52167. // static name
  52168. : { name: ("\"" + name + "\""), dynamic: false }
  52169. }
  52170. // handle <slot/> outlets
  52171. function processSlotOutlet (el) {
  52172. if (el.tag === 'slot') {
  52173. el.slotName = getBindingAttr(el, 'name');
  52174. if (el.key) {
  52175. warn$2(
  52176. "`key` does not work on <slot> because slots are abstract outlets " +
  52177. "and can possibly expand into multiple elements. " +
  52178. "Use the key on a wrapping element instead.",
  52179. getRawBindingAttr(el, 'key')
  52180. );
  52181. }
  52182. }
  52183. }
  52184. function processComponent (el) {
  52185. var binding;
  52186. if ((binding = getBindingAttr(el, 'is'))) {
  52187. el.component = binding;
  52188. }
  52189. if (getAndRemoveAttr(el, 'inline-template') != null) {
  52190. el.inlineTemplate = true;
  52191. }
  52192. }
  52193. function processAttrs (el) {
  52194. var list = el.attrsList;
  52195. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  52196. for (i = 0, l = list.length; i < l; i++) {
  52197. name = rawName = list[i].name;
  52198. value = list[i].value;
  52199. if (dirRE.test(name)) {
  52200. // mark element as dynamic
  52201. el.hasBindings = true;
  52202. // modifiers
  52203. modifiers = parseModifiers(name.replace(dirRE, ''));
  52204. // support .foo shorthand syntax for the .prop modifier
  52205. if (modifiers) {
  52206. name = name.replace(modifierRE, '');
  52207. }
  52208. if (bindRE.test(name)) { // v-bind
  52209. name = name.replace(bindRE, '');
  52210. value = parseFilters(value);
  52211. isDynamic = dynamicArgRE.test(name);
  52212. if (isDynamic) {
  52213. name = name.slice(1, -1);
  52214. }
  52215. if (
  52216. value.trim().length === 0
  52217. ) {
  52218. warn$2(
  52219. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  52220. );
  52221. }
  52222. if (modifiers) {
  52223. if (modifiers.prop && !isDynamic) {
  52224. name = camelize(name);
  52225. if (name === 'innerHtml') { name = 'innerHTML'; }
  52226. }
  52227. if (modifiers.camel && !isDynamic) {
  52228. name = camelize(name);
  52229. }
  52230. if (modifiers.sync) {
  52231. syncGen = genAssignmentCode(value, "$event");
  52232. if (!isDynamic) {
  52233. addHandler(
  52234. el,
  52235. ("update:" + (camelize(name))),
  52236. syncGen,
  52237. null,
  52238. false,
  52239. warn$2,
  52240. list[i]
  52241. );
  52242. if (hyphenate(name) !== camelize(name)) {
  52243. addHandler(
  52244. el,
  52245. ("update:" + (hyphenate(name))),
  52246. syncGen,
  52247. null,
  52248. false,
  52249. warn$2,
  52250. list[i]
  52251. );
  52252. }
  52253. } else {
  52254. // handler w/ dynamic event name
  52255. addHandler(
  52256. el,
  52257. ("\"update:\"+(" + name + ")"),
  52258. syncGen,
  52259. null,
  52260. false,
  52261. warn$2,
  52262. list[i],
  52263. true // dynamic
  52264. );
  52265. }
  52266. }
  52267. }
  52268. if ((modifiers && modifiers.prop) || (
  52269. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  52270. )) {
  52271. addProp(el, name, value, list[i], isDynamic);
  52272. } else {
  52273. addAttr(el, name, value, list[i], isDynamic);
  52274. }
  52275. } else if (onRE.test(name)) { // v-on
  52276. name = name.replace(onRE, '');
  52277. isDynamic = dynamicArgRE.test(name);
  52278. if (isDynamic) {
  52279. name = name.slice(1, -1);
  52280. }
  52281. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  52282. } else { // normal directives
  52283. name = name.replace(dirRE, '');
  52284. // parse arg
  52285. var argMatch = name.match(argRE);
  52286. var arg = argMatch && argMatch[1];
  52287. isDynamic = false;
  52288. if (arg) {
  52289. name = name.slice(0, -(arg.length + 1));
  52290. if (dynamicArgRE.test(arg)) {
  52291. arg = arg.slice(1, -1);
  52292. isDynamic = true;
  52293. }
  52294. }
  52295. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  52296. if (name === 'model') {
  52297. checkForAliasModel(el, value);
  52298. }
  52299. }
  52300. } else {
  52301. // literal attribute
  52302. {
  52303. var res = parseText(value, delimiters);
  52304. if (res) {
  52305. warn$2(
  52306. name + "=\"" + value + "\": " +
  52307. 'Interpolation inside attributes has been removed. ' +
  52308. 'Use v-bind or the colon shorthand instead. For example, ' +
  52309. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  52310. list[i]
  52311. );
  52312. }
  52313. }
  52314. addAttr(el, name, JSON.stringify(value), list[i]);
  52315. // #6887 firefox doesn't update muted state if set via attribute
  52316. // even immediately after element creation
  52317. if (!el.component &&
  52318. name === 'muted' &&
  52319. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  52320. addProp(el, name, 'true', list[i]);
  52321. }
  52322. }
  52323. }
  52324. }
  52325. function checkInFor (el) {
  52326. var parent = el;
  52327. while (parent) {
  52328. if (parent.for !== undefined) {
  52329. return true
  52330. }
  52331. parent = parent.parent;
  52332. }
  52333. return false
  52334. }
  52335. function parseModifiers (name) {
  52336. var match = name.match(modifierRE);
  52337. if (match) {
  52338. var ret = {};
  52339. match.forEach(function (m) { ret[m.slice(1)] = true; });
  52340. return ret
  52341. }
  52342. }
  52343. function makeAttrsMap (attrs) {
  52344. var map = {};
  52345. for (var i = 0, l = attrs.length; i < l; i++) {
  52346. if (
  52347. map[attrs[i].name] && !isIE && !isEdge
  52348. ) {
  52349. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  52350. }
  52351. map[attrs[i].name] = attrs[i].value;
  52352. }
  52353. return map
  52354. }
  52355. // for script (e.g. type="x/template") or style, do not decode content
  52356. function isTextTag (el) {
  52357. return el.tag === 'script' || el.tag === 'style'
  52358. }
  52359. function isForbiddenTag (el) {
  52360. return (
  52361. el.tag === 'style' ||
  52362. (el.tag === 'script' && (
  52363. !el.attrsMap.type ||
  52364. el.attrsMap.type === 'text/javascript'
  52365. ))
  52366. )
  52367. }
  52368. var ieNSBug = /^xmlns:NS\d+/;
  52369. var ieNSPrefix = /^NS\d+:/;
  52370. /* istanbul ignore next */
  52371. function guardIESVGBug (attrs) {
  52372. var res = [];
  52373. for (var i = 0; i < attrs.length; i++) {
  52374. var attr = attrs[i];
  52375. if (!ieNSBug.test(attr.name)) {
  52376. attr.name = attr.name.replace(ieNSPrefix, '');
  52377. res.push(attr);
  52378. }
  52379. }
  52380. return res
  52381. }
  52382. function checkForAliasModel (el, value) {
  52383. var _el = el;
  52384. while (_el) {
  52385. if (_el.for && _el.alias === value) {
  52386. warn$2(
  52387. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  52388. "You are binding v-model directly to a v-for iteration alias. " +
  52389. "This will not be able to modify the v-for source array because " +
  52390. "writing to the alias is like modifying a function local variable. " +
  52391. "Consider using an array of objects and use v-model on an object property instead.",
  52392. el.rawAttrsMap['v-model']
  52393. );
  52394. }
  52395. _el = _el.parent;
  52396. }
  52397. }
  52398. /* */
  52399. function preTransformNode (el, options) {
  52400. if (el.tag === 'input') {
  52401. var map = el.attrsMap;
  52402. if (!map['v-model']) {
  52403. return
  52404. }
  52405. var typeBinding;
  52406. if (map[':type'] || map['v-bind:type']) {
  52407. typeBinding = getBindingAttr(el, 'type');
  52408. }
  52409. if (!map.type && !typeBinding && map['v-bind']) {
  52410. typeBinding = "(" + (map['v-bind']) + ").type";
  52411. }
  52412. if (typeBinding) {
  52413. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  52414. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  52415. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  52416. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  52417. // 1. checkbox
  52418. var branch0 = cloneASTElement(el);
  52419. // process for on the main node
  52420. processFor(branch0);
  52421. addRawAttr(branch0, 'type', 'checkbox');
  52422. processElement(branch0, options);
  52423. branch0.processed = true; // prevent it from double-processed
  52424. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  52425. addIfCondition(branch0, {
  52426. exp: branch0.if,
  52427. block: branch0
  52428. });
  52429. // 2. add radio else-if condition
  52430. var branch1 = cloneASTElement(el);
  52431. getAndRemoveAttr(branch1, 'v-for', true);
  52432. addRawAttr(branch1, 'type', 'radio');
  52433. processElement(branch1, options);
  52434. addIfCondition(branch0, {
  52435. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  52436. block: branch1
  52437. });
  52438. // 3. other
  52439. var branch2 = cloneASTElement(el);
  52440. getAndRemoveAttr(branch2, 'v-for', true);
  52441. addRawAttr(branch2, ':type', typeBinding);
  52442. processElement(branch2, options);
  52443. addIfCondition(branch0, {
  52444. exp: ifCondition,
  52445. block: branch2
  52446. });
  52447. if (hasElse) {
  52448. branch0.else = true;
  52449. } else if (elseIfCondition) {
  52450. branch0.elseif = elseIfCondition;
  52451. }
  52452. return branch0
  52453. }
  52454. }
  52455. }
  52456. function cloneASTElement (el) {
  52457. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  52458. }
  52459. var model$1 = {
  52460. preTransformNode: preTransformNode
  52461. };
  52462. var modules$1 = [
  52463. klass$1,
  52464. style$1,
  52465. model$1
  52466. ];
  52467. /* */
  52468. function text (el, dir) {
  52469. if (dir.value) {
  52470. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  52471. }
  52472. }
  52473. /* */
  52474. function html (el, dir) {
  52475. if (dir.value) {
  52476. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  52477. }
  52478. }
  52479. var directives$1 = {
  52480. model: model,
  52481. text: text,
  52482. html: html
  52483. };
  52484. /* */
  52485. var baseOptions = {
  52486. expectHTML: true,
  52487. modules: modules$1,
  52488. directives: directives$1,
  52489. isPreTag: isPreTag,
  52490. isUnaryTag: isUnaryTag,
  52491. mustUseProp: mustUseProp,
  52492. canBeLeftOpenTag: canBeLeftOpenTag,
  52493. isReservedTag: isReservedTag,
  52494. getTagNamespace: getTagNamespace,
  52495. staticKeys: genStaticKeys(modules$1)
  52496. };
  52497. /* */
  52498. var isStaticKey;
  52499. var isPlatformReservedTag;
  52500. var genStaticKeysCached = cached(genStaticKeys$1);
  52501. /**
  52502. * Goal of the optimizer: walk the generated template AST tree
  52503. * and detect sub-trees that are purely static, i.e. parts of
  52504. * the DOM that never needs to change.
  52505. *
  52506. * Once we detect these sub-trees, we can:
  52507. *
  52508. * 1. Hoist them into constants, so that we no longer need to
  52509. * create fresh nodes for them on each re-render;
  52510. * 2. Completely skip them in the patching process.
  52511. */
  52512. function optimize (root, options) {
  52513. if (!root) { return }
  52514. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  52515. isPlatformReservedTag = options.isReservedTag || no;
  52516. // first pass: mark all non-static nodes.
  52517. markStatic$1(root);
  52518. // second pass: mark static roots.
  52519. markStaticRoots(root, false);
  52520. }
  52521. function genStaticKeys$1 (keys) {
  52522. return makeMap(
  52523. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  52524. (keys ? ',' + keys : '')
  52525. )
  52526. }
  52527. function markStatic$1 (node) {
  52528. node.static = isStatic(node);
  52529. if (node.type === 1) {
  52530. // do not make component slot content static. this avoids
  52531. // 1. components not able to mutate slot nodes
  52532. // 2. static slot content fails for hot-reloading
  52533. if (
  52534. !isPlatformReservedTag(node.tag) &&
  52535. node.tag !== 'slot' &&
  52536. node.attrsMap['inline-template'] == null
  52537. ) {
  52538. return
  52539. }
  52540. for (var i = 0, l = node.children.length; i < l; i++) {
  52541. var child = node.children[i];
  52542. markStatic$1(child);
  52543. if (!child.static) {
  52544. node.static = false;
  52545. }
  52546. }
  52547. if (node.ifConditions) {
  52548. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  52549. var block = node.ifConditions[i$1].block;
  52550. markStatic$1(block);
  52551. if (!block.static) {
  52552. node.static = false;
  52553. }
  52554. }
  52555. }
  52556. }
  52557. }
  52558. function markStaticRoots (node, isInFor) {
  52559. if (node.type === 1) {
  52560. if (node.static || node.once) {
  52561. node.staticInFor = isInFor;
  52562. }
  52563. // For a node to qualify as a static root, it should have children that
  52564. // are not just static text. Otherwise the cost of hoisting out will
  52565. // outweigh the benefits and it's better off to just always render it fresh.
  52566. if (node.static && node.children.length && !(
  52567. node.children.length === 1 &&
  52568. node.children[0].type === 3
  52569. )) {
  52570. node.staticRoot = true;
  52571. return
  52572. } else {
  52573. node.staticRoot = false;
  52574. }
  52575. if (node.children) {
  52576. for (var i = 0, l = node.children.length; i < l; i++) {
  52577. markStaticRoots(node.children[i], isInFor || !!node.for);
  52578. }
  52579. }
  52580. if (node.ifConditions) {
  52581. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  52582. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  52583. }
  52584. }
  52585. }
  52586. }
  52587. function isStatic (node) {
  52588. if (node.type === 2) { // expression
  52589. return false
  52590. }
  52591. if (node.type === 3) { // text
  52592. return true
  52593. }
  52594. return !!(node.pre || (
  52595. !node.hasBindings && // no dynamic bindings
  52596. !node.if && !node.for && // not v-if or v-for or v-else
  52597. !isBuiltInTag(node.tag) && // not a built-in
  52598. isPlatformReservedTag(node.tag) && // not a component
  52599. !isDirectChildOfTemplateFor(node) &&
  52600. Object.keys(node).every(isStaticKey)
  52601. ))
  52602. }
  52603. function isDirectChildOfTemplateFor (node) {
  52604. while (node.parent) {
  52605. node = node.parent;
  52606. if (node.tag !== 'template') {
  52607. return false
  52608. }
  52609. if (node.for) {
  52610. return true
  52611. }
  52612. }
  52613. return false
  52614. }
  52615. /* */
  52616. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  52617. var fnInvokeRE = /\([^)]*?\);*$/;
  52618. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  52619. // KeyboardEvent.keyCode aliases
  52620. var keyCodes = {
  52621. esc: 27,
  52622. tab: 9,
  52623. enter: 13,
  52624. space: 32,
  52625. up: 38,
  52626. left: 37,
  52627. right: 39,
  52628. down: 40,
  52629. 'delete': [8, 46]
  52630. };
  52631. // KeyboardEvent.key aliases
  52632. var keyNames = {
  52633. // #7880: IE11 and Edge use `Esc` for Escape key name.
  52634. esc: ['Esc', 'Escape'],
  52635. tab: 'Tab',
  52636. enter: 'Enter',
  52637. // #9112: IE11 uses `Spacebar` for Space key name.
  52638. space: [' ', 'Spacebar'],
  52639. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  52640. up: ['Up', 'ArrowUp'],
  52641. left: ['Left', 'ArrowLeft'],
  52642. right: ['Right', 'ArrowRight'],
  52643. down: ['Down', 'ArrowDown'],
  52644. // #9112: IE11 uses `Del` for Delete key name.
  52645. 'delete': ['Backspace', 'Delete', 'Del']
  52646. };
  52647. // #4868: modifiers that prevent the execution of the listener
  52648. // need to explicitly return null so that we can determine whether to remove
  52649. // the listener for .once
  52650. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  52651. var modifierCode = {
  52652. stop: '$event.stopPropagation();',
  52653. prevent: '$event.preventDefault();',
  52654. self: genGuard("$event.target !== $event.currentTarget"),
  52655. ctrl: genGuard("!$event.ctrlKey"),
  52656. shift: genGuard("!$event.shiftKey"),
  52657. alt: genGuard("!$event.altKey"),
  52658. meta: genGuard("!$event.metaKey"),
  52659. left: genGuard("'button' in $event && $event.button !== 0"),
  52660. middle: genGuard("'button' in $event && $event.button !== 1"),
  52661. right: genGuard("'button' in $event && $event.button !== 2")
  52662. };
  52663. function genHandlers (
  52664. events,
  52665. isNative
  52666. ) {
  52667. var prefix = isNative ? 'nativeOn:' : 'on:';
  52668. var staticHandlers = "";
  52669. var dynamicHandlers = "";
  52670. for (var name in events) {
  52671. var handlerCode = genHandler(events[name]);
  52672. if (events[name] && events[name].dynamic) {
  52673. dynamicHandlers += name + "," + handlerCode + ",";
  52674. } else {
  52675. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  52676. }
  52677. }
  52678. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  52679. if (dynamicHandlers) {
  52680. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  52681. } else {
  52682. return prefix + staticHandlers
  52683. }
  52684. }
  52685. function genHandler (handler) {
  52686. if (!handler) {
  52687. return 'function(){}'
  52688. }
  52689. if (Array.isArray(handler)) {
  52690. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  52691. }
  52692. var isMethodPath = simplePathRE.test(handler.value);
  52693. var isFunctionExpression = fnExpRE.test(handler.value);
  52694. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  52695. if (!handler.modifiers) {
  52696. if (isMethodPath || isFunctionExpression) {
  52697. return handler.value
  52698. }
  52699. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  52700. } else {
  52701. var code = '';
  52702. var genModifierCode = '';
  52703. var keys = [];
  52704. for (var key in handler.modifiers) {
  52705. if (modifierCode[key]) {
  52706. genModifierCode += modifierCode[key];
  52707. // left/right
  52708. if (keyCodes[key]) {
  52709. keys.push(key);
  52710. }
  52711. } else if (key === 'exact') {
  52712. var modifiers = (handler.modifiers);
  52713. genModifierCode += genGuard(
  52714. ['ctrl', 'shift', 'alt', 'meta']
  52715. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  52716. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  52717. .join('||')
  52718. );
  52719. } else {
  52720. keys.push(key);
  52721. }
  52722. }
  52723. if (keys.length) {
  52724. code += genKeyFilter(keys);
  52725. }
  52726. // Make sure modifiers like prevent and stop get executed after key filtering
  52727. if (genModifierCode) {
  52728. code += genModifierCode;
  52729. }
  52730. var handlerCode = isMethodPath
  52731. ? ("return " + (handler.value) + "($event)")
  52732. : isFunctionExpression
  52733. ? ("return (" + (handler.value) + ")($event)")
  52734. : isFunctionInvocation
  52735. ? ("return " + (handler.value))
  52736. : handler.value;
  52737. return ("function($event){" + code + handlerCode + "}")
  52738. }
  52739. }
  52740. function genKeyFilter (keys) {
  52741. return (
  52742. // make sure the key filters only apply to KeyboardEvents
  52743. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  52744. // key events that do not have keyCode property...
  52745. "if(!$event.type.indexOf('key')&&" +
  52746. (keys.map(genFilterCode).join('&&')) + ")return null;"
  52747. )
  52748. }
  52749. function genFilterCode (key) {
  52750. var keyVal = parseInt(key, 10);
  52751. if (keyVal) {
  52752. return ("$event.keyCode!==" + keyVal)
  52753. }
  52754. var keyCode = keyCodes[key];
  52755. var keyName = keyNames[key];
  52756. return (
  52757. "_k($event.keyCode," +
  52758. (JSON.stringify(key)) + "," +
  52759. (JSON.stringify(keyCode)) + "," +
  52760. "$event.key," +
  52761. "" + (JSON.stringify(keyName)) +
  52762. ")"
  52763. )
  52764. }
  52765. /* */
  52766. function on (el, dir) {
  52767. if (dir.modifiers) {
  52768. warn("v-on without argument does not support modifiers.");
  52769. }
  52770. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  52771. }
  52772. /* */
  52773. function bind$1 (el, dir) {
  52774. el.wrapData = function (code) {
  52775. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  52776. };
  52777. }
  52778. /* */
  52779. var baseDirectives = {
  52780. on: on,
  52781. bind: bind$1,
  52782. cloak: noop
  52783. };
  52784. /* */
  52785. var CodegenState = function CodegenState (options) {
  52786. this.options = options;
  52787. this.warn = options.warn || baseWarn;
  52788. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  52789. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  52790. this.directives = extend(extend({}, baseDirectives), options.directives);
  52791. var isReservedTag = options.isReservedTag || no;
  52792. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  52793. this.onceId = 0;
  52794. this.staticRenderFns = [];
  52795. this.pre = false;
  52796. };
  52797. function generate (
  52798. ast,
  52799. options
  52800. ) {
  52801. var state = new CodegenState(options);
  52802. var code = ast ? genElement(ast, state) : '_c("div")';
  52803. return {
  52804. render: ("with(this){return " + code + "}"),
  52805. staticRenderFns: state.staticRenderFns
  52806. }
  52807. }
  52808. function genElement (el, state) {
  52809. if (el.parent) {
  52810. el.pre = el.pre || el.parent.pre;
  52811. }
  52812. if (el.staticRoot && !el.staticProcessed) {
  52813. return genStatic(el, state)
  52814. } else if (el.once && !el.onceProcessed) {
  52815. return genOnce(el, state)
  52816. } else if (el.for && !el.forProcessed) {
  52817. return genFor(el, state)
  52818. } else if (el.if && !el.ifProcessed) {
  52819. return genIf(el, state)
  52820. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  52821. return genChildren(el, state) || 'void 0'
  52822. } else if (el.tag === 'slot') {
  52823. return genSlot(el, state)
  52824. } else {
  52825. // component or element
  52826. var code;
  52827. if (el.component) {
  52828. code = genComponent(el.component, el, state);
  52829. } else {
  52830. var data;
  52831. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  52832. data = genData$2(el, state);
  52833. }
  52834. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  52835. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  52836. }
  52837. // module transforms
  52838. for (var i = 0; i < state.transforms.length; i++) {
  52839. code = state.transforms[i](el, code);
  52840. }
  52841. return code
  52842. }
  52843. }
  52844. // hoist static sub-trees out
  52845. function genStatic (el, state) {
  52846. el.staticProcessed = true;
  52847. // Some elements (templates) need to behave differently inside of a v-pre
  52848. // node. All pre nodes are static roots, so we can use this as a location to
  52849. // wrap a state change and reset it upon exiting the pre node.
  52850. var originalPreState = state.pre;
  52851. if (el.pre) {
  52852. state.pre = el.pre;
  52853. }
  52854. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  52855. state.pre = originalPreState;
  52856. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  52857. }
  52858. // v-once
  52859. function genOnce (el, state) {
  52860. el.onceProcessed = true;
  52861. if (el.if && !el.ifProcessed) {
  52862. return genIf(el, state)
  52863. } else if (el.staticInFor) {
  52864. var key = '';
  52865. var parent = el.parent;
  52866. while (parent) {
  52867. if (parent.for) {
  52868. key = parent.key;
  52869. break
  52870. }
  52871. parent = parent.parent;
  52872. }
  52873. if (!key) {
  52874. state.warn(
  52875. "v-once can only be used inside v-for that is keyed. ",
  52876. el.rawAttrsMap['v-once']
  52877. );
  52878. return genElement(el, state)
  52879. }
  52880. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  52881. } else {
  52882. return genStatic(el, state)
  52883. }
  52884. }
  52885. function genIf (
  52886. el,
  52887. state,
  52888. altGen,
  52889. altEmpty
  52890. ) {
  52891. el.ifProcessed = true; // avoid recursion
  52892. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  52893. }
  52894. function genIfConditions (
  52895. conditions,
  52896. state,
  52897. altGen,
  52898. altEmpty
  52899. ) {
  52900. if (!conditions.length) {
  52901. return altEmpty || '_e()'
  52902. }
  52903. var condition = conditions.shift();
  52904. if (condition.exp) {
  52905. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  52906. } else {
  52907. return ("" + (genTernaryExp(condition.block)))
  52908. }
  52909. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  52910. function genTernaryExp (el) {
  52911. return altGen
  52912. ? altGen(el, state)
  52913. : el.once
  52914. ? genOnce(el, state)
  52915. : genElement(el, state)
  52916. }
  52917. }
  52918. function genFor (
  52919. el,
  52920. state,
  52921. altGen,
  52922. altHelper
  52923. ) {
  52924. var exp = el.for;
  52925. var alias = el.alias;
  52926. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  52927. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  52928. if (state.maybeComponent(el) &&
  52929. el.tag !== 'slot' &&
  52930. el.tag !== 'template' &&
  52931. !el.key
  52932. ) {
  52933. state.warn(
  52934. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  52935. "v-for should have explicit keys. " +
  52936. "See https://vuejs.org/guide/list.html#key for more info.",
  52937. el.rawAttrsMap['v-for'],
  52938. true /* tip */
  52939. );
  52940. }
  52941. el.forProcessed = true; // avoid recursion
  52942. return (altHelper || '_l') + "((" + exp + ")," +
  52943. "function(" + alias + iterator1 + iterator2 + "){" +
  52944. "return " + ((altGen || genElement)(el, state)) +
  52945. '})'
  52946. }
  52947. function genData$2 (el, state) {
  52948. var data = '{';
  52949. // directives first.
  52950. // directives may mutate the el's other properties before they are generated.
  52951. var dirs = genDirectives(el, state);
  52952. if (dirs) { data += dirs + ','; }
  52953. // key
  52954. if (el.key) {
  52955. data += "key:" + (el.key) + ",";
  52956. }
  52957. // ref
  52958. if (el.ref) {
  52959. data += "ref:" + (el.ref) + ",";
  52960. }
  52961. if (el.refInFor) {
  52962. data += "refInFor:true,";
  52963. }
  52964. // pre
  52965. if (el.pre) {
  52966. data += "pre:true,";
  52967. }
  52968. // record original tag name for components using "is" attribute
  52969. if (el.component) {
  52970. data += "tag:\"" + (el.tag) + "\",";
  52971. }
  52972. // module data generation functions
  52973. for (var i = 0; i < state.dataGenFns.length; i++) {
  52974. data += state.dataGenFns[i](el);
  52975. }
  52976. // attributes
  52977. if (el.attrs) {
  52978. data += "attrs:" + (genProps(el.attrs)) + ",";
  52979. }
  52980. // DOM props
  52981. if (el.props) {
  52982. data += "domProps:" + (genProps(el.props)) + ",";
  52983. }
  52984. // event handlers
  52985. if (el.events) {
  52986. data += (genHandlers(el.events, false)) + ",";
  52987. }
  52988. if (el.nativeEvents) {
  52989. data += (genHandlers(el.nativeEvents, true)) + ",";
  52990. }
  52991. // slot target
  52992. // only for non-scoped slots
  52993. if (el.slotTarget && !el.slotScope) {
  52994. data += "slot:" + (el.slotTarget) + ",";
  52995. }
  52996. // scoped slots
  52997. if (el.scopedSlots) {
  52998. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  52999. }
  53000. // component v-model
  53001. if (el.model) {
  53002. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  53003. }
  53004. // inline-template
  53005. if (el.inlineTemplate) {
  53006. var inlineTemplate = genInlineTemplate(el, state);
  53007. if (inlineTemplate) {
  53008. data += inlineTemplate + ",";
  53009. }
  53010. }
  53011. data = data.replace(/,$/, '') + '}';
  53012. // v-bind dynamic argument wrap
  53013. // v-bind with dynamic arguments must be applied using the same v-bind object
  53014. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  53015. if (el.dynamicAttrs) {
  53016. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  53017. }
  53018. // v-bind data wrap
  53019. if (el.wrapData) {
  53020. data = el.wrapData(data);
  53021. }
  53022. // v-on data wrap
  53023. if (el.wrapListeners) {
  53024. data = el.wrapListeners(data);
  53025. }
  53026. return data
  53027. }
  53028. function genDirectives (el, state) {
  53029. var dirs = el.directives;
  53030. if (!dirs) { return }
  53031. var res = 'directives:[';
  53032. var hasRuntime = false;
  53033. var i, l, dir, needRuntime;
  53034. for (i = 0, l = dirs.length; i < l; i++) {
  53035. dir = dirs[i];
  53036. needRuntime = true;
  53037. var gen = state.directives[dir.name];
  53038. if (gen) {
  53039. // compile-time directive that manipulates AST.
  53040. // returns true if it also needs a runtime counterpart.
  53041. needRuntime = !!gen(el, dir, state.warn);
  53042. }
  53043. if (needRuntime) {
  53044. hasRuntime = true;
  53045. 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))) : '') + "},";
  53046. }
  53047. }
  53048. if (hasRuntime) {
  53049. return res.slice(0, -1) + ']'
  53050. }
  53051. }
  53052. function genInlineTemplate (el, state) {
  53053. var ast = el.children[0];
  53054. if (el.children.length !== 1 || ast.type !== 1) {
  53055. state.warn(
  53056. 'Inline-template components must have exactly one child element.',
  53057. { start: el.start }
  53058. );
  53059. }
  53060. if (ast && ast.type === 1) {
  53061. var inlineRenderFns = generate(ast, state.options);
  53062. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  53063. }
  53064. }
  53065. function genScopedSlots (
  53066. el,
  53067. slots,
  53068. state
  53069. ) {
  53070. // by default scoped slots are considered "stable", this allows child
  53071. // components with only scoped slots to skip forced updates from parent.
  53072. // but in some cases we have to bail-out of this optimization
  53073. // for example if the slot contains dynamic names, has v-if or v-for on them...
  53074. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  53075. var slot = slots[key];
  53076. return (
  53077. slot.slotTargetDynamic ||
  53078. slot.if ||
  53079. slot.for ||
  53080. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  53081. )
  53082. });
  53083. // #9534: if a component with scoped slots is inside a conditional branch,
  53084. // it's possible for the same component to be reused but with different
  53085. // compiled slot content. To avoid that, we generate a unique key based on
  53086. // the generated code of all the slot contents.
  53087. var needsKey = !!el.if;
  53088. // OR when it is inside another scoped slot or v-for (the reactivity may be
  53089. // disconnected due to the intermediate scope variable)
  53090. // #9438, #9506
  53091. // TODO: this can be further optimized by properly analyzing in-scope bindings
  53092. // and skip force updating ones that do not actually use scope variables.
  53093. if (!needsForceUpdate) {
  53094. var parent = el.parent;
  53095. while (parent) {
  53096. if (
  53097. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  53098. parent.for
  53099. ) {
  53100. needsForceUpdate = true;
  53101. break
  53102. }
  53103. if (parent.if) {
  53104. needsKey = true;
  53105. }
  53106. parent = parent.parent;
  53107. }
  53108. }
  53109. var generatedSlots = Object.keys(slots)
  53110. .map(function (key) { return genScopedSlot(slots[key], state); })
  53111. .join(',');
  53112. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  53113. }
  53114. function hash(str) {
  53115. var hash = 5381;
  53116. var i = str.length;
  53117. while(i) {
  53118. hash = (hash * 33) ^ str.charCodeAt(--i);
  53119. }
  53120. return hash >>> 0
  53121. }
  53122. function containsSlotChild (el) {
  53123. if (el.type === 1) {
  53124. if (el.tag === 'slot') {
  53125. return true
  53126. }
  53127. return el.children.some(containsSlotChild)
  53128. }
  53129. return false
  53130. }
  53131. function genScopedSlot (
  53132. el,
  53133. state
  53134. ) {
  53135. var isLegacySyntax = el.attrsMap['slot-scope'];
  53136. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  53137. return genIf(el, state, genScopedSlot, "null")
  53138. }
  53139. if (el.for && !el.forProcessed) {
  53140. return genFor(el, state, genScopedSlot)
  53141. }
  53142. var slotScope = el.slotScope === emptySlotScopeToken
  53143. ? ""
  53144. : String(el.slotScope);
  53145. var fn = "function(" + slotScope + "){" +
  53146. "return " + (el.tag === 'template'
  53147. ? el.if && isLegacySyntax
  53148. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  53149. : genChildren(el, state) || 'undefined'
  53150. : genElement(el, state)) + "}";
  53151. // reverse proxy v-slot without scope on this.$slots
  53152. var reverseProxy = slotScope ? "" : ",proxy:true";
  53153. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  53154. }
  53155. function genChildren (
  53156. el,
  53157. state,
  53158. checkSkip,
  53159. altGenElement,
  53160. altGenNode
  53161. ) {
  53162. var children = el.children;
  53163. if (children.length) {
  53164. var el$1 = children[0];
  53165. // optimize single v-for
  53166. if (children.length === 1 &&
  53167. el$1.for &&
  53168. el$1.tag !== 'template' &&
  53169. el$1.tag !== 'slot'
  53170. ) {
  53171. var normalizationType = checkSkip
  53172. ? state.maybeComponent(el$1) ? ",1" : ",0"
  53173. : "";
  53174. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  53175. }
  53176. var normalizationType$1 = checkSkip
  53177. ? getNormalizationType(children, state.maybeComponent)
  53178. : 0;
  53179. var gen = altGenNode || genNode;
  53180. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  53181. }
  53182. }
  53183. // determine the normalization needed for the children array.
  53184. // 0: no normalization needed
  53185. // 1: simple normalization needed (possible 1-level deep nested array)
  53186. // 2: full normalization needed
  53187. function getNormalizationType (
  53188. children,
  53189. maybeComponent
  53190. ) {
  53191. var res = 0;
  53192. for (var i = 0; i < children.length; i++) {
  53193. var el = children[i];
  53194. if (el.type !== 1) {
  53195. continue
  53196. }
  53197. if (needsNormalization(el) ||
  53198. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  53199. res = 2;
  53200. break
  53201. }
  53202. if (maybeComponent(el) ||
  53203. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  53204. res = 1;
  53205. }
  53206. }
  53207. return res
  53208. }
  53209. function needsNormalization (el) {
  53210. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  53211. }
  53212. function genNode (node, state) {
  53213. if (node.type === 1) {
  53214. return genElement(node, state)
  53215. } else if (node.type === 3 && node.isComment) {
  53216. return genComment(node)
  53217. } else {
  53218. return genText(node)
  53219. }
  53220. }
  53221. function genText (text) {
  53222. return ("_v(" + (text.type === 2
  53223. ? text.expression // no need for () because already wrapped in _s()
  53224. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  53225. }
  53226. function genComment (comment) {
  53227. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  53228. }
  53229. function genSlot (el, state) {
  53230. var slotName = el.slotName || '"default"';
  53231. var children = genChildren(el, state);
  53232. var res = "_t(" + slotName + (children ? ("," + children) : '');
  53233. var attrs = el.attrs || el.dynamicAttrs
  53234. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  53235. // slot props are camelized
  53236. name: camelize(attr.name),
  53237. value: attr.value,
  53238. dynamic: attr.dynamic
  53239. }); }))
  53240. : null;
  53241. var bind$$1 = el.attrsMap['v-bind'];
  53242. if ((attrs || bind$$1) && !children) {
  53243. res += ",null";
  53244. }
  53245. if (attrs) {
  53246. res += "," + attrs;
  53247. }
  53248. if (bind$$1) {
  53249. res += (attrs ? '' : ',null') + "," + bind$$1;
  53250. }
  53251. return res + ')'
  53252. }
  53253. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  53254. function genComponent (
  53255. componentName,
  53256. el,
  53257. state
  53258. ) {
  53259. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  53260. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  53261. }
  53262. function genProps (props) {
  53263. var staticProps = "";
  53264. var dynamicProps = "";
  53265. for (var i = 0; i < props.length; i++) {
  53266. var prop = props[i];
  53267. var value = transformSpecialNewlines(prop.value);
  53268. if (prop.dynamic) {
  53269. dynamicProps += (prop.name) + "," + value + ",";
  53270. } else {
  53271. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  53272. }
  53273. }
  53274. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  53275. if (dynamicProps) {
  53276. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  53277. } else {
  53278. return staticProps
  53279. }
  53280. }
  53281. // #3895, #4268
  53282. function transformSpecialNewlines (text) {
  53283. return text
  53284. .replace(/\u2028/g, '\\u2028')
  53285. .replace(/\u2029/g, '\\u2029')
  53286. }
  53287. /* */
  53288. // these keywords should not appear inside expressions, but operators like
  53289. // typeof, instanceof and in are allowed
  53290. var prohibitedKeywordRE = new RegExp('\\b' + (
  53291. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  53292. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  53293. 'extends,finally,continue,debugger,function,arguments'
  53294. ).split(',').join('\\b|\\b') + '\\b');
  53295. // these unary operators should not be used as property/method names
  53296. var unaryOperatorsRE = new RegExp('\\b' + (
  53297. 'delete,typeof,void'
  53298. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  53299. // strip strings in expressions
  53300. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  53301. // detect problematic expressions in a template
  53302. function detectErrors (ast, warn) {
  53303. if (ast) {
  53304. checkNode(ast, warn);
  53305. }
  53306. }
  53307. function checkNode (node, warn) {
  53308. if (node.type === 1) {
  53309. for (var name in node.attrsMap) {
  53310. if (dirRE.test(name)) {
  53311. var value = node.attrsMap[name];
  53312. if (value) {
  53313. var range = node.rawAttrsMap[name];
  53314. if (name === 'v-for') {
  53315. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  53316. } else if (name === 'v-slot' || name[0] === '#') {
  53317. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  53318. } else if (onRE.test(name)) {
  53319. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  53320. } else {
  53321. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  53322. }
  53323. }
  53324. }
  53325. }
  53326. if (node.children) {
  53327. for (var i = 0; i < node.children.length; i++) {
  53328. checkNode(node.children[i], warn);
  53329. }
  53330. }
  53331. } else if (node.type === 2) {
  53332. checkExpression(node.expression, node.text, warn, node);
  53333. }
  53334. }
  53335. function checkEvent (exp, text, warn, range) {
  53336. var stripped = exp.replace(stripStringRE, '');
  53337. var keywordMatch = stripped.match(unaryOperatorsRE);
  53338. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  53339. warn(
  53340. "avoid using JavaScript unary operator as property name: " +
  53341. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  53342. range
  53343. );
  53344. }
  53345. checkExpression(exp, text, warn, range);
  53346. }
  53347. function checkFor (node, text, warn, range) {
  53348. checkExpression(node.for || '', text, warn, range);
  53349. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  53350. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  53351. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  53352. }
  53353. function checkIdentifier (
  53354. ident,
  53355. type,
  53356. text,
  53357. warn,
  53358. range
  53359. ) {
  53360. if (typeof ident === 'string') {
  53361. try {
  53362. new Function(("var " + ident + "=_"));
  53363. } catch (e) {
  53364. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  53365. }
  53366. }
  53367. }
  53368. function checkExpression (exp, text, warn, range) {
  53369. try {
  53370. new Function(("return " + exp));
  53371. } catch (e) {
  53372. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  53373. if (keywordMatch) {
  53374. warn(
  53375. "avoid using JavaScript keyword as property name: " +
  53376. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  53377. range
  53378. );
  53379. } else {
  53380. warn(
  53381. "invalid expression: " + (e.message) + " in\n\n" +
  53382. " " + exp + "\n\n" +
  53383. " Raw expression: " + (text.trim()) + "\n",
  53384. range
  53385. );
  53386. }
  53387. }
  53388. }
  53389. function checkFunctionParameterExpression (exp, text, warn, range) {
  53390. try {
  53391. new Function(exp, '');
  53392. } catch (e) {
  53393. warn(
  53394. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  53395. " " + exp + "\n\n" +
  53396. " Raw expression: " + (text.trim()) + "\n",
  53397. range
  53398. );
  53399. }
  53400. }
  53401. /* */
  53402. var range = 2;
  53403. function generateCodeFrame (
  53404. source,
  53405. start,
  53406. end
  53407. ) {
  53408. if ( start === void 0 ) start = 0;
  53409. if ( end === void 0 ) end = source.length;
  53410. var lines = source.split(/\r?\n/);
  53411. var count = 0;
  53412. var res = [];
  53413. for (var i = 0; i < lines.length; i++) {
  53414. count += lines[i].length + 1;
  53415. if (count >= start) {
  53416. for (var j = i - range; j <= i + range || end > count; j++) {
  53417. if (j < 0 || j >= lines.length) { continue }
  53418. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  53419. var lineLength = lines[j].length;
  53420. if (j === i) {
  53421. // push underline
  53422. var pad = start - (count - lineLength) + 1;
  53423. var length = end > count ? lineLength - pad : end - start;
  53424. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  53425. } else if (j > i) {
  53426. if (end > count) {
  53427. var length$1 = Math.min(end - count, lineLength);
  53428. res.push(" | " + repeat$1("^", length$1));
  53429. }
  53430. count += lineLength + 1;
  53431. }
  53432. }
  53433. break
  53434. }
  53435. }
  53436. return res.join('\n')
  53437. }
  53438. function repeat$1 (str, n) {
  53439. var result = '';
  53440. if (n > 0) {
  53441. while (true) { // eslint-disable-line
  53442. if (n & 1) { result += str; }
  53443. n >>>= 1;
  53444. if (n <= 0) { break }
  53445. str += str;
  53446. }
  53447. }
  53448. return result
  53449. }
  53450. /* */
  53451. function createFunction (code, errors) {
  53452. try {
  53453. return new Function(code)
  53454. } catch (err) {
  53455. errors.push({ err: err, code: code });
  53456. return noop
  53457. }
  53458. }
  53459. function createCompileToFunctionFn (compile) {
  53460. var cache = Object.create(null);
  53461. return function compileToFunctions (
  53462. template,
  53463. options,
  53464. vm
  53465. ) {
  53466. options = extend({}, options);
  53467. var warn$$1 = options.warn || warn;
  53468. delete options.warn;
  53469. /* istanbul ignore if */
  53470. {
  53471. // detect possible CSP restriction
  53472. try {
  53473. new Function('return 1');
  53474. } catch (e) {
  53475. if (e.toString().match(/unsafe-eval|CSP/)) {
  53476. warn$$1(
  53477. 'It seems you are using the standalone build of Vue.js in an ' +
  53478. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  53479. 'The template compiler cannot work in this environment. Consider ' +
  53480. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  53481. 'templates into render functions.'
  53482. );
  53483. }
  53484. }
  53485. }
  53486. // check cache
  53487. var key = options.delimiters
  53488. ? String(options.delimiters) + template
  53489. : template;
  53490. if (cache[key]) {
  53491. return cache[key]
  53492. }
  53493. // compile
  53494. var compiled = compile(template, options);
  53495. // check compilation errors/tips
  53496. {
  53497. if (compiled.errors && compiled.errors.length) {
  53498. if (options.outputSourceRange) {
  53499. compiled.errors.forEach(function (e) {
  53500. warn$$1(
  53501. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  53502. generateCodeFrame(template, e.start, e.end),
  53503. vm
  53504. );
  53505. });
  53506. } else {
  53507. warn$$1(
  53508. "Error compiling template:\n\n" + template + "\n\n" +
  53509. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  53510. vm
  53511. );
  53512. }
  53513. }
  53514. if (compiled.tips && compiled.tips.length) {
  53515. if (options.outputSourceRange) {
  53516. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  53517. } else {
  53518. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  53519. }
  53520. }
  53521. }
  53522. // turn code into functions
  53523. var res = {};
  53524. var fnGenErrors = [];
  53525. res.render = createFunction(compiled.render, fnGenErrors);
  53526. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  53527. return createFunction(code, fnGenErrors)
  53528. });
  53529. // check function generation errors.
  53530. // this should only happen if there is a bug in the compiler itself.
  53531. // mostly for codegen development use
  53532. /* istanbul ignore if */
  53533. {
  53534. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  53535. warn$$1(
  53536. "Failed to generate render function:\n\n" +
  53537. fnGenErrors.map(function (ref) {
  53538. var err = ref.err;
  53539. var code = ref.code;
  53540. return ((err.toString()) + " in\n\n" + code + "\n");
  53541. }).join('\n'),
  53542. vm
  53543. );
  53544. }
  53545. }
  53546. return (cache[key] = res)
  53547. }
  53548. }
  53549. /* */
  53550. function createCompilerCreator (baseCompile) {
  53551. return function createCompiler (baseOptions) {
  53552. function compile (
  53553. template,
  53554. options
  53555. ) {
  53556. var finalOptions = Object.create(baseOptions);
  53557. var errors = [];
  53558. var tips = [];
  53559. var warn = function (msg, range, tip) {
  53560. (tip ? tips : errors).push(msg);
  53561. };
  53562. if (options) {
  53563. if (options.outputSourceRange) {
  53564. // $flow-disable-line
  53565. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  53566. warn = function (msg, range, tip) {
  53567. var data = { msg: msg };
  53568. if (range) {
  53569. if (range.start != null) {
  53570. data.start = range.start + leadingSpaceLength;
  53571. }
  53572. if (range.end != null) {
  53573. data.end = range.end + leadingSpaceLength;
  53574. }
  53575. }
  53576. (tip ? tips : errors).push(data);
  53577. };
  53578. }
  53579. // merge custom modules
  53580. if (options.modules) {
  53581. finalOptions.modules =
  53582. (baseOptions.modules || []).concat(options.modules);
  53583. }
  53584. // merge custom directives
  53585. if (options.directives) {
  53586. finalOptions.directives = extend(
  53587. Object.create(baseOptions.directives || null),
  53588. options.directives
  53589. );
  53590. }
  53591. // copy other options
  53592. for (var key in options) {
  53593. if (key !== 'modules' && key !== 'directives') {
  53594. finalOptions[key] = options[key];
  53595. }
  53596. }
  53597. }
  53598. finalOptions.warn = warn;
  53599. var compiled = baseCompile(template.trim(), finalOptions);
  53600. {
  53601. detectErrors(compiled.ast, warn);
  53602. }
  53603. compiled.errors = errors;
  53604. compiled.tips = tips;
  53605. return compiled
  53606. }
  53607. return {
  53608. compile: compile,
  53609. compileToFunctions: createCompileToFunctionFn(compile)
  53610. }
  53611. }
  53612. }
  53613. /* */
  53614. // `createCompilerCreator` allows creating compilers that use alternative
  53615. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  53616. // Here we just export a default compiler using the default parts.
  53617. var createCompiler = createCompilerCreator(function baseCompile (
  53618. template,
  53619. options
  53620. ) {
  53621. var ast = parse(template.trim(), options);
  53622. if (options.optimize !== false) {
  53623. optimize(ast, options);
  53624. }
  53625. var code = generate(ast, options);
  53626. return {
  53627. ast: ast,
  53628. render: code.render,
  53629. staticRenderFns: code.staticRenderFns
  53630. }
  53631. });
  53632. /* */
  53633. var ref$1 = createCompiler(baseOptions);
  53634. var compile = ref$1.compile;
  53635. var compileToFunctions = ref$1.compileToFunctions;
  53636. /* */
  53637. // check whether current browser encodes a char inside attribute values
  53638. var div;
  53639. function getShouldDecode (href) {
  53640. div = div || document.createElement('div');
  53641. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  53642. return div.innerHTML.indexOf('&#10;') > 0
  53643. }
  53644. // #3663: IE encodes newlines inside attribute values while other browsers don't
  53645. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  53646. // #6828: chrome encodes content in a[href]
  53647. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  53648. /* */
  53649. var idToTemplate = cached(function (id) {
  53650. var el = query(id);
  53651. return el && el.innerHTML
  53652. });
  53653. var mount = Vue.prototype.$mount;
  53654. Vue.prototype.$mount = function (
  53655. el,
  53656. hydrating
  53657. ) {
  53658. el = el && query(el);
  53659. /* istanbul ignore if */
  53660. if (el === document.body || el === document.documentElement) {
  53661. warn(
  53662. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  53663. );
  53664. return this
  53665. }
  53666. var options = this.$options;
  53667. // resolve template/el and convert to render function
  53668. if (!options.render) {
  53669. var template = options.template;
  53670. if (template) {
  53671. if (typeof template === 'string') {
  53672. if (template.charAt(0) === '#') {
  53673. template = idToTemplate(template);
  53674. /* istanbul ignore if */
  53675. if (!template) {
  53676. warn(
  53677. ("Template element not found or is empty: " + (options.template)),
  53678. this
  53679. );
  53680. }
  53681. }
  53682. } else if (template.nodeType) {
  53683. template = template.innerHTML;
  53684. } else {
  53685. {
  53686. warn('invalid template option:' + template, this);
  53687. }
  53688. return this
  53689. }
  53690. } else if (el) {
  53691. template = getOuterHTML(el);
  53692. }
  53693. if (template) {
  53694. /* istanbul ignore if */
  53695. if (config.performance && mark) {
  53696. mark('compile');
  53697. }
  53698. var ref = compileToFunctions(template, {
  53699. outputSourceRange: "development" !== 'production',
  53700. shouldDecodeNewlines: shouldDecodeNewlines,
  53701. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  53702. delimiters: options.delimiters,
  53703. comments: options.comments
  53704. }, this);
  53705. var render = ref.render;
  53706. var staticRenderFns = ref.staticRenderFns;
  53707. options.render = render;
  53708. options.staticRenderFns = staticRenderFns;
  53709. /* istanbul ignore if */
  53710. if (config.performance && mark) {
  53711. mark('compile end');
  53712. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  53713. }
  53714. }
  53715. }
  53716. return mount.call(this, el, hydrating)
  53717. };
  53718. /**
  53719. * Get outerHTML of elements, taking care
  53720. * of SVG elements in IE as well.
  53721. */
  53722. function getOuterHTML (el) {
  53723. if (el.outerHTML) {
  53724. return el.outerHTML
  53725. } else {
  53726. var container = document.createElement('div');
  53727. container.appendChild(el.cloneNode(true));
  53728. return container.innerHTML
  53729. }
  53730. }
  53731. Vue.compile = compileToFunctions;
  53732. module.exports = Vue;
  53733. /* 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))
  53734. /***/ }),
  53735. /***/ "./node_modules/vue/dist/vue.common.js":
  53736. /*!*********************************************!*\
  53737. !*** ./node_modules/vue/dist/vue.common.js ***!
  53738. \*********************************************/
  53739. /*! no static exports found */
  53740. /***/ (function(module, exports, __webpack_require__) {
  53741. if (false) {} else {
  53742. module.exports = __webpack_require__(/*! ./vue.common.dev.js */ "./node_modules/vue/dist/vue.common.dev.js")
  53743. }
  53744. /***/ }),
  53745. /***/ "./node_modules/webpack/buildin/global.js":
  53746. /*!***********************************!*\
  53747. !*** (webpack)/buildin/global.js ***!
  53748. \***********************************/
  53749. /*! no static exports found */
  53750. /***/ (function(module, exports) {
  53751. var g;
  53752. // This works in non-strict mode
  53753. g = (function() {
  53754. return this;
  53755. })();
  53756. try {
  53757. // This works if eval is allowed (see CSP)
  53758. g = g || new Function("return this")();
  53759. } catch (e) {
  53760. // This works if the window reference is available
  53761. if (typeof window === "object") g = window;
  53762. }
  53763. // g can still be undefined, but nothing to do about it...
  53764. // We return undefined, instead of nothing here, so it's
  53765. // easier to handle this case. if(!global) { ...}
  53766. module.exports = g;
  53767. /***/ }),
  53768. /***/ "./node_modules/webpack/buildin/module.js":
  53769. /*!***********************************!*\
  53770. !*** (webpack)/buildin/module.js ***!
  53771. \***********************************/
  53772. /*! no static exports found */
  53773. /***/ (function(module, exports) {
  53774. module.exports = function(module) {
  53775. if (!module.webpackPolyfill) {
  53776. module.deprecate = function() {};
  53777. module.paths = [];
  53778. // module.parent = undefined by default
  53779. if (!module.children) module.children = [];
  53780. Object.defineProperty(module, "loaded", {
  53781. enumerable: true,
  53782. get: function() {
  53783. return module.l;
  53784. }
  53785. });
  53786. Object.defineProperty(module, "id", {
  53787. enumerable: true,
  53788. get: function() {
  53789. return module.i;
  53790. }
  53791. });
  53792. module.webpackPolyfill = 1;
  53793. }
  53794. return module;
  53795. };
  53796. /***/ }),
  53797. /***/ "./resources/js/app.js":
  53798. /*!*****************************!*\
  53799. !*** ./resources/js/app.js ***!
  53800. \*****************************/
  53801. /*! no static exports found */
  53802. /***/ (function(module, exports, __webpack_require__) {
  53803. /**
  53804. * First we will load all of this project's JavaScript dependencies which
  53805. * includes Vue and other libraries. It is a great starting point when
  53806. * building robust, powerful web applications using Vue and Laravel.
  53807. */
  53808. __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
  53809. window.Clipboard = __webpack_require__(/*! clipboard */ "./node_modules/clipboard/dist/clipboard.js");
  53810. __webpack_require__(/*! ./notify.min.js */ "./resources/js/notify.min.js");
  53811. window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
  53812. /**
  53813. * The following block of code may be used to automatically register your
  53814. * Vue components. It will recursively scan this directory for the Vue
  53815. * components and automatically register them with their "basename".
  53816. *
  53817. * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
  53818. */
  53819. // const files = require.context('./', true, /\.vue$/i)
  53820. // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
  53821. Vue.component('example-component', __webpack_require__(/*! ./components/ExampleComponent.vue */ "./resources/js/components/ExampleComponent.vue")["default"]);
  53822. Vue.component('woinfo', __webpack_require__(/*! ./components/woinfo.vue */ "./resources/js/components/woinfo.vue")["default"]);
  53823. Vue.component('assetinfo', __webpack_require__(/*! ./components/assetinfo.vue */ "./resources/js/components/assetinfo.vue")["default"]);
  53824. Vue.component('credential', __webpack_require__(/*! ./components/credential.vue */ "./resources/js/components/credential.vue")["default"]);
  53825. Vue.component('notes', __webpack_require__(/*! ./components/notes.vue */ "./resources/js/components/notes.vue")["default"]);
  53826. /**
  53827. * Next, we will create a fresh Vue application instance and attach it to
  53828. * the page. Then, you may begin adding components to this application
  53829. * or customize the JavaScript scaffolding to fit your unique needs.
  53830. */
  53831. var app = new Vue({
  53832. el: '#app'
  53833. });
  53834. $(function () {
  53835. $('[data-toggle="tooltip"]').tooltip();
  53836. });
  53837. var clipboard = new Clipboard('.btn-clip');
  53838. clipboard.on('success', function (e) {
  53839. $('#' + e.trigger.getAttribute('id')).notify('Copied to Clipboard', {
  53840. position: "right",
  53841. className: 'success'
  53842. });
  53843. e.clearSelection();
  53844. });
  53845. /***/ }),
  53846. /***/ "./resources/js/bootstrap.js":
  53847. /*!***********************************!*\
  53848. !*** ./resources/js/bootstrap.js ***!
  53849. \***********************************/
  53850. /*! no exports provided */
  53851. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53852. "use strict";
  53853. __webpack_require__.r(__webpack_exports__);
  53854. /* harmony import */ var laravel_echo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! laravel-echo */ "./node_modules/laravel-echo/dist/echo.js");
  53855. window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
  53856. /**
  53857. * We'll load jQuery and the Bootstrap jQuery plugin which provides support
  53858. * for JavaScript based Bootstrap features such as modals and tabs. This
  53859. * code may be modified to fit the specific needs of your application.
  53860. */
  53861. try {
  53862. window.Popper = __webpack_require__(/*! popper.js */ "./node_modules/popper.js/dist/esm/popper.js")["default"];
  53863. window.$ = window.jQuery = __webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js");
  53864. __webpack_require__(/*! bootstrap */ "./node_modules/bootstrap/dist/js/bootstrap.js");
  53865. } catch (e) {}
  53866. /**
  53867. * We'll load the axios HTTP library which allows us to easily issue requests
  53868. * to our Laravel back-end. This library automatically handles sending the
  53869. * CSRF token as a header based on the value of the "XSRF" token cookie.
  53870. */
  53871. window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js");
  53872. window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  53873. /**
  53874. * Echo exposes an expressive API for subscribing to channels and listening
  53875. * for events that are broadcast by Laravel. Echo and event broadcasting
  53876. * allows your team to easily build robust real-time web applications.
  53877. */
  53878. window.Pusher = __webpack_require__(/*! pusher-js */ "./node_modules/pusher-js/dist/web/pusher.js");
  53879. window.Echo = new laravel_echo__WEBPACK_IMPORTED_MODULE_0__["default"]({
  53880. broadcaster: 'pusher',
  53881. key: "upccrt",
  53882. wsHost: window.location.hostname,
  53883. wsPort: 6001,
  53884. disableStats: true
  53885. });
  53886. /***/ }),
  53887. /***/ "./resources/js/components/ExampleComponent.vue":
  53888. /*!******************************************************!*\
  53889. !*** ./resources/js/components/ExampleComponent.vue ***!
  53890. \******************************************************/
  53891. /*! exports provided: default */
  53892. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53893. "use strict";
  53894. __webpack_require__.r(__webpack_exports__);
  53895. /* 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&");
  53896. /* 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&");
  53897. /* 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");
  53898. /* normalize component */
  53899. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  53900. _ExampleComponent_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  53901. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["render"],
  53902. _ExampleComponent_vue_vue_type_template_id_299e239e___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  53903. false,
  53904. null,
  53905. null,
  53906. null
  53907. )
  53908. /* hot reload */
  53909. if (false) { var api; }
  53910. component.options.__file = "resources/js/components/ExampleComponent.vue"
  53911. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  53912. /***/ }),
  53913. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&":
  53914. /*!*******************************************************************************!*\
  53915. !*** ./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& ***!
  53916. \*******************************************************************************/
  53917. /*! exports provided: default */
  53918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53919. "use strict";
  53920. __webpack_require__.r(__webpack_exports__);
  53921. /* 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&");
  53922. /* 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"]);
  53923. /***/ }),
  53924. /***/ "./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e&":
  53925. /*!*************************************************************************************!*\
  53926. !*** ./resources/js/components/ExampleComponent.vue?vue&type=template&id=299e239e& ***!
  53927. \*************************************************************************************/
  53928. /*! exports provided: render, staticRenderFns */
  53929. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53930. "use strict";
  53931. __webpack_require__.r(__webpack_exports__);
  53932. /* 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&");
  53933. /* 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"]; });
  53934. /* 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"]; });
  53935. /***/ }),
  53936. /***/ "./resources/js/components/assetinfo.vue":
  53937. /*!***********************************************!*\
  53938. !*** ./resources/js/components/assetinfo.vue ***!
  53939. \***********************************************/
  53940. /*! exports provided: default */
  53941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53942. "use strict";
  53943. __webpack_require__.r(__webpack_exports__);
  53944. /* 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&");
  53945. /* 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&");
  53946. /* 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");
  53947. /* normalize component */
  53948. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  53949. _assetinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  53950. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["render"],
  53951. _assetinfo_vue_vue_type_template_id_4fe1d2e3___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  53952. false,
  53953. null,
  53954. null,
  53955. null
  53956. )
  53957. /* hot reload */
  53958. if (false) { var api; }
  53959. component.options.__file = "resources/js/components/assetinfo.vue"
  53960. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  53961. /***/ }),
  53962. /***/ "./resources/js/components/assetinfo.vue?vue&type=script&lang=js&":
  53963. /*!************************************************************************!*\
  53964. !*** ./resources/js/components/assetinfo.vue?vue&type=script&lang=js& ***!
  53965. \************************************************************************/
  53966. /*! exports provided: default */
  53967. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53968. "use strict";
  53969. __webpack_require__.r(__webpack_exports__);
  53970. /* 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&");
  53971. /* 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"]);
  53972. /***/ }),
  53973. /***/ "./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3&":
  53974. /*!******************************************************************************!*\
  53975. !*** ./resources/js/components/assetinfo.vue?vue&type=template&id=4fe1d2e3& ***!
  53976. \******************************************************************************/
  53977. /*! exports provided: render, staticRenderFns */
  53978. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53979. "use strict";
  53980. __webpack_require__.r(__webpack_exports__);
  53981. /* 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&");
  53982. /* 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"]; });
  53983. /* 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"]; });
  53984. /***/ }),
  53985. /***/ "./resources/js/components/credential.vue":
  53986. /*!************************************************!*\
  53987. !*** ./resources/js/components/credential.vue ***!
  53988. \************************************************/
  53989. /*! exports provided: default */
  53990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53991. "use strict";
  53992. __webpack_require__.r(__webpack_exports__);
  53993. /* 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&");
  53994. /* 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&");
  53995. /* 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");
  53996. /* normalize component */
  53997. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  53998. _credential_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  53999. _credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["render"],
  54000. _credential_vue_vue_type_template_id_0f5cc562___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54001. false,
  54002. null,
  54003. null,
  54004. null
  54005. )
  54006. /* hot reload */
  54007. if (false) { var api; }
  54008. component.options.__file = "resources/js/components/credential.vue"
  54009. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54010. /***/ }),
  54011. /***/ "./resources/js/components/credential.vue?vue&type=script&lang=js&":
  54012. /*!*************************************************************************!*\
  54013. !*** ./resources/js/components/credential.vue?vue&type=script&lang=js& ***!
  54014. \*************************************************************************/
  54015. /*! exports provided: default */
  54016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54017. "use strict";
  54018. __webpack_require__.r(__webpack_exports__);
  54019. /* 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&");
  54020. /* 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"]);
  54021. /***/ }),
  54022. /***/ "./resources/js/components/credential.vue?vue&type=template&id=0f5cc562&":
  54023. /*!*******************************************************************************!*\
  54024. !*** ./resources/js/components/credential.vue?vue&type=template&id=0f5cc562& ***!
  54025. \*******************************************************************************/
  54026. /*! exports provided: render, staticRenderFns */
  54027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54028. "use strict";
  54029. __webpack_require__.r(__webpack_exports__);
  54030. /* 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&");
  54031. /* 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"]; });
  54032. /* 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"]; });
  54033. /***/ }),
  54034. /***/ "./resources/js/components/notes.vue":
  54035. /*!*******************************************!*\
  54036. !*** ./resources/js/components/notes.vue ***!
  54037. \*******************************************/
  54038. /*! exports provided: default */
  54039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54040. "use strict";
  54041. __webpack_require__.r(__webpack_exports__);
  54042. /* 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&");
  54043. /* 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&");
  54044. /* 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");
  54045. /* normalize component */
  54046. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54047. _notes_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54048. _notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__["render"],
  54049. _notes_vue_vue_type_template_id_73d141f4___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54050. false,
  54051. null,
  54052. null,
  54053. null
  54054. )
  54055. /* hot reload */
  54056. if (false) { var api; }
  54057. component.options.__file = "resources/js/components/notes.vue"
  54058. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54059. /***/ }),
  54060. /***/ "./resources/js/components/notes.vue?vue&type=script&lang=js&":
  54061. /*!********************************************************************!*\
  54062. !*** ./resources/js/components/notes.vue?vue&type=script&lang=js& ***!
  54063. \********************************************************************/
  54064. /*! exports provided: default */
  54065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54066. "use strict";
  54067. __webpack_require__.r(__webpack_exports__);
  54068. /* 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&");
  54069. /* 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"]);
  54070. /***/ }),
  54071. /***/ "./resources/js/components/notes.vue?vue&type=template&id=73d141f4&":
  54072. /*!**************************************************************************!*\
  54073. !*** ./resources/js/components/notes.vue?vue&type=template&id=73d141f4& ***!
  54074. \**************************************************************************/
  54075. /*! exports provided: render, staticRenderFns */
  54076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54077. "use strict";
  54078. __webpack_require__.r(__webpack_exports__);
  54079. /* 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&");
  54080. /* 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"]; });
  54081. /* 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"]; });
  54082. /***/ }),
  54083. /***/ "./resources/js/components/woinfo.vue":
  54084. /*!********************************************!*\
  54085. !*** ./resources/js/components/woinfo.vue ***!
  54086. \********************************************/
  54087. /*! exports provided: default */
  54088. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54089. "use strict";
  54090. __webpack_require__.r(__webpack_exports__);
  54091. /* 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&");
  54092. /* 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&");
  54093. /* 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");
  54094. /* normalize component */
  54095. var component = Object(_node_modules_vue_loader_lib_runtime_componentNormalizer_js__WEBPACK_IMPORTED_MODULE_2__["default"])(
  54096. _woinfo_vue_vue_type_script_lang_js___WEBPACK_IMPORTED_MODULE_1__["default"],
  54097. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["render"],
  54098. _woinfo_vue_vue_type_template_id_33ce32de___WEBPACK_IMPORTED_MODULE_0__["staticRenderFns"],
  54099. false,
  54100. null,
  54101. null,
  54102. null
  54103. )
  54104. /* hot reload */
  54105. if (false) { var api; }
  54106. component.options.__file = "resources/js/components/woinfo.vue"
  54107. /* harmony default export */ __webpack_exports__["default"] = (component.exports);
  54108. /***/ }),
  54109. /***/ "./resources/js/components/woinfo.vue?vue&type=script&lang=js&":
  54110. /*!*********************************************************************!*\
  54111. !*** ./resources/js/components/woinfo.vue?vue&type=script&lang=js& ***!
  54112. \*********************************************************************/
  54113. /*! exports provided: default */
  54114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54115. "use strict";
  54116. __webpack_require__.r(__webpack_exports__);
  54117. /* 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&");
  54118. /* 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"]);
  54119. /***/ }),
  54120. /***/ "./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de&":
  54121. /*!***************************************************************************!*\
  54122. !*** ./resources/js/components/woinfo.vue?vue&type=template&id=33ce32de& ***!
  54123. \***************************************************************************/
  54124. /*! exports provided: render, staticRenderFns */
  54125. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54126. "use strict";
  54127. __webpack_require__.r(__webpack_exports__);
  54128. /* 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&");
  54129. /* 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"]; });
  54130. /* 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"]; });
  54131. /***/ }),
  54132. /***/ "./resources/js/mixins/dateMixin.js":
  54133. /*!******************************************!*\
  54134. !*** ./resources/js/mixins/dateMixin.js ***!
  54135. \******************************************/
  54136. /*! exports provided: default */
  54137. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54138. "use strict";
  54139. __webpack_require__.r(__webpack_exports__);
  54140. /* harmony default export */ __webpack_exports__["default"] = ({
  54141. methods: {
  54142. treatAsUTC: function treatAsUTC(date) {
  54143. var result = new Date(date);
  54144. result.setMinutes(result.getMinutes() - result.getTimezoneOffset());
  54145. return result;
  54146. },
  54147. daysSinceToday: function daysSinceToday(date) {
  54148. var currentDate = new Date();
  54149. var millisecondsPerDay = 24 * 60 * 60 * 1000;
  54150. return (this.treatAsUTC(currentDate) - this.treatAsUTC(date)) / millisecondsPerDay;
  54151. },
  54152. getHRDate: function getHRDate(dateString) {
  54153. var date = new Date(dateString);
  54154. var year = date.getFullYear();
  54155. var month = date.toLocaleString('default', {
  54156. month: 'short'
  54157. });
  54158. var day = date.getDate();
  54159. var hour = date.getHours() % 12;
  54160. var minute = date.getMinutes();
  54161. var period = date.getHours() < 24 ? 'AM' : 'PM';
  54162. return month + " " + day + ", " + year + " " + hour + ":" + minute + " " + period;
  54163. },
  54164. isZero: function isZero(dateString) {
  54165. return dateString === '0000-00-00 00:00:00';
  54166. }
  54167. }
  54168. });
  54169. /***/ }),
  54170. /***/ "./resources/js/notify.min.js":
  54171. /*!************************************!*\
  54172. !*** ./resources/js/notify.min.js ***!
  54173. \************************************/
  54174. /*! no static exports found */
  54175. /***/ (function(module, exports, __webpack_require__) {
  54176. 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); }
  54177. (function (e) {
  54178. true ? !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! jquery */ "./node_modules/jquery/dist/jquery.js")], __WEBPACK_AMD_DEFINE_FACTORY__ = (e),
  54179. __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
  54180. (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
  54181. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)) : undefined;
  54182. })(function (e) {
  54183. function A(t, n, i) {
  54184. typeof i == "string" && (i = {
  54185. className: i
  54186. }), 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);
  54187. }
  54188. var t = [].indexOf || function (e) {
  54189. for (var t = 0, n = this.length; t < n; t++) {
  54190. if (t in this && this[t] === e) return t;
  54191. }
  54192. return -1;
  54193. },
  54194. n = "notify",
  54195. r = n + "js",
  54196. i = n + "!blank",
  54197. s = {
  54198. t: "top",
  54199. m: "middle",
  54200. b: "bottom",
  54201. l: "left",
  54202. c: "center",
  54203. r: "right"
  54204. },
  54205. o = ["l", "c", "r"],
  54206. u = ["t", "m", "b"],
  54207. a = ["t", "b", "l", "r"],
  54208. f = {
  54209. t: "b",
  54210. m: null,
  54211. b: "t",
  54212. l: "r",
  54213. c: null,
  54214. r: "l"
  54215. },
  54216. l = function l(t) {
  54217. var n;
  54218. return n = [], e.each(t.split(/\W+/), function (e, t) {
  54219. var r;
  54220. r = t.toLowerCase().charAt(0);
  54221. if (s[r]) return n.push(r);
  54222. }), n;
  54223. },
  54224. c = {},
  54225. h = {
  54226. name: "core",
  54227. html: '<div class="' + r + '-wrapper">\n <div class="' + r + '-arrow"></div>\n <div class="' + r + '-container"></div>\n</div>',
  54228. 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}"
  54229. },
  54230. p = {
  54231. "border-radius": ["-webkit-", "-moz-"]
  54232. },
  54233. d = function d(e) {
  54234. return c[e];
  54235. },
  54236. v = function v(e) {
  54237. if (!e) throw "Missing Style name";
  54238. c[e] && delete c[e];
  54239. },
  54240. m = function m(t, i) {
  54241. if (!t) throw "Missing Style name";
  54242. if (!i) throw "Missing Style definition";
  54243. if (!i.html) throw "Missing Style HTML";
  54244. var s = c[t];
  54245. s && s.cssElem && (window.console && console.warn(n + ": overwriting style '" + t + "'"), c[t].cssElem.remove()), i.name = t, c[t] = i;
  54246. var o = "";
  54247. i.classes && e.each(i.classes, function (t, n) {
  54248. return o += "." + r + "-" + i.name + "-" + t + " {\n", e.each(n, function (t, n) {
  54249. return p[t] && e.each(p[t], function (e, r) {
  54250. return o += " " + r + t + ": " + n + ";\n";
  54251. }), o += " " + t + ": " + n + ";\n";
  54252. }), o += "}\n";
  54253. }), i.css && (o += "/* styles for " + i.name + " */\n" + i.css), o && (i.cssElem = g(o), i.cssElem.attr("id", "notify-" + i.name));
  54254. var u = {},
  54255. a = e(i.html);
  54256. y("html", a, u), y("text", a, u), i.fields = u;
  54257. },
  54258. g = function g(t) {
  54259. var n, r, i;
  54260. r = x("style"), r.attr("type", "text/css"), e("head").append(r);
  54261. try {
  54262. r.html(t);
  54263. } catch (s) {
  54264. r[0].styleSheet.cssText = t;
  54265. }
  54266. return r;
  54267. },
  54268. y = function y(t, n, r) {
  54269. var s;
  54270. return t !== "html" && (t = "text"), s = "data-notify-" + t, b(n, "[" + s + "]").each(function () {
  54271. var n;
  54272. n = e(this).attr(s), n || (n = i), r[n] = t;
  54273. });
  54274. },
  54275. b = function b(e, t) {
  54276. return e.is(t) ? e : e.find(t);
  54277. },
  54278. w = {
  54279. clickToHide: !0,
  54280. autoHide: !0,
  54281. autoHideDelay: 5e3,
  54282. arrowShow: !0,
  54283. arrowSize: 5,
  54284. breakNewLines: !0,
  54285. elementPosition: "bottom",
  54286. globalPosition: "top right",
  54287. style: "bootstrap",
  54288. className: "error",
  54289. showAnimation: "slideDown",
  54290. showDuration: 400,
  54291. hideAnimation: "slideUp",
  54292. hideDuration: 200,
  54293. gap: 5
  54294. },
  54295. E = function E(t, n) {
  54296. var r;
  54297. return r = function r() {}, r.prototype = t, e.extend(!0, new r(), n);
  54298. },
  54299. S = function S(t) {
  54300. return e.extend(w, t);
  54301. },
  54302. x = function x(t) {
  54303. return e("<" + t + "></" + t + ">");
  54304. },
  54305. T = {},
  54306. N = function N(t) {
  54307. var n;
  54308. return t.is("[type=radio]") && (n = t.parents("form:first").find("[type=radio]").filter(function (n, r) {
  54309. return e(r).attr("name") === t.attr("name");
  54310. }), t = n.first()), t;
  54311. },
  54312. C = function C(e, t, n) {
  54313. var r, i;
  54314. if (typeof n == "string") n = parseInt(n, 10);else if (typeof n != "number") return;
  54315. if (isNaN(n)) return;
  54316. 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;
  54317. },
  54318. k = function k(e, t, n) {
  54319. if (e === "l" || e === "t") return 0;
  54320. if (e === "c" || e === "m") return n / 2 - t / 2;
  54321. if (e === "r" || e === "b") return n - t;
  54322. throw "Invalid alignment";
  54323. },
  54324. L = function L(e) {
  54325. return L.e = L.e || x("div"), L.e.text(e).html();
  54326. };
  54327. A.prototype.loadHTML = function () {
  54328. var t;
  54329. t = this.getStyle(), this.userContainer = e(t.html), this.userFields = t.fields;
  54330. }, A.prototype.show = function (e, t) {
  54331. var n, r, i, s, o;
  54332. r = function (n) {
  54333. return function () {
  54334. !e && !n.elem && n.destroy();
  54335. if (t) return t();
  54336. };
  54337. }(this), o = this.container.parent().parents(":hidden").length > 0, i = this.container.add(this.arrow), n = [];
  54338. 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 {
  54339. if (!!o || !!e) return r();
  54340. s = this.options.hideAnimation, n.push(this.options.hideDuration);
  54341. }
  54342. return n.push(r), i[s].apply(i, n);
  54343. }, A.prototype.setGlobalPosition = function () {
  54344. var t = this.getPosition(),
  54345. n = t[0],
  54346. i = t[1],
  54347. o = s[n],
  54348. u = s[i],
  54349. a = n + "|" + i,
  54350. f = T[a];
  54351. if (!f || !document.body.contains(f[0])) {
  54352. f = T[a] = x("div");
  54353. var l = {};
  54354. 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);
  54355. }
  54356. return f.prepend(this.wrapper);
  54357. }, A.prototype.setElementPosition = function () {
  54358. 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;
  54359. 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"];
  54360. for (w = 0, S = B.length; w < S; w++) {
  54361. D = B[w], N = parseInt(this.elem.css("margin-" + D), 10), N && C(p, D, N);
  54362. }
  54363. b = Math.max(0, this.options.gap - (this.options.arrowShow ? i : 0)), C(p, A, b);
  54364. if (!this.options.arrowShow) this.arrow.hide();else {
  54365. 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";
  54366. for (E = 0, x = a.length; E < x; E++) {
  54367. D = a[E], P = s[D];
  54368. if (D === L) continue;
  54369. l = P === T ? n : "transparent", r["border-" + P] = i + "px solid " + l;
  54370. }
  54371. C(p, s[L], i), t.call(a, O) >= 0 && C(r, s[O], i * 2);
  54372. }
  54373. 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);
  54374. if (r) return this.arrow.removeAttr("style").css(r);
  54375. }, A.prototype.getPosition = function () {
  54376. var e, n, r, i, s, f, c, h;
  54377. h = this.options.position || (this.elem ? this.options.elementPosition : this.options.globalPosition), e = l(h), e.length === 0 && (e[0] = "b");
  54378. if (n = e[0], t.call(a, n) < 0) throw "Must be one of [" + a + "]";
  54379. 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";
  54380. return e.length === 2 && (e[2] = e[1]), e;
  54381. }, A.prototype.getStyle = function (e) {
  54382. var t;
  54383. e || (e = this.options.style), e || (e = "default"), t = c[e];
  54384. if (!t) throw "Missing style: " + e;
  54385. return t;
  54386. }, A.prototype.updateClasses = function () {
  54387. var t, n;
  54388. 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) {
  54389. return r + "-" + n.name + "-" + e;
  54390. }).join(" "), this.userContainer.attr("class", t);
  54391. }, A.prototype.run = function (t, n) {
  54392. var r, s, o, u, a;
  54393. e.isPlainObject(n) ? e.extend(this.options, n) : e.type(n) === "string" && (this.options.className = n);
  54394. if (this.container && !t) {
  54395. this.show(!1);
  54396. return;
  54397. }
  54398. if (!this.container && !t) return;
  54399. s = {}, e.isPlainObject(t) ? s = t : s[i] = t;
  54400. for (o in s) {
  54401. r = s[o], u = this.userFields[o];
  54402. if (!u) continue;
  54403. 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);
  54404. }
  54405. 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));
  54406. }, A.prototype.destroy = function () {
  54407. this.wrapper.data(r, null), this.wrapper.remove();
  54408. }, e[n] = function (t, r, i) {
  54409. return t && t.nodeName || t.jquery ? e(t)[n](r, i) : (i = r, r = t, new A(null, r, i)), t;
  54410. }, e.fn[n] = function (t, n) {
  54411. return e(this).each(function () {
  54412. var i = N(e(this)).data(r);
  54413. i && i.destroy();
  54414. var s = new A(e(this), t, n);
  54415. }), this;
  54416. }, e.extend(e[n], {
  54417. defaults: S,
  54418. addStyle: m,
  54419. removeStyle: v,
  54420. pluginOptions: w,
  54421. getStyle: d,
  54422. insertCSS: g
  54423. }), m("bootstrap", {
  54424. html: "<div>\n<span data-notify-text></span>\n</div>",
  54425. classes: {
  54426. base: {
  54427. "font-weight": "bold",
  54428. padding: "8px 15px 8px 14px",
  54429. "text-shadow": "0 1px 0 rgba(255, 255, 255, 0.5)",
  54430. "background-color": "#fcf8e3",
  54431. border: "1px solid #fbeed5",
  54432. "border-radius": "4px",
  54433. "white-space": "nowrap",
  54434. "padding-left": "25px",
  54435. "background-repeat": "no-repeat",
  54436. "background-position": "3px 7px"
  54437. },
  54438. error: {
  54439. color: "#B94A48",
  54440. "background-color": "#F2DEDE",
  54441. "border-color": "#EED3D7",
  54442. "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=)"
  54443. },
  54444. success: {
  54445. color: "#468847",
  54446. "background-color": "#DFF0D8",
  54447. "border-color": "#D6E9C6",
  54448. "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==)"
  54449. },
  54450. info: {
  54451. color: "#3A87AD",
  54452. "background-color": "#D9EDF7",
  54453. "border-color": "#BCE8F1",
  54454. "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=)"
  54455. },
  54456. warn: {
  54457. color: "#C09853",
  54458. "background-color": "#FCF8E3",
  54459. "border-color": "#FBEED5",
  54460. "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)"
  54461. }
  54462. }
  54463. }), e(function () {
  54464. g(h.css).attr("id", "core-notify"), e(document).on("click", "." + r + "-hidable", function (t) {
  54465. e(this).trigger("notify-hide");
  54466. }), e(document).on("notify-hide", "." + r + "-wrapper", function (t) {
  54467. var n = e(this).data(r);
  54468. n && n.show(!1);
  54469. });
  54470. });
  54471. });
  54472. /***/ }),
  54473. /***/ "./resources/sass/app.scss":
  54474. /*!*********************************!*\
  54475. !*** ./resources/sass/app.scss ***!
  54476. \*********************************/
  54477. /*! no static exports found */
  54478. /***/ (function(module, exports) {
  54479. // removed by extract-text-webpack-plugin
  54480. /***/ }),
  54481. /***/ 0:
  54482. /*!*************************************************************!*\
  54483. !*** multi ./resources/js/app.js ./resources/sass/app.scss ***!
  54484. \*************************************************************/
  54485. /*! no static exports found */
  54486. /***/ (function(module, exports, __webpack_require__) {
  54487. __webpack_require__(/*! /home/vagrant/upccrt/resources/js/app.js */"./resources/js/app.js");
  54488. module.exports = __webpack_require__(/*! /home/vagrant/upccrt/resources/sass/app.scss */"./resources/sass/app.scss");
  54489. /***/ })
  54490. /******/ });