Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')) :
  3. typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'], factory) :
  4. (global = global || self, factory(global.ReactBigCalendar = {}, global.React, global.ReactDOM));
  5. }(this, function (exports, React, ReactDOM) { 'use strict';
  6. var React__default = 'default' in React ? React['default'] : React;
  7. var ReactDOM__default = 'default' in ReactDOM ? ReactDOM['default'] : ReactDOM;
  8. function NoopWrapper(props) {
  9. return props.children;
  10. }
  11. function _extends() {
  12. _extends = Object.assign || function (target) {
  13. for (var i = 1; i < arguments.length; i++) {
  14. var source = arguments[i];
  15. for (var key in source) {
  16. if (Object.prototype.hasOwnProperty.call(source, key)) {
  17. target[key] = source[key];
  18. }
  19. }
  20. }
  21. return target;
  22. };
  23. return _extends.apply(this, arguments);
  24. }
  25. function _objectWithoutPropertiesLoose(source, excluded) {
  26. if (source == null) return {};
  27. var target = {};
  28. var sourceKeys = Object.keys(source);
  29. var key, i;
  30. for (i = 0; i < sourceKeys.length; i++) {
  31. key = sourceKeys[i];
  32. if (excluded.indexOf(key) >= 0) continue;
  33. target[key] = source[key];
  34. }
  35. return target;
  36. }
  37. function _inheritsLoose(subClass, superClass) {
  38. subClass.prototype = Object.create(superClass.prototype);
  39. subClass.prototype.constructor = subClass;
  40. subClass.__proto__ = superClass;
  41. }
  42. function unwrapExports (x) {
  43. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
  44. }
  45. function createCommonjsModule(fn, module) {
  46. return module = { exports: {} }, fn(module, module.exports), module.exports;
  47. }
  48. var reactIs_production_min = createCommonjsModule(function (module, exports) {
  49. Object.defineProperty(exports,"__esModule",{value:!0});
  50. var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?Symbol.for("react.memo"):
  51. 60115,r=b?Symbol.for("react.lazy"):60116;function t(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return u}}case r:case q:case d:return u}}}function v(a){return t(a)===m}exports.typeOf=t;exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;
  52. exports.Fragment=e;exports.Lazy=r;exports.Memo=q;exports.Portal=d;exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||"object"===typeof a&&null!==a&&(a.$$typeof===r||a.$$typeof===q||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n)};exports.isAsyncMode=function(a){return v(a)||t(a)===l};exports.isConcurrentMode=v;exports.isContextConsumer=function(a){return t(a)===k};
  53. exports.isContextProvider=function(a){return t(a)===h};exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return t(a)===n};exports.isFragment=function(a){return t(a)===e};exports.isLazy=function(a){return t(a)===r};exports.isMemo=function(a){return t(a)===q};exports.isPortal=function(a){return t(a)===d};exports.isProfiler=function(a){return t(a)===g};exports.isStrictMode=function(a){return t(a)===f};
  54. exports.isSuspense=function(a){return t(a)===p};
  55. });
  56. unwrapExports(reactIs_production_min);
  57. var reactIs_production_min_1 = reactIs_production_min.typeOf;
  58. var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
  59. var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
  60. var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
  61. var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
  62. var reactIs_production_min_6 = reactIs_production_min.Element;
  63. var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
  64. var reactIs_production_min_8 = reactIs_production_min.Fragment;
  65. var reactIs_production_min_9 = reactIs_production_min.Lazy;
  66. var reactIs_production_min_10 = reactIs_production_min.Memo;
  67. var reactIs_production_min_11 = reactIs_production_min.Portal;
  68. var reactIs_production_min_12 = reactIs_production_min.Profiler;
  69. var reactIs_production_min_13 = reactIs_production_min.StrictMode;
  70. var reactIs_production_min_14 = reactIs_production_min.Suspense;
  71. var reactIs_production_min_15 = reactIs_production_min.isValidElementType;
  72. var reactIs_production_min_16 = reactIs_production_min.isAsyncMode;
  73. var reactIs_production_min_17 = reactIs_production_min.isConcurrentMode;
  74. var reactIs_production_min_18 = reactIs_production_min.isContextConsumer;
  75. var reactIs_production_min_19 = reactIs_production_min.isContextProvider;
  76. var reactIs_production_min_20 = reactIs_production_min.isElement;
  77. var reactIs_production_min_21 = reactIs_production_min.isForwardRef;
  78. var reactIs_production_min_22 = reactIs_production_min.isFragment;
  79. var reactIs_production_min_23 = reactIs_production_min.isLazy;
  80. var reactIs_production_min_24 = reactIs_production_min.isMemo;
  81. var reactIs_production_min_25 = reactIs_production_min.isPortal;
  82. var reactIs_production_min_26 = reactIs_production_min.isProfiler;
  83. var reactIs_production_min_27 = reactIs_production_min.isStrictMode;
  84. var reactIs_production_min_28 = reactIs_production_min.isSuspense;
  85. var reactIs_development = createCommonjsModule(function (module, exports) {
  86. {
  87. (function() {
  88. Object.defineProperty(exports, '__esModule', { value: true });
  89. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  90. // nor polyfill, then a plain number is used for performance.
  91. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  92. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  93. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  94. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  95. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  96. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  97. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  98. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
  99. var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
  100. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  101. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  102. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  103. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  104. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  105. function isValidElementType(type) {
  106. return typeof type === 'string' || typeof type === 'function' ||
  107. // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
  108. type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
  109. }
  110. /**
  111. * Forked from fbjs/warning:
  112. * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
  113. *
  114. * Only change is we use console.warn instead of console.error,
  115. * and do nothing when 'console' is not supported.
  116. * This really simplifies the code.
  117. * ---
  118. * Similar to invariant but only logs a warning if the condition is not met.
  119. * This can be used to log issues in development environments in critical
  120. * paths. Removing the logging code for production environments will keep the
  121. * same logic and follow the same code paths.
  122. */
  123. var lowPriorityWarning = function () {};
  124. {
  125. var printWarning = function (format) {
  126. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  127. args[_key - 1] = arguments[_key];
  128. }
  129. var argIndex = 0;
  130. var message = 'Warning: ' + format.replace(/%s/g, function () {
  131. return args[argIndex++];
  132. });
  133. if (typeof console !== 'undefined') {
  134. console.warn(message);
  135. }
  136. try {
  137. // --- Welcome to debugging React ---
  138. // This error was thrown as a convenience so that you can use this stack
  139. // to find the callsite that caused this warning to fire.
  140. throw new Error(message);
  141. } catch (x) {}
  142. };
  143. lowPriorityWarning = function (condition, format) {
  144. if (format === undefined) {
  145. throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
  146. }
  147. if (!condition) {
  148. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  149. args[_key2 - 2] = arguments[_key2];
  150. }
  151. printWarning.apply(undefined, [format].concat(args));
  152. }
  153. };
  154. }
  155. var lowPriorityWarning$1 = lowPriorityWarning;
  156. function typeOf(object) {
  157. if (typeof object === 'object' && object !== null) {
  158. var $$typeof = object.$$typeof;
  159. switch ($$typeof) {
  160. case REACT_ELEMENT_TYPE:
  161. var type = object.type;
  162. switch (type) {
  163. case REACT_ASYNC_MODE_TYPE:
  164. case REACT_CONCURRENT_MODE_TYPE:
  165. case REACT_FRAGMENT_TYPE:
  166. case REACT_PROFILER_TYPE:
  167. case REACT_STRICT_MODE_TYPE:
  168. case REACT_SUSPENSE_TYPE:
  169. return type;
  170. default:
  171. var $$typeofType = type && type.$$typeof;
  172. switch ($$typeofType) {
  173. case REACT_CONTEXT_TYPE:
  174. case REACT_FORWARD_REF_TYPE:
  175. case REACT_PROVIDER_TYPE:
  176. return $$typeofType;
  177. default:
  178. return $$typeof;
  179. }
  180. }
  181. case REACT_LAZY_TYPE:
  182. case REACT_MEMO_TYPE:
  183. case REACT_PORTAL_TYPE:
  184. return $$typeof;
  185. }
  186. }
  187. return undefined;
  188. }
  189. // AsyncMode is deprecated along with isAsyncMode
  190. var AsyncMode = REACT_ASYNC_MODE_TYPE;
  191. var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
  192. var ContextConsumer = REACT_CONTEXT_TYPE;
  193. var ContextProvider = REACT_PROVIDER_TYPE;
  194. var Element = REACT_ELEMENT_TYPE;
  195. var ForwardRef = REACT_FORWARD_REF_TYPE;
  196. var Fragment = REACT_FRAGMENT_TYPE;
  197. var Lazy = REACT_LAZY_TYPE;
  198. var Memo = REACT_MEMO_TYPE;
  199. var Portal = REACT_PORTAL_TYPE;
  200. var Profiler = REACT_PROFILER_TYPE;
  201. var StrictMode = REACT_STRICT_MODE_TYPE;
  202. var Suspense = REACT_SUSPENSE_TYPE;
  203. var hasWarnedAboutDeprecatedIsAsyncMode = false;
  204. // AsyncMode should be deprecated
  205. function isAsyncMode(object) {
  206. {
  207. if (!hasWarnedAboutDeprecatedIsAsyncMode) {
  208. hasWarnedAboutDeprecatedIsAsyncMode = true;
  209. lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
  210. }
  211. }
  212. return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
  213. }
  214. function isConcurrentMode(object) {
  215. return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
  216. }
  217. function isContextConsumer(object) {
  218. return typeOf(object) === REACT_CONTEXT_TYPE;
  219. }
  220. function isContextProvider(object) {
  221. return typeOf(object) === REACT_PROVIDER_TYPE;
  222. }
  223. function isElement(object) {
  224. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  225. }
  226. function isForwardRef(object) {
  227. return typeOf(object) === REACT_FORWARD_REF_TYPE;
  228. }
  229. function isFragment(object) {
  230. return typeOf(object) === REACT_FRAGMENT_TYPE;
  231. }
  232. function isLazy(object) {
  233. return typeOf(object) === REACT_LAZY_TYPE;
  234. }
  235. function isMemo(object) {
  236. return typeOf(object) === REACT_MEMO_TYPE;
  237. }
  238. function isPortal(object) {
  239. return typeOf(object) === REACT_PORTAL_TYPE;
  240. }
  241. function isProfiler(object) {
  242. return typeOf(object) === REACT_PROFILER_TYPE;
  243. }
  244. function isStrictMode(object) {
  245. return typeOf(object) === REACT_STRICT_MODE_TYPE;
  246. }
  247. function isSuspense(object) {
  248. return typeOf(object) === REACT_SUSPENSE_TYPE;
  249. }
  250. exports.typeOf = typeOf;
  251. exports.AsyncMode = AsyncMode;
  252. exports.ConcurrentMode = ConcurrentMode;
  253. exports.ContextConsumer = ContextConsumer;
  254. exports.ContextProvider = ContextProvider;
  255. exports.Element = Element;
  256. exports.ForwardRef = ForwardRef;
  257. exports.Fragment = Fragment;
  258. exports.Lazy = Lazy;
  259. exports.Memo = Memo;
  260. exports.Portal = Portal;
  261. exports.Profiler = Profiler;
  262. exports.StrictMode = StrictMode;
  263. exports.Suspense = Suspense;
  264. exports.isValidElementType = isValidElementType;
  265. exports.isAsyncMode = isAsyncMode;
  266. exports.isConcurrentMode = isConcurrentMode;
  267. exports.isContextConsumer = isContextConsumer;
  268. exports.isContextProvider = isContextProvider;
  269. exports.isElement = isElement;
  270. exports.isForwardRef = isForwardRef;
  271. exports.isFragment = isFragment;
  272. exports.isLazy = isLazy;
  273. exports.isMemo = isMemo;
  274. exports.isPortal = isPortal;
  275. exports.isProfiler = isProfiler;
  276. exports.isStrictMode = isStrictMode;
  277. exports.isSuspense = isSuspense;
  278. })();
  279. }
  280. });
  281. unwrapExports(reactIs_development);
  282. var reactIs_development_1 = reactIs_development.typeOf;
  283. var reactIs_development_2 = reactIs_development.AsyncMode;
  284. var reactIs_development_3 = reactIs_development.ConcurrentMode;
  285. var reactIs_development_4 = reactIs_development.ContextConsumer;
  286. var reactIs_development_5 = reactIs_development.ContextProvider;
  287. var reactIs_development_6 = reactIs_development.Element;
  288. var reactIs_development_7 = reactIs_development.ForwardRef;
  289. var reactIs_development_8 = reactIs_development.Fragment;
  290. var reactIs_development_9 = reactIs_development.Lazy;
  291. var reactIs_development_10 = reactIs_development.Memo;
  292. var reactIs_development_11 = reactIs_development.Portal;
  293. var reactIs_development_12 = reactIs_development.Profiler;
  294. var reactIs_development_13 = reactIs_development.StrictMode;
  295. var reactIs_development_14 = reactIs_development.Suspense;
  296. var reactIs_development_15 = reactIs_development.isValidElementType;
  297. var reactIs_development_16 = reactIs_development.isAsyncMode;
  298. var reactIs_development_17 = reactIs_development.isConcurrentMode;
  299. var reactIs_development_18 = reactIs_development.isContextConsumer;
  300. var reactIs_development_19 = reactIs_development.isContextProvider;
  301. var reactIs_development_20 = reactIs_development.isElement;
  302. var reactIs_development_21 = reactIs_development.isForwardRef;
  303. var reactIs_development_22 = reactIs_development.isFragment;
  304. var reactIs_development_23 = reactIs_development.isLazy;
  305. var reactIs_development_24 = reactIs_development.isMemo;
  306. var reactIs_development_25 = reactIs_development.isPortal;
  307. var reactIs_development_26 = reactIs_development.isProfiler;
  308. var reactIs_development_27 = reactIs_development.isStrictMode;
  309. var reactIs_development_28 = reactIs_development.isSuspense;
  310. var reactIs = createCommonjsModule(function (module) {
  311. {
  312. module.exports = reactIs_development;
  313. }
  314. });
  315. /*
  316. object-assign
  317. (c) Sindre Sorhus
  318. @license MIT
  319. */
  320. /* eslint-disable no-unused-vars */
  321. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  322. var hasOwnProperty = Object.prototype.hasOwnProperty;
  323. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  324. function toObject(val) {
  325. if (val === null || val === undefined) {
  326. throw new TypeError('Object.assign cannot be called with null or undefined');
  327. }
  328. return Object(val);
  329. }
  330. function shouldUseNative() {
  331. try {
  332. if (!Object.assign) {
  333. return false;
  334. }
  335. // Detect buggy property enumeration order in older V8 versions.
  336. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  337. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  338. test1[5] = 'de';
  339. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  340. return false;
  341. }
  342. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  343. var test2 = {};
  344. for (var i = 0; i < 10; i++) {
  345. test2['_' + String.fromCharCode(i)] = i;
  346. }
  347. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  348. return test2[n];
  349. });
  350. if (order2.join('') !== '0123456789') {
  351. return false;
  352. }
  353. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  354. var test3 = {};
  355. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  356. test3[letter] = letter;
  357. });
  358. if (Object.keys(Object.assign({}, test3)).join('') !==
  359. 'abcdefghijklmnopqrst') {
  360. return false;
  361. }
  362. return true;
  363. } catch (err) {
  364. // We don't expect any of the above to throw, but better to be safe.
  365. return false;
  366. }
  367. }
  368. var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
  369. var from;
  370. var to = toObject(target);
  371. var symbols;
  372. for (var s = 1; s < arguments.length; s++) {
  373. from = Object(arguments[s]);
  374. for (var key in from) {
  375. if (hasOwnProperty.call(from, key)) {
  376. to[key] = from[key];
  377. }
  378. }
  379. if (getOwnPropertySymbols) {
  380. symbols = getOwnPropertySymbols(from);
  381. for (var i = 0; i < symbols.length; i++) {
  382. if (propIsEnumerable.call(from, symbols[i])) {
  383. to[symbols[i]] = from[symbols[i]];
  384. }
  385. }
  386. }
  387. }
  388. return to;
  389. };
  390. /**
  391. * Copyright (c) 2013-present, Facebook, Inc.
  392. *
  393. * This source code is licensed under the MIT license found in the
  394. * LICENSE file in the root directory of this source tree.
  395. */
  396. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  397. var ReactPropTypesSecret_1 = ReactPropTypesSecret;
  398. var printWarning = function() {};
  399. {
  400. var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
  401. var loggedTypeFailures = {};
  402. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  403. printWarning = function(text) {
  404. var message = 'Warning: ' + text;
  405. if (typeof console !== 'undefined') {
  406. console.error(message);
  407. }
  408. try {
  409. // --- Welcome to debugging React ---
  410. // This error was thrown as a convenience so that you can use this stack
  411. // to find the callsite that caused this warning to fire.
  412. throw new Error(message);
  413. } catch (x) {}
  414. };
  415. }
  416. /**
  417. * Assert that the values match with the type specs.
  418. * Error messages are memorized and will only be shown once.
  419. *
  420. * @param {object} typeSpecs Map of name to a ReactPropType
  421. * @param {object} values Runtime values that need to be type-checked
  422. * @param {string} location e.g. "prop", "context", "child context"
  423. * @param {string} componentName Name of the component for error messages.
  424. * @param {?Function} getStack Returns the component stack.
  425. * @private
  426. */
  427. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  428. {
  429. for (var typeSpecName in typeSpecs) {
  430. if (has(typeSpecs, typeSpecName)) {
  431. var error;
  432. // Prop type validation may throw. In case they do, we don't want to
  433. // fail the render phase where it didn't fail before. So we log it.
  434. // After these have been cleaned up, we'll let them throw.
  435. try {
  436. // This is intentionally an invariant that gets caught. It's the same
  437. // behavior as without this statement except with a better message.
  438. if (typeof typeSpecs[typeSpecName] !== 'function') {
  439. var err = Error(
  440. (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
  441. 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
  442. );
  443. err.name = 'Invariant Violation';
  444. throw err;
  445. }
  446. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
  447. } catch (ex) {
  448. error = ex;
  449. }
  450. if (error && !(error instanceof Error)) {
  451. printWarning(
  452. (componentName || 'React class') + ': type specification of ' +
  453. location + ' `' + typeSpecName + '` is invalid; the type checker ' +
  454. 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
  455. 'You may have forgotten to pass an argument to the type checker ' +
  456. 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
  457. 'shape all require an argument).'
  458. );
  459. }
  460. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  461. // Only monitor this failure once because there tends to be a lot of the
  462. // same error.
  463. loggedTypeFailures[error.message] = true;
  464. var stack = getStack ? getStack() : '';
  465. printWarning(
  466. 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
  467. );
  468. }
  469. }
  470. }
  471. }
  472. }
  473. /**
  474. * Resets warning cache when testing.
  475. *
  476. * @private
  477. */
  478. checkPropTypes.resetWarningCache = function() {
  479. {
  480. loggedTypeFailures = {};
  481. }
  482. };
  483. var checkPropTypes_1 = checkPropTypes;
  484. var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
  485. var printWarning$1 = function() {};
  486. {
  487. printWarning$1 = function(text) {
  488. var message = 'Warning: ' + text;
  489. if (typeof console !== 'undefined') {
  490. console.error(message);
  491. }
  492. try {
  493. // --- Welcome to debugging React ---
  494. // This error was thrown as a convenience so that you can use this stack
  495. // to find the callsite that caused this warning to fire.
  496. throw new Error(message);
  497. } catch (x) {}
  498. };
  499. }
  500. function emptyFunctionThatReturnsNull() {
  501. return null;
  502. }
  503. var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
  504. /* global Symbol */
  505. var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  506. var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
  507. /**
  508. * Returns the iterator method function contained on the iterable object.
  509. *
  510. * Be sure to invoke the function with the iterable as context:
  511. *
  512. * var iteratorFn = getIteratorFn(myIterable);
  513. * if (iteratorFn) {
  514. * var iterator = iteratorFn.call(myIterable);
  515. * ...
  516. * }
  517. *
  518. * @param {?object} maybeIterable
  519. * @return {?function}
  520. */
  521. function getIteratorFn(maybeIterable) {
  522. var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
  523. if (typeof iteratorFn === 'function') {
  524. return iteratorFn;
  525. }
  526. }
  527. /**
  528. * Collection of methods that allow declaration and validation of props that are
  529. * supplied to React components. Example usage:
  530. *
  531. * var Props = require('ReactPropTypes');
  532. * var MyArticle = React.createClass({
  533. * propTypes: {
  534. * // An optional string prop named "description".
  535. * description: Props.string,
  536. *
  537. * // A required enum prop named "category".
  538. * category: Props.oneOf(['News','Photos']).isRequired,
  539. *
  540. * // A prop named "dialog" that requires an instance of Dialog.
  541. * dialog: Props.instanceOf(Dialog).isRequired
  542. * },
  543. * render: function() { ... }
  544. * });
  545. *
  546. * A more formal specification of how these methods are used:
  547. *
  548. * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
  549. * decl := ReactPropTypes.{type}(.isRequired)?
  550. *
  551. * Each and every declaration produces a function with the same signature. This
  552. * allows the creation of custom validation functions. For example:
  553. *
  554. * var MyLink = React.createClass({
  555. * propTypes: {
  556. * // An optional string or URI prop named "href".
  557. * href: function(props, propName, componentName) {
  558. * var propValue = props[propName];
  559. * if (propValue != null && typeof propValue !== 'string' &&
  560. * !(propValue instanceof URI)) {
  561. * return new Error(
  562. * 'Expected a string or an URI for ' + propName + ' in ' +
  563. * componentName
  564. * );
  565. * }
  566. * }
  567. * },
  568. * render: function() {...}
  569. * });
  570. *
  571. * @internal
  572. */
  573. var ANONYMOUS = '<<anonymous>>';
  574. // Important!
  575. // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
  576. var ReactPropTypes = {
  577. array: createPrimitiveTypeChecker('array'),
  578. bool: createPrimitiveTypeChecker('boolean'),
  579. func: createPrimitiveTypeChecker('function'),
  580. number: createPrimitiveTypeChecker('number'),
  581. object: createPrimitiveTypeChecker('object'),
  582. string: createPrimitiveTypeChecker('string'),
  583. symbol: createPrimitiveTypeChecker('symbol'),
  584. any: createAnyTypeChecker(),
  585. arrayOf: createArrayOfTypeChecker,
  586. element: createElementTypeChecker(),
  587. elementType: createElementTypeTypeChecker(),
  588. instanceOf: createInstanceTypeChecker,
  589. node: createNodeChecker(),
  590. objectOf: createObjectOfTypeChecker,
  591. oneOf: createEnumTypeChecker,
  592. oneOfType: createUnionTypeChecker,
  593. shape: createShapeTypeChecker,
  594. exact: createStrictShapeTypeChecker,
  595. };
  596. /**
  597. * inlined Object.is polyfill to avoid requiring consumers ship their own
  598. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  599. */
  600. /*eslint-disable no-self-compare*/
  601. function is(x, y) {
  602. // SameValue algorithm
  603. if (x === y) {
  604. // Steps 1-5, 7-10
  605. // Steps 6.b-6.e: +0 != -0
  606. return x !== 0 || 1 / x === 1 / y;
  607. } else {
  608. // Step 6.a: NaN == NaN
  609. return x !== x && y !== y;
  610. }
  611. }
  612. /*eslint-enable no-self-compare*/
  613. /**
  614. * We use an Error-like object for backward compatibility as people may call
  615. * PropTypes directly and inspect their output. However, we don't use real
  616. * Errors anymore. We don't inspect their stack anyway, and creating them
  617. * is prohibitively expensive if they are created too often, such as what
  618. * happens in oneOfType() for any type before the one that matched.
  619. */
  620. function PropTypeError(message) {
  621. this.message = message;
  622. this.stack = '';
  623. }
  624. // Make `instanceof Error` still work for returned errors.
  625. PropTypeError.prototype = Error.prototype;
  626. function createChainableTypeChecker(validate) {
  627. {
  628. var manualPropTypeCallCache = {};
  629. var manualPropTypeWarningCount = 0;
  630. }
  631. function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
  632. componentName = componentName || ANONYMOUS;
  633. propFullName = propFullName || propName;
  634. if (secret !== ReactPropTypesSecret_1) {
  635. if (throwOnDirectAccess) {
  636. // New behavior only for users of `prop-types` package
  637. var err = new Error(
  638. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  639. 'Use `PropTypes.checkPropTypes()` to call them. ' +
  640. 'Read more at http://fb.me/use-check-prop-types'
  641. );
  642. err.name = 'Invariant Violation';
  643. throw err;
  644. } else if (typeof console !== 'undefined') {
  645. // Old behavior for people using React.PropTypes
  646. var cacheKey = componentName + ':' + propName;
  647. if (
  648. !manualPropTypeCallCache[cacheKey] &&
  649. // Avoid spamming the console because they are often not actionable except for lib authors
  650. manualPropTypeWarningCount < 3
  651. ) {
  652. printWarning$1(
  653. 'You are manually calling a React.PropTypes validation ' +
  654. 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
  655. 'and will throw in the standalone `prop-types` package. ' +
  656. 'You may be seeing this warning due to a third-party PropTypes ' +
  657. 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
  658. );
  659. manualPropTypeCallCache[cacheKey] = true;
  660. manualPropTypeWarningCount++;
  661. }
  662. }
  663. }
  664. if (props[propName] == null) {
  665. if (isRequired) {
  666. if (props[propName] === null) {
  667. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
  668. }
  669. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
  670. }
  671. return null;
  672. } else {
  673. return validate(props, propName, componentName, location, propFullName);
  674. }
  675. }
  676. var chainedCheckType = checkType.bind(null, false);
  677. chainedCheckType.isRequired = checkType.bind(null, true);
  678. return chainedCheckType;
  679. }
  680. function createPrimitiveTypeChecker(expectedType) {
  681. function validate(props, propName, componentName, location, propFullName, secret) {
  682. var propValue = props[propName];
  683. var propType = getPropType(propValue);
  684. if (propType !== expectedType) {
  685. // `propValue` being instance of, say, date/regexp, pass the 'object'
  686. // check, but we can offer a more precise error message here rather than
  687. // 'of type `object`'.
  688. var preciseType = getPreciseType(propValue);
  689. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
  690. }
  691. return null;
  692. }
  693. return createChainableTypeChecker(validate);
  694. }
  695. function createAnyTypeChecker() {
  696. return createChainableTypeChecker(emptyFunctionThatReturnsNull);
  697. }
  698. function createArrayOfTypeChecker(typeChecker) {
  699. function validate(props, propName, componentName, location, propFullName) {
  700. if (typeof typeChecker !== 'function') {
  701. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
  702. }
  703. var propValue = props[propName];
  704. if (!Array.isArray(propValue)) {
  705. var propType = getPropType(propValue);
  706. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
  707. }
  708. for (var i = 0; i < propValue.length; i++) {
  709. var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
  710. if (error instanceof Error) {
  711. return error;
  712. }
  713. }
  714. return null;
  715. }
  716. return createChainableTypeChecker(validate);
  717. }
  718. function createElementTypeChecker() {
  719. function validate(props, propName, componentName, location, propFullName) {
  720. var propValue = props[propName];
  721. if (!isValidElement(propValue)) {
  722. var propType = getPropType(propValue);
  723. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
  724. }
  725. return null;
  726. }
  727. return createChainableTypeChecker(validate);
  728. }
  729. function createElementTypeTypeChecker() {
  730. function validate(props, propName, componentName, location, propFullName) {
  731. var propValue = props[propName];
  732. if (!reactIs.isValidElementType(propValue)) {
  733. var propType = getPropType(propValue);
  734. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
  735. }
  736. return null;
  737. }
  738. return createChainableTypeChecker(validate);
  739. }
  740. function createInstanceTypeChecker(expectedClass) {
  741. function validate(props, propName, componentName, location, propFullName) {
  742. if (!(props[propName] instanceof expectedClass)) {
  743. var expectedClassName = expectedClass.name || ANONYMOUS;
  744. var actualClassName = getClassName(props[propName]);
  745. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
  746. }
  747. return null;
  748. }
  749. return createChainableTypeChecker(validate);
  750. }
  751. function createEnumTypeChecker(expectedValues) {
  752. if (!Array.isArray(expectedValues)) {
  753. {
  754. if (arguments.length > 1) {
  755. printWarning$1(
  756. 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
  757. 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
  758. );
  759. } else {
  760. printWarning$1('Invalid argument supplied to oneOf, expected an array.');
  761. }
  762. }
  763. return emptyFunctionThatReturnsNull;
  764. }
  765. function validate(props, propName, componentName, location, propFullName) {
  766. var propValue = props[propName];
  767. for (var i = 0; i < expectedValues.length; i++) {
  768. if (is(propValue, expectedValues[i])) {
  769. return null;
  770. }
  771. }
  772. var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
  773. var type = getPreciseType(value);
  774. if (type === 'symbol') {
  775. return String(value);
  776. }
  777. return value;
  778. });
  779. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
  780. }
  781. return createChainableTypeChecker(validate);
  782. }
  783. function createObjectOfTypeChecker(typeChecker) {
  784. function validate(props, propName, componentName, location, propFullName) {
  785. if (typeof typeChecker !== 'function') {
  786. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
  787. }
  788. var propValue = props[propName];
  789. var propType = getPropType(propValue);
  790. if (propType !== 'object') {
  791. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
  792. }
  793. for (var key in propValue) {
  794. if (has$1(propValue, key)) {
  795. var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  796. if (error instanceof Error) {
  797. return error;
  798. }
  799. }
  800. }
  801. return null;
  802. }
  803. return createChainableTypeChecker(validate);
  804. }
  805. function createUnionTypeChecker(arrayOfTypeCheckers) {
  806. if (!Array.isArray(arrayOfTypeCheckers)) {
  807. printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.');
  808. return emptyFunctionThatReturnsNull;
  809. }
  810. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  811. var checker = arrayOfTypeCheckers[i];
  812. if (typeof checker !== 'function') {
  813. printWarning$1(
  814. 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
  815. 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
  816. );
  817. return emptyFunctionThatReturnsNull;
  818. }
  819. }
  820. function validate(props, propName, componentName, location, propFullName) {
  821. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  822. var checker = arrayOfTypeCheckers[i];
  823. if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
  824. return null;
  825. }
  826. }
  827. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
  828. }
  829. return createChainableTypeChecker(validate);
  830. }
  831. function createNodeChecker() {
  832. function validate(props, propName, componentName, location, propFullName) {
  833. if (!isNode(props[propName])) {
  834. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
  835. }
  836. return null;
  837. }
  838. return createChainableTypeChecker(validate);
  839. }
  840. function createShapeTypeChecker(shapeTypes) {
  841. function validate(props, propName, componentName, location, propFullName) {
  842. var propValue = props[propName];
  843. var propType = getPropType(propValue);
  844. if (propType !== 'object') {
  845. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  846. }
  847. for (var key in shapeTypes) {
  848. var checker = shapeTypes[key];
  849. if (!checker) {
  850. continue;
  851. }
  852. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  853. if (error) {
  854. return error;
  855. }
  856. }
  857. return null;
  858. }
  859. return createChainableTypeChecker(validate);
  860. }
  861. function createStrictShapeTypeChecker(shapeTypes) {
  862. function validate(props, propName, componentName, location, propFullName) {
  863. var propValue = props[propName];
  864. var propType = getPropType(propValue);
  865. if (propType !== 'object') {
  866. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  867. }
  868. // We need to check all keys in case some are required but missing from
  869. // props.
  870. var allKeys = objectAssign({}, props[propName], shapeTypes);
  871. for (var key in allKeys) {
  872. var checker = shapeTypes[key];
  873. if (!checker) {
  874. return new PropTypeError(
  875. 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
  876. '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
  877. '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
  878. );
  879. }
  880. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  881. if (error) {
  882. return error;
  883. }
  884. }
  885. return null;
  886. }
  887. return createChainableTypeChecker(validate);
  888. }
  889. function isNode(propValue) {
  890. switch (typeof propValue) {
  891. case 'number':
  892. case 'string':
  893. case 'undefined':
  894. return true;
  895. case 'boolean':
  896. return !propValue;
  897. case 'object':
  898. if (Array.isArray(propValue)) {
  899. return propValue.every(isNode);
  900. }
  901. if (propValue === null || isValidElement(propValue)) {
  902. return true;
  903. }
  904. var iteratorFn = getIteratorFn(propValue);
  905. if (iteratorFn) {
  906. var iterator = iteratorFn.call(propValue);
  907. var step;
  908. if (iteratorFn !== propValue.entries) {
  909. while (!(step = iterator.next()).done) {
  910. if (!isNode(step.value)) {
  911. return false;
  912. }
  913. }
  914. } else {
  915. // Iterator will provide entry [k,v] tuples rather than values.
  916. while (!(step = iterator.next()).done) {
  917. var entry = step.value;
  918. if (entry) {
  919. if (!isNode(entry[1])) {
  920. return false;
  921. }
  922. }
  923. }
  924. }
  925. } else {
  926. return false;
  927. }
  928. return true;
  929. default:
  930. return false;
  931. }
  932. }
  933. function isSymbol(propType, propValue) {
  934. // Native Symbol.
  935. if (propType === 'symbol') {
  936. return true;
  937. }
  938. // falsy value can't be a Symbol
  939. if (!propValue) {
  940. return false;
  941. }
  942. // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
  943. if (propValue['@@toStringTag'] === 'Symbol') {
  944. return true;
  945. }
  946. // Fallback for non-spec compliant Symbols which are polyfilled.
  947. if (typeof Symbol === 'function' && propValue instanceof Symbol) {
  948. return true;
  949. }
  950. return false;
  951. }
  952. // Equivalent of `typeof` but with special handling for array and regexp.
  953. function getPropType(propValue) {
  954. var propType = typeof propValue;
  955. if (Array.isArray(propValue)) {
  956. return 'array';
  957. }
  958. if (propValue instanceof RegExp) {
  959. // Old webkits (at least until Android 4.0) return 'function' rather than
  960. // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
  961. // passes PropTypes.object.
  962. return 'object';
  963. }
  964. if (isSymbol(propType, propValue)) {
  965. return 'symbol';
  966. }
  967. return propType;
  968. }
  969. // This handles more types than `getPropType`. Only used for error messages.
  970. // See `createPrimitiveTypeChecker`.
  971. function getPreciseType(propValue) {
  972. if (typeof propValue === 'undefined' || propValue === null) {
  973. return '' + propValue;
  974. }
  975. var propType = getPropType(propValue);
  976. if (propType === 'object') {
  977. if (propValue instanceof Date) {
  978. return 'date';
  979. } else if (propValue instanceof RegExp) {
  980. return 'regexp';
  981. }
  982. }
  983. return propType;
  984. }
  985. // Returns a string that is postfixed to a warning about an invalid type.
  986. // For example, "undefined" or "of type array"
  987. function getPostfixForTypeWarning(value) {
  988. var type = getPreciseType(value);
  989. switch (type) {
  990. case 'array':
  991. case 'object':
  992. return 'an ' + type;
  993. case 'boolean':
  994. case 'date':
  995. case 'regexp':
  996. return 'a ' + type;
  997. default:
  998. return type;
  999. }
  1000. }
  1001. // Returns class name of the object, if any.
  1002. function getClassName(propValue) {
  1003. if (!propValue.constructor || !propValue.constructor.name) {
  1004. return ANONYMOUS;
  1005. }
  1006. return propValue.constructor.name;
  1007. }
  1008. ReactPropTypes.checkPropTypes = checkPropTypes_1;
  1009. ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
  1010. ReactPropTypes.PropTypes = ReactPropTypes;
  1011. return ReactPropTypes;
  1012. };
  1013. var propTypes = createCommonjsModule(function (module) {
  1014. /**
  1015. * Copyright (c) 2013-present, Facebook, Inc.
  1016. *
  1017. * This source code is licensed under the MIT license found in the
  1018. * LICENSE file in the root directory of this source tree.
  1019. */
  1020. {
  1021. var ReactIs = reactIs;
  1022. // By explicitly using `prop-types` you are opting into new development behavior.
  1023. // http://fb.me/prop-types-in-prod
  1024. var throwOnDirectAccess = true;
  1025. module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
  1026. }
  1027. });
  1028. function _extends$1() {
  1029. _extends$1 = Object.assign || function (target) {
  1030. for (var i = 1; i < arguments.length; i++) {
  1031. var source = arguments[i];
  1032. for (var key in source) {
  1033. if (Object.prototype.hasOwnProperty.call(source, key)) {
  1034. target[key] = source[key];
  1035. }
  1036. }
  1037. }
  1038. return target;
  1039. };
  1040. return _extends$1.apply(this, arguments);
  1041. }
  1042. function _objectWithoutPropertiesLoose$1(source, excluded) {
  1043. if (source == null) return {};
  1044. var target = {};
  1045. var sourceKeys = Object.keys(source);
  1046. var key, i;
  1047. for (i = 0; i < sourceKeys.length; i++) {
  1048. key = sourceKeys[i];
  1049. if (excluded.indexOf(key) >= 0) continue;
  1050. target[key] = source[key];
  1051. }
  1052. return target;
  1053. }
  1054. /**
  1055. * Copyright (c) 2013-present, Facebook, Inc.
  1056. *
  1057. * This source code is licensed under the MIT license found in the
  1058. * LICENSE file in the root directory of this source tree.
  1059. */
  1060. var invariant = function(condition, format, a, b, c, d, e, f) {
  1061. {
  1062. if (format === undefined) {
  1063. throw new Error('invariant requires an error message argument');
  1064. }
  1065. }
  1066. if (!condition) {
  1067. var error;
  1068. if (format === undefined) {
  1069. error = new Error(
  1070. 'Minified exception occurred; use the non-minified dev environment ' +
  1071. 'for the full error message and additional helpful warnings.'
  1072. );
  1073. } else {
  1074. var args = [a, b, c, d, e, f];
  1075. var argIndex = 0;
  1076. error = new Error(
  1077. format.replace(/%s/g, function() { return args[argIndex++]; })
  1078. );
  1079. error.name = 'Invariant Violation';
  1080. }
  1081. error.framesToPop = 1; // we don't care about invariant's own frame
  1082. throw error;
  1083. }
  1084. };
  1085. var invariant_1 = invariant;
  1086. var noop = function noop() {};
  1087. function readOnlyPropType(handler, name) {
  1088. return function (props, propName) {
  1089. if (props[propName] !== undefined) {
  1090. if (!props[handler]) {
  1091. return new Error("You have provided a `" + propName + "` prop to `" + name + "` " + ("without an `" + handler + "` handler prop. This will render a read-only field. ") + ("If the field should be mutable use `" + defaultKey(propName) + "`. ") + ("Otherwise, set `" + handler + "`."));
  1092. }
  1093. }
  1094. };
  1095. }
  1096. function uncontrolledPropTypes(controlledValues, displayName) {
  1097. var propTypes = {};
  1098. Object.keys(controlledValues).forEach(function (prop) {
  1099. // add default propTypes for folks that use runtime checks
  1100. propTypes[defaultKey(prop)] = noop;
  1101. {
  1102. var handler = controlledValues[prop];
  1103. !(typeof handler === 'string' && handler.trim().length) ? invariant_1(false, 'Uncontrollable - [%s]: the prop `%s` needs a valid handler key name in order to make it uncontrollable', displayName, prop) : void 0;
  1104. propTypes[prop] = readOnlyPropType(handler, displayName);
  1105. }
  1106. });
  1107. return propTypes;
  1108. }
  1109. function isProp(props, prop) {
  1110. return props[prop] !== undefined;
  1111. }
  1112. function defaultKey(key) {
  1113. return 'default' + key.charAt(0).toUpperCase() + key.substr(1);
  1114. }
  1115. /**
  1116. * Copyright (c) 2013-present, Facebook, Inc.
  1117. * All rights reserved.
  1118. *
  1119. * This source code is licensed under the BSD-style license found in the
  1120. * LICENSE file in the root directory of this source tree. An additional grant
  1121. * of patent rights can be found in the PATENTS file in the same directory.
  1122. */
  1123. function canAcceptRef(component) {
  1124. return !!component && (typeof component !== 'function' || component.prototype && component.prototype.isReactComponent);
  1125. }
  1126. function _inheritsLoose$1(subClass, superClass) {
  1127. subClass.prototype = Object.create(superClass.prototype);
  1128. subClass.prototype.constructor = subClass;
  1129. subClass.__proto__ = superClass;
  1130. }
  1131. function uncontrollable(Component, controlledValues, methods) {
  1132. if (methods === void 0) {
  1133. methods = [];
  1134. }
  1135. var displayName = Component.displayName || Component.name || 'Component';
  1136. var canAcceptRef$1 = canAcceptRef(Component);
  1137. var controlledProps = Object.keys(controlledValues);
  1138. var PROPS_TO_OMIT = controlledProps.map(defaultKey);
  1139. !(canAcceptRef$1 || !methods.length) ? invariant_1(false, '[uncontrollable] stateless function components cannot pass through methods ' + 'because they have no associated instances. Check component: ' + displayName + ', ' + 'attempting to pass through methods: ' + methods.join(', ')) : void 0;
  1140. var UncontrolledComponent =
  1141. /*#__PURE__*/
  1142. function (_React$Component) {
  1143. _inheritsLoose$1(UncontrolledComponent, _React$Component);
  1144. function UncontrolledComponent() {
  1145. var _this;
  1146. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1147. args[_key] = arguments[_key];
  1148. }
  1149. _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
  1150. _this.handlers = Object.create(null);
  1151. controlledProps.forEach(function (propName) {
  1152. var handlerName = controlledValues[propName];
  1153. var handleChange = function handleChange(value) {
  1154. if (_this.props[handlerName]) {
  1155. var _this$props;
  1156. _this._notifying = true;
  1157. for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
  1158. args[_key2 - 1] = arguments[_key2];
  1159. }
  1160. (_this$props = _this.props)[handlerName].apply(_this$props, [value].concat(args));
  1161. _this._notifying = false;
  1162. }
  1163. _this._values[propName] = value;
  1164. if (!_this.unmounted) _this.forceUpdate();
  1165. };
  1166. _this.handlers[handlerName] = handleChange;
  1167. });
  1168. if (methods.length) _this.attachRef = function (ref) {
  1169. _this.inner = ref;
  1170. };
  1171. return _this;
  1172. }
  1173. var _proto = UncontrolledComponent.prototype;
  1174. _proto.shouldComponentUpdate = function shouldComponentUpdate() {
  1175. //let the forceUpdate trigger the update
  1176. return !this._notifying;
  1177. };
  1178. _proto.componentWillMount = function componentWillMount() {
  1179. var _this2 = this;
  1180. var props = this.props;
  1181. this._values = Object.create(null);
  1182. controlledProps.forEach(function (key) {
  1183. _this2._values[key] = props[defaultKey(key)];
  1184. });
  1185. };
  1186. _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
  1187. var _this3 = this;
  1188. var props = this.props;
  1189. controlledProps.forEach(function (key) {
  1190. /**
  1191. * If a prop switches from controlled to Uncontrolled
  1192. * reset its value to the defaultValue
  1193. */
  1194. if (!isProp(nextProps, key) && isProp(props, key)) {
  1195. _this3._values[key] = nextProps[defaultKey(key)];
  1196. }
  1197. });
  1198. };
  1199. _proto.componentWillUnmount = function componentWillUnmount() {
  1200. this.unmounted = true;
  1201. };
  1202. _proto.render = function render() {
  1203. var _this4 = this;
  1204. var _this$props2 = this.props,
  1205. innerRef = _this$props2.innerRef,
  1206. props = _objectWithoutPropertiesLoose$1(_this$props2, ["innerRef"]);
  1207. PROPS_TO_OMIT.forEach(function (prop) {
  1208. delete props[prop];
  1209. });
  1210. var newProps = {};
  1211. controlledProps.forEach(function (propName) {
  1212. var propValue = _this4.props[propName];
  1213. newProps[propName] = propValue !== undefined ? propValue : _this4._values[propName];
  1214. });
  1215. return React__default.createElement(Component, _extends$1({}, props, newProps, this.handlers, {
  1216. ref: innerRef || this.attachRef
  1217. }));
  1218. };
  1219. return UncontrolledComponent;
  1220. }(React__default.Component);
  1221. UncontrolledComponent.displayName = "Uncontrolled(" + displayName + ")";
  1222. UncontrolledComponent.propTypes = _extends$1({
  1223. innerRef: function innerRef() {}
  1224. }, uncontrolledPropTypes(controlledValues, displayName));
  1225. methods.forEach(function (method) {
  1226. UncontrolledComponent.prototype[method] = function $proxiedMethod() {
  1227. var _this$inner;
  1228. return (_this$inner = this.inner)[method].apply(_this$inner, arguments);
  1229. };
  1230. });
  1231. var WrappedComponent = UncontrolledComponent;
  1232. if (React__default.forwardRef) {
  1233. WrappedComponent = React__default.forwardRef(function (props, ref) {
  1234. return React__default.createElement(UncontrolledComponent, _extends$1({}, props, {
  1235. innerRef: ref
  1236. }));
  1237. });
  1238. WrappedComponent.propTypes = UncontrolledComponent.propTypes;
  1239. }
  1240. WrappedComponent.ControlledComponent = Component;
  1241. /**
  1242. * useful when wrapping a Component and you want to control
  1243. * everything
  1244. */
  1245. WrappedComponent.deferControlTo = function (newComponent, additions, nextMethods) {
  1246. if (additions === void 0) {
  1247. additions = {};
  1248. }
  1249. return uncontrollable(newComponent, _extends$1({}, controlledValues, additions), nextMethods);
  1250. };
  1251. return WrappedComponent;
  1252. }
  1253. function toVal(mix) {
  1254. var k, y, str='';
  1255. if (mix) {
  1256. if (typeof mix === 'object') {
  1257. if (!!mix.push) {
  1258. for (k=0; k < mix.length; k++) {
  1259. if (mix[k] && (y = toVal(mix[k]))) {
  1260. str && (str += ' ');
  1261. str += y;
  1262. }
  1263. }
  1264. } else {
  1265. for (k in mix) {
  1266. if (mix[k] && (y = toVal(k))) {
  1267. str && (str += ' ');
  1268. str += y;
  1269. }
  1270. }
  1271. }
  1272. } else if (typeof mix !== 'boolean' && !mix.call) {
  1273. str && (str += ' ');
  1274. str += mix;
  1275. }
  1276. }
  1277. return str;
  1278. }
  1279. function clsx () {
  1280. var i=0, x, str='';
  1281. while (i < arguments.length) {
  1282. if (x = toVal(arguments[i++])) {
  1283. str && (str += ' ');
  1284. str += x;
  1285. }
  1286. }
  1287. return str;
  1288. }
  1289. var navigate = {
  1290. PREVIOUS: 'PREV',
  1291. NEXT: 'NEXT',
  1292. TODAY: 'TODAY',
  1293. DATE: 'DATE'
  1294. };
  1295. var views = {
  1296. MONTH: 'month',
  1297. WEEK: 'week',
  1298. WORK_WEEK: 'work_week',
  1299. DAY: 'day',
  1300. AGENDA: 'agenda'
  1301. };
  1302. var viewNames = Object.keys(views).map(function (k) {
  1303. return views[k];
  1304. });
  1305. var accessor = propTypes.oneOfType([propTypes.string, propTypes.func]);
  1306. var dateFormat = propTypes.any;
  1307. var dateRangeFormat = propTypes.func;
  1308. /**
  1309. * accepts either an array of builtin view names:
  1310. *
  1311. * ```
  1312. * views={['month', 'day', 'agenda']}
  1313. * ```
  1314. *
  1315. * or an object hash of the view name and the component (or boolean for builtin)
  1316. *
  1317. * ```
  1318. * views={{
  1319. * month: true,
  1320. * week: false,
  1321. * workweek: WorkWeekViewComponent,
  1322. * }}
  1323. * ```
  1324. */
  1325. var views$1 = propTypes.oneOfType([propTypes.arrayOf(propTypes.oneOf(viewNames)), propTypes.objectOf(function (prop, key) {
  1326. var isBuiltinView = viewNames.indexOf(key) !== -1 && typeof prop[key] === 'boolean';
  1327. if (isBuiltinView) {
  1328. return null;
  1329. } else {
  1330. for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  1331. args[_key - 2] = arguments[_key];
  1332. }
  1333. return propTypes.elementType.apply(propTypes, [prop, key].concat(args));
  1334. }
  1335. })]);
  1336. /**
  1337. * Copyright (c) 2014-present, Facebook, Inc.
  1338. *
  1339. * This source code is licensed under the MIT license found in the
  1340. * LICENSE file in the root directory of this source tree.
  1341. */
  1342. var warning = function() {};
  1343. {
  1344. var printWarning$2 = function printWarning(format, args) {
  1345. var len = arguments.length;
  1346. args = new Array(len > 1 ? len - 1 : 0);
  1347. for (var key = 1; key < len; key++) {
  1348. args[key - 1] = arguments[key];
  1349. }
  1350. var argIndex = 0;
  1351. var message = 'Warning: ' +
  1352. format.replace(/%s/g, function() {
  1353. return args[argIndex++];
  1354. });
  1355. if (typeof console !== 'undefined') {
  1356. console.error(message);
  1357. }
  1358. try {
  1359. // --- Welcome to debugging React ---
  1360. // This error was thrown as a convenience so that you can use this stack
  1361. // to find the callsite that caused this warning to fire.
  1362. throw new Error(message);
  1363. } catch (x) {}
  1364. };
  1365. warning = function(condition, format, args) {
  1366. var len = arguments.length;
  1367. args = new Array(len > 2 ? len - 2 : 0);
  1368. for (var key = 2; key < len; key++) {
  1369. args[key - 2] = arguments[key];
  1370. }
  1371. if (format === undefined) {
  1372. throw new Error(
  1373. '`warning(condition, format, ...args)` requires a warning ' +
  1374. 'message argument'
  1375. );
  1376. }
  1377. if (!condition) {
  1378. printWarning$2.apply(null, [format].concat(args));
  1379. }
  1380. };
  1381. }
  1382. var warning_1 = warning;
  1383. function notify(handler, args) {
  1384. handler && handler.apply(null, [].concat(args));
  1385. }
  1386. var localePropType = propTypes.oneOfType([propTypes.string, propTypes.func]);
  1387. function _format(localizer, formatter, value, format, culture) {
  1388. var result = typeof format === 'function' ? format(value, culture, localizer) : formatter.call(localizer, value, format, culture);
  1389. !(result == null || typeof result === 'string') ? invariant_1(false, '`localizer format(..)` must return a string, null, or undefined') : void 0;
  1390. return result;
  1391. }
  1392. var DateLocalizer = function DateLocalizer(spec) {
  1393. var _this = this;
  1394. !(typeof spec.format === 'function') ? invariant_1(false, 'date localizer `format(..)` must be a function') : void 0;
  1395. !(typeof spec.firstOfWeek === 'function') ? invariant_1(false, 'date localizer `firstOfWeek(..)` must be a function') : void 0;
  1396. this.propType = spec.propType || localePropType;
  1397. this.startOfWeek = spec.firstOfWeek;
  1398. this.formats = spec.formats;
  1399. this.format = function () {
  1400. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  1401. args[_key] = arguments[_key];
  1402. }
  1403. return _format.apply(void 0, [_this, spec.format].concat(args));
  1404. };
  1405. };
  1406. function mergeWithDefaults(localizer, culture, formatOverrides, messages) {
  1407. var formats = _extends({}, localizer.formats, formatOverrides);
  1408. return _extends({}, localizer, {
  1409. messages: messages,
  1410. startOfWeek: function startOfWeek() {
  1411. return localizer.startOfWeek(culture);
  1412. },
  1413. format: function format(value, _format2) {
  1414. return localizer.format(value, formats[_format2] || _format2, culture);
  1415. }
  1416. });
  1417. }
  1418. var defaultMessages = {
  1419. date: 'Date',
  1420. time: 'Time',
  1421. event: 'Event',
  1422. allDay: 'All Day',
  1423. week: 'Week',
  1424. work_week: 'Work Week',
  1425. day: 'Day',
  1426. month: 'Month',
  1427. previous: 'Back',
  1428. next: 'Next',
  1429. yesterday: 'Yesterday',
  1430. tomorrow: 'Tomorrow',
  1431. today: 'Today',
  1432. agenda: 'Agenda',
  1433. noEventsInRange: 'There are no events in this range.',
  1434. showMore: function showMore(total) {
  1435. return "+" + total + " more";
  1436. }
  1437. };
  1438. function messages(msgs) {
  1439. return _extends({}, defaultMessages, msgs);
  1440. }
  1441. function _assertThisInitialized(self) {
  1442. if (self === void 0) {
  1443. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  1444. }
  1445. return self;
  1446. }
  1447. var MILI = 'milliseconds'
  1448. , SECONDS = 'seconds'
  1449. , MINUTES = 'minutes'
  1450. , HOURS = 'hours'
  1451. , DAY = 'day'
  1452. , WEEK = 'week'
  1453. , MONTH = 'month'
  1454. , YEAR = 'year'
  1455. , DECADE = 'decade'
  1456. , CENTURY = 'century';
  1457. function add(d, num, unit) {
  1458. d = new Date(d);
  1459. switch (unit){
  1460. case MILI:
  1461. return milliseconds(d, milliseconds(d) + num)
  1462. case SECONDS:
  1463. return seconds(d, seconds(d) + num)
  1464. case MINUTES:
  1465. return minutes(d, minutes(d) + num)
  1466. case HOURS:
  1467. return hours(d, hours(d) + num)
  1468. case YEAR:
  1469. return year(d, year(d) + num)
  1470. case DAY:
  1471. return date(d, date(d) + num)
  1472. case WEEK:
  1473. return date(d, date(d) + (7 * num))
  1474. case MONTH:
  1475. return monthMath(d, num)
  1476. case DECADE:
  1477. return year(d, year(d) + (num * 10))
  1478. case CENTURY:
  1479. return year(d, year(d) + (num * 100))
  1480. }
  1481. throw new TypeError('Invalid units: "' + unit + '"')
  1482. }
  1483. function subtract(d, num, unit) {
  1484. return add(d, -num, unit)
  1485. }
  1486. function startOf(d, unit, firstOfWeek) {
  1487. d = new Date(d);
  1488. switch (unit) {
  1489. case CENTURY:
  1490. case DECADE:
  1491. case YEAR:
  1492. d = month(d, 0);
  1493. case MONTH:
  1494. d = date(d, 1);
  1495. case WEEK:
  1496. case DAY:
  1497. d = hours(d, 0);
  1498. case HOURS:
  1499. d = minutes(d, 0);
  1500. case MINUTES:
  1501. d = seconds(d, 0);
  1502. case SECONDS:
  1503. d = milliseconds(d, 0);
  1504. }
  1505. if (unit === DECADE)
  1506. d = subtract(d, year(d) % 10, 'year');
  1507. if (unit === CENTURY)
  1508. d = subtract(d, year(d) % 100, 'year');
  1509. if (unit === WEEK)
  1510. d = weekday(d, 0, firstOfWeek);
  1511. return d
  1512. }
  1513. function endOf(d, unit, firstOfWeek){
  1514. d = new Date(d);
  1515. d = startOf(d, unit, firstOfWeek);
  1516. d = add(d, 1, unit);
  1517. d = subtract(d, 1, MILI);
  1518. return d
  1519. }
  1520. var eq = createComparer(function(a, b){ return a === b });
  1521. var gt = createComparer(function(a, b){ return a > b });
  1522. var gte = createComparer(function(a, b){ return a >= b });
  1523. var lt = createComparer(function(a, b){ return a < b });
  1524. var lte = createComparer(function(a, b){ return a <= b });
  1525. function min(){
  1526. return new Date(Math.min.apply(Math, arguments))
  1527. }
  1528. function max(){
  1529. return new Date(Math.max.apply(Math, arguments))
  1530. }
  1531. function inRange(day, min, max, unit){
  1532. unit = unit || 'day';
  1533. return (!min || gte(day, min, unit))
  1534. && (!max || lte(day, max, unit))
  1535. }
  1536. var milliseconds = createAccessor('Milliseconds');
  1537. var seconds = createAccessor('Seconds');
  1538. var minutes = createAccessor('Minutes');
  1539. var hours = createAccessor('Hours');
  1540. var day = createAccessor('Day');
  1541. var date = createAccessor('Date');
  1542. var month = createAccessor('Month');
  1543. var year = createAccessor('FullYear');
  1544. function weekday(d, val, firstDay) {
  1545. var w = (day(d) + 7 - (firstDay || 0) ) % 7;
  1546. return val === undefined
  1547. ? w
  1548. : add(d, val - w, DAY);
  1549. }
  1550. function monthMath(d, val){
  1551. var current = month(d)
  1552. , newMonth = (current + val);
  1553. d = month(d, newMonth);
  1554. while (newMonth < 0 ) newMonth = 12 + newMonth;
  1555. //month rollover
  1556. if ( month(d) !== ( newMonth % 12))
  1557. d = date(d, 0); //move to last of month
  1558. return d
  1559. }
  1560. function createAccessor(method){
  1561. var hourLength = (function(method) {
  1562. switch(method) {
  1563. case 'Milliseconds':
  1564. return 3600000;
  1565. case 'Seconds':
  1566. return 3600;
  1567. case 'Minutes':
  1568. return 60;
  1569. case 'Hours':
  1570. return 1;
  1571. default:
  1572. return null;
  1573. }
  1574. })(method);
  1575. return function(d, val){
  1576. if (val === undefined)
  1577. return d['get' + method]()
  1578. var dateOut = new Date(d);
  1579. dateOut['set' + method](val);
  1580. if(hourLength && dateOut['get'+method]() != val && (method === 'Hours' || val >=hourLength && (dateOut.getHours()-d.getHours()<Math.floor(val/hourLength))) ){
  1581. //Skip DST hour, if it occurs
  1582. dateOut['set'+method](val+hourLength);
  1583. }
  1584. return dateOut
  1585. }
  1586. }
  1587. function createComparer(operator) {
  1588. return function (a, b, unit) {
  1589. return operator(+startOf(a, unit), +startOf(b, unit))
  1590. };
  1591. }
  1592. /* eslint no-fallthrough: off */
  1593. var MILLI = {
  1594. seconds: 1000,
  1595. minutes: 1000 * 60,
  1596. hours: 1000 * 60 * 60,
  1597. day: 1000 * 60 * 60 * 24
  1598. };
  1599. function firstVisibleDay(date, localizer) {
  1600. var firstOfMonth = startOf(date, 'month');
  1601. return startOf(firstOfMonth, 'week', localizer.startOfWeek());
  1602. }
  1603. function lastVisibleDay(date, localizer) {
  1604. var endOfMonth = endOf(date, 'month');
  1605. return endOf(endOfMonth, 'week', localizer.startOfWeek());
  1606. }
  1607. function visibleDays(date, localizer) {
  1608. var current = firstVisibleDay(date, localizer),
  1609. last = lastVisibleDay(date, localizer),
  1610. days = [];
  1611. while (lte(current, last, 'day')) {
  1612. days.push(current);
  1613. current = add(current, 1, 'day');
  1614. }
  1615. return days;
  1616. }
  1617. function ceil(date, unit) {
  1618. var floor = startOf(date, unit);
  1619. return eq(floor, date) ? floor : add(floor, 1, unit);
  1620. }
  1621. function range(start, end, unit) {
  1622. if (unit === void 0) {
  1623. unit = 'day';
  1624. }
  1625. var current = start,
  1626. days = [];
  1627. while (lte(current, end, unit)) {
  1628. days.push(current);
  1629. current = add(current, 1, unit);
  1630. }
  1631. return days;
  1632. }
  1633. function merge(date, time) {
  1634. if (time == null && date == null) return null;
  1635. if (time == null) time = new Date();
  1636. if (date == null) date = new Date();
  1637. date = startOf(date, 'day');
  1638. date = hours(date, hours(time));
  1639. date = minutes(date, minutes(time));
  1640. date = seconds(date, seconds(time));
  1641. return milliseconds(date, milliseconds(time));
  1642. }
  1643. function isJustDate(date) {
  1644. return hours(date) === 0 && minutes(date) === 0 && seconds(date) === 0 && milliseconds(date) === 0;
  1645. }
  1646. function diff(dateA, dateB, unit) {
  1647. if (!unit || unit === 'milliseconds') return Math.abs(+dateA - +dateB); // the .round() handles an edge case
  1648. // with DST where the total won't be exact
  1649. // since one day in the range may be shorter/longer by an hour
  1650. return Math.round(Math.abs(+startOf(dateA, unit) / MILLI[unit] - +startOf(dateB, unit) / MILLI[unit]));
  1651. }
  1652. /**
  1653. * The base implementation of `_.slice` without an iteratee call guard.
  1654. *
  1655. * @private
  1656. * @param {Array} array The array to slice.
  1657. * @param {number} [start=0] The start position.
  1658. * @param {number} [end=array.length] The end position.
  1659. * @returns {Array} Returns the slice of `array`.
  1660. */
  1661. function baseSlice(array, start, end) {
  1662. var index = -1,
  1663. length = array.length;
  1664. if (start < 0) {
  1665. start = -start > length ? 0 : (length + start);
  1666. }
  1667. end = end > length ? length : end;
  1668. if (end < 0) {
  1669. end += length;
  1670. }
  1671. length = start > end ? 0 : ((end - start) >>> 0);
  1672. start >>>= 0;
  1673. var result = Array(length);
  1674. while (++index < length) {
  1675. result[index] = array[index + start];
  1676. }
  1677. return result;
  1678. }
  1679. /**
  1680. * Performs a
  1681. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  1682. * comparison between two values to determine if they are equivalent.
  1683. *
  1684. * @static
  1685. * @memberOf _
  1686. * @since 4.0.0
  1687. * @category Lang
  1688. * @param {*} value The value to compare.
  1689. * @param {*} other The other value to compare.
  1690. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  1691. * @example
  1692. *
  1693. * var object = { 'a': 1 };
  1694. * var other = { 'a': 1 };
  1695. *
  1696. * _.eq(object, object);
  1697. * // => true
  1698. *
  1699. * _.eq(object, other);
  1700. * // => false
  1701. *
  1702. * _.eq('a', 'a');
  1703. * // => true
  1704. *
  1705. * _.eq('a', Object('a'));
  1706. * // => false
  1707. *
  1708. * _.eq(NaN, NaN);
  1709. * // => true
  1710. */
  1711. function eq$1(value, other) {
  1712. return value === other || (value !== value && other !== other);
  1713. }
  1714. /** Detect free variable `global` from Node.js. */
  1715. var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
  1716. /** Detect free variable `self`. */
  1717. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1718. /** Used as a reference to the global object. */
  1719. var root = freeGlobal || freeSelf || Function('return this')();
  1720. /** Built-in value references. */
  1721. var Symbol$1 = root.Symbol;
  1722. /** Used for built-in method references. */
  1723. var objectProto = Object.prototype;
  1724. /** Used to check objects for own properties. */
  1725. var hasOwnProperty$1 = objectProto.hasOwnProperty;
  1726. /**
  1727. * Used to resolve the
  1728. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1729. * of values.
  1730. */
  1731. var nativeObjectToString = objectProto.toString;
  1732. /** Built-in value references. */
  1733. var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
  1734. /**
  1735. * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
  1736. *
  1737. * @private
  1738. * @param {*} value The value to query.
  1739. * @returns {string} Returns the raw `toStringTag`.
  1740. */
  1741. function getRawTag(value) {
  1742. var isOwn = hasOwnProperty$1.call(value, symToStringTag),
  1743. tag = value[symToStringTag];
  1744. try {
  1745. value[symToStringTag] = undefined;
  1746. var unmasked = true;
  1747. } catch (e) {}
  1748. var result = nativeObjectToString.call(value);
  1749. if (unmasked) {
  1750. if (isOwn) {
  1751. value[symToStringTag] = tag;
  1752. } else {
  1753. delete value[symToStringTag];
  1754. }
  1755. }
  1756. return result;
  1757. }
  1758. /** Used for built-in method references. */
  1759. var objectProto$1 = Object.prototype;
  1760. /**
  1761. * Used to resolve the
  1762. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1763. * of values.
  1764. */
  1765. var nativeObjectToString$1 = objectProto$1.toString;
  1766. /**
  1767. * Converts `value` to a string using `Object.prototype.toString`.
  1768. *
  1769. * @private
  1770. * @param {*} value The value to convert.
  1771. * @returns {string} Returns the converted string.
  1772. */
  1773. function objectToString(value) {
  1774. return nativeObjectToString$1.call(value);
  1775. }
  1776. /** `Object#toString` result references. */
  1777. var nullTag = '[object Null]',
  1778. undefinedTag = '[object Undefined]';
  1779. /** Built-in value references. */
  1780. var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
  1781. /**
  1782. * The base implementation of `getTag` without fallbacks for buggy environments.
  1783. *
  1784. * @private
  1785. * @param {*} value The value to query.
  1786. * @returns {string} Returns the `toStringTag`.
  1787. */
  1788. function baseGetTag(value) {
  1789. if (value == null) {
  1790. return value === undefined ? undefinedTag : nullTag;
  1791. }
  1792. return (symToStringTag$1 && symToStringTag$1 in Object(value))
  1793. ? getRawTag(value)
  1794. : objectToString(value);
  1795. }
  1796. /**
  1797. * Checks if `value` is the
  1798. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  1799. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1800. *
  1801. * @static
  1802. * @memberOf _
  1803. * @since 0.1.0
  1804. * @category Lang
  1805. * @param {*} value The value to check.
  1806. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1807. * @example
  1808. *
  1809. * _.isObject({});
  1810. * // => true
  1811. *
  1812. * _.isObject([1, 2, 3]);
  1813. * // => true
  1814. *
  1815. * _.isObject(_.noop);
  1816. * // => true
  1817. *
  1818. * _.isObject(null);
  1819. * // => false
  1820. */
  1821. function isObject(value) {
  1822. var type = typeof value;
  1823. return value != null && (type == 'object' || type == 'function');
  1824. }
  1825. /** `Object#toString` result references. */
  1826. var asyncTag = '[object AsyncFunction]',
  1827. funcTag = '[object Function]',
  1828. genTag = '[object GeneratorFunction]',
  1829. proxyTag = '[object Proxy]';
  1830. /**
  1831. * Checks if `value` is classified as a `Function` object.
  1832. *
  1833. * @static
  1834. * @memberOf _
  1835. * @since 0.1.0
  1836. * @category Lang
  1837. * @param {*} value The value to check.
  1838. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  1839. * @example
  1840. *
  1841. * _.isFunction(_);
  1842. * // => true
  1843. *
  1844. * _.isFunction(/abc/);
  1845. * // => false
  1846. */
  1847. function isFunction(value) {
  1848. if (!isObject(value)) {
  1849. return false;
  1850. }
  1851. // The use of `Object#toString` avoids issues with the `typeof` operator
  1852. // in Safari 9 which returns 'object' for typed arrays and other constructors.
  1853. var tag = baseGetTag(value);
  1854. return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
  1855. }
  1856. /** Used as references for various `Number` constants. */
  1857. var MAX_SAFE_INTEGER = 9007199254740991;
  1858. /**
  1859. * Checks if `value` is a valid array-like length.
  1860. *
  1861. * **Note:** This method is loosely based on
  1862. * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
  1863. *
  1864. * @static
  1865. * @memberOf _
  1866. * @since 4.0.0
  1867. * @category Lang
  1868. * @param {*} value The value to check.
  1869. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
  1870. * @example
  1871. *
  1872. * _.isLength(3);
  1873. * // => true
  1874. *
  1875. * _.isLength(Number.MIN_VALUE);
  1876. * // => false
  1877. *
  1878. * _.isLength(Infinity);
  1879. * // => false
  1880. *
  1881. * _.isLength('3');
  1882. * // => false
  1883. */
  1884. function isLength(value) {
  1885. return typeof value == 'number' &&
  1886. value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
  1887. }
  1888. /**
  1889. * Checks if `value` is array-like. A value is considered array-like if it's
  1890. * not a function and has a `value.length` that's an integer greater than or
  1891. * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
  1892. *
  1893. * @static
  1894. * @memberOf _
  1895. * @since 4.0.0
  1896. * @category Lang
  1897. * @param {*} value The value to check.
  1898. * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
  1899. * @example
  1900. *
  1901. * _.isArrayLike([1, 2, 3]);
  1902. * // => true
  1903. *
  1904. * _.isArrayLike(document.body.children);
  1905. * // => true
  1906. *
  1907. * _.isArrayLike('abc');
  1908. * // => true
  1909. *
  1910. * _.isArrayLike(_.noop);
  1911. * // => false
  1912. */
  1913. function isArrayLike(value) {
  1914. return value != null && isLength(value.length) && !isFunction(value);
  1915. }
  1916. /** Used as references for various `Number` constants. */
  1917. var MAX_SAFE_INTEGER$1 = 9007199254740991;
  1918. /** Used to detect unsigned integer values. */
  1919. var reIsUint = /^(?:0|[1-9]\d*)$/;
  1920. /**
  1921. * Checks if `value` is a valid array-like index.
  1922. *
  1923. * @private
  1924. * @param {*} value The value to check.
  1925. * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
  1926. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
  1927. */
  1928. function isIndex(value, length) {
  1929. var type = typeof value;
  1930. length = length == null ? MAX_SAFE_INTEGER$1 : length;
  1931. return !!length &&
  1932. (type == 'number' ||
  1933. (type != 'symbol' && reIsUint.test(value))) &&
  1934. (value > -1 && value % 1 == 0 && value < length);
  1935. }
  1936. /**
  1937. * Checks if the given arguments are from an iteratee call.
  1938. *
  1939. * @private
  1940. * @param {*} value The potential iteratee value argument.
  1941. * @param {*} index The potential iteratee index or key argument.
  1942. * @param {*} object The potential iteratee object argument.
  1943. * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
  1944. * else `false`.
  1945. */
  1946. function isIterateeCall(value, index, object) {
  1947. if (!isObject(object)) {
  1948. return false;
  1949. }
  1950. var type = typeof index;
  1951. if (type == 'number'
  1952. ? (isArrayLike(object) && isIndex(index, object.length))
  1953. : (type == 'string' && index in object)
  1954. ) {
  1955. return eq$1(object[index], value);
  1956. }
  1957. return false;
  1958. }
  1959. /**
  1960. * Checks if `value` is object-like. A value is object-like if it's not `null`
  1961. * and has a `typeof` result of "object".
  1962. *
  1963. * @static
  1964. * @memberOf _
  1965. * @since 4.0.0
  1966. * @category Lang
  1967. * @param {*} value The value to check.
  1968. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  1969. * @example
  1970. *
  1971. * _.isObjectLike({});
  1972. * // => true
  1973. *
  1974. * _.isObjectLike([1, 2, 3]);
  1975. * // => true
  1976. *
  1977. * _.isObjectLike(_.noop);
  1978. * // => false
  1979. *
  1980. * _.isObjectLike(null);
  1981. * // => false
  1982. */
  1983. function isObjectLike(value) {
  1984. return value != null && typeof value == 'object';
  1985. }
  1986. /** `Object#toString` result references. */
  1987. var symbolTag = '[object Symbol]';
  1988. /**
  1989. * Checks if `value` is classified as a `Symbol` primitive or object.
  1990. *
  1991. * @static
  1992. * @memberOf _
  1993. * @since 4.0.0
  1994. * @category Lang
  1995. * @param {*} value The value to check.
  1996. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  1997. * @example
  1998. *
  1999. * _.isSymbol(Symbol.iterator);
  2000. * // => true
  2001. *
  2002. * _.isSymbol('abc');
  2003. * // => false
  2004. */
  2005. function isSymbol(value) {
  2006. return typeof value == 'symbol' ||
  2007. (isObjectLike(value) && baseGetTag(value) == symbolTag);
  2008. }
  2009. /** Used as references for various `Number` constants. */
  2010. var NAN = 0 / 0;
  2011. /** Used to match leading and trailing whitespace. */
  2012. var reTrim = /^\s+|\s+$/g;
  2013. /** Used to detect bad signed hexadecimal string values. */
  2014. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  2015. /** Used to detect binary string values. */
  2016. var reIsBinary = /^0b[01]+$/i;
  2017. /** Used to detect octal string values. */
  2018. var reIsOctal = /^0o[0-7]+$/i;
  2019. /** Built-in method references without a dependency on `root`. */
  2020. var freeParseInt = parseInt;
  2021. /**
  2022. * Converts `value` to a number.
  2023. *
  2024. * @static
  2025. * @memberOf _
  2026. * @since 4.0.0
  2027. * @category Lang
  2028. * @param {*} value The value to process.
  2029. * @returns {number} Returns the number.
  2030. * @example
  2031. *
  2032. * _.toNumber(3.2);
  2033. * // => 3.2
  2034. *
  2035. * _.toNumber(Number.MIN_VALUE);
  2036. * // => 5e-324
  2037. *
  2038. * _.toNumber(Infinity);
  2039. * // => Infinity
  2040. *
  2041. * _.toNumber('3.2');
  2042. * // => 3.2
  2043. */
  2044. function toNumber(value) {
  2045. if (typeof value == 'number') {
  2046. return value;
  2047. }
  2048. if (isSymbol(value)) {
  2049. return NAN;
  2050. }
  2051. if (isObject(value)) {
  2052. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  2053. value = isObject(other) ? (other + '') : other;
  2054. }
  2055. if (typeof value != 'string') {
  2056. return value === 0 ? value : +value;
  2057. }
  2058. value = value.replace(reTrim, '');
  2059. var isBinary = reIsBinary.test(value);
  2060. return (isBinary || reIsOctal.test(value))
  2061. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  2062. : (reIsBadHex.test(value) ? NAN : +value);
  2063. }
  2064. /** Used as references for various `Number` constants. */
  2065. var INFINITY = 1 / 0,
  2066. MAX_INTEGER = 1.7976931348623157e+308;
  2067. /**
  2068. * Converts `value` to a finite number.
  2069. *
  2070. * @static
  2071. * @memberOf _
  2072. * @since 4.12.0
  2073. * @category Lang
  2074. * @param {*} value The value to convert.
  2075. * @returns {number} Returns the converted number.
  2076. * @example
  2077. *
  2078. * _.toFinite(3.2);
  2079. * // => 3.2
  2080. *
  2081. * _.toFinite(Number.MIN_VALUE);
  2082. * // => 5e-324
  2083. *
  2084. * _.toFinite(Infinity);
  2085. * // => 1.7976931348623157e+308
  2086. *
  2087. * _.toFinite('3.2');
  2088. * // => 3.2
  2089. */
  2090. function toFinite(value) {
  2091. if (!value) {
  2092. return value === 0 ? value : 0;
  2093. }
  2094. value = toNumber(value);
  2095. if (value === INFINITY || value === -INFINITY) {
  2096. var sign = (value < 0 ? -1 : 1);
  2097. return sign * MAX_INTEGER;
  2098. }
  2099. return value === value ? value : 0;
  2100. }
  2101. /**
  2102. * Converts `value` to an integer.
  2103. *
  2104. * **Note:** This method is loosely based on
  2105. * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
  2106. *
  2107. * @static
  2108. * @memberOf _
  2109. * @since 4.0.0
  2110. * @category Lang
  2111. * @param {*} value The value to convert.
  2112. * @returns {number} Returns the converted integer.
  2113. * @example
  2114. *
  2115. * _.toInteger(3.2);
  2116. * // => 3
  2117. *
  2118. * _.toInteger(Number.MIN_VALUE);
  2119. * // => 0
  2120. *
  2121. * _.toInteger(Infinity);
  2122. * // => 1.7976931348623157e+308
  2123. *
  2124. * _.toInteger('3.2');
  2125. * // => 3
  2126. */
  2127. function toInteger(value) {
  2128. var result = toFinite(value),
  2129. remainder = result % 1;
  2130. return result === result ? (remainder ? result - remainder : result) : 0;
  2131. }
  2132. /* Built-in method references for those with the same name as other `lodash` methods. */
  2133. var nativeCeil = Math.ceil,
  2134. nativeMax = Math.max;
  2135. /**
  2136. * Creates an array of elements split into groups the length of `size`.
  2137. * If `array` can't be split evenly, the final chunk will be the remaining
  2138. * elements.
  2139. *
  2140. * @static
  2141. * @memberOf _
  2142. * @since 3.0.0
  2143. * @category Array
  2144. * @param {Array} array The array to process.
  2145. * @param {number} [size=1] The length of each chunk
  2146. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
  2147. * @returns {Array} Returns the new array of chunks.
  2148. * @example
  2149. *
  2150. * _.chunk(['a', 'b', 'c', 'd'], 2);
  2151. * // => [['a', 'b'], ['c', 'd']]
  2152. *
  2153. * _.chunk(['a', 'b', 'c', 'd'], 3);
  2154. * // => [['a', 'b', 'c'], ['d']]
  2155. */
  2156. function chunk(array, size, guard) {
  2157. if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) {
  2158. size = 1;
  2159. } else {
  2160. size = nativeMax(toInteger(size), 0);
  2161. }
  2162. var length = array == null ? 0 : array.length;
  2163. if (!length || size < 1) {
  2164. return [];
  2165. }
  2166. var index = 0,
  2167. resIndex = 0,
  2168. result = Array(nativeCeil(length / size));
  2169. while (index < length) {
  2170. result[resIndex++] = baseSlice(array, index, (index += size));
  2171. }
  2172. return result;
  2173. }
  2174. function _extends$2() {
  2175. _extends$2 = Object.assign || function (target) {
  2176. for (var i = 1; i < arguments.length; i++) {
  2177. var source = arguments[i];
  2178. for (var key in source) {
  2179. if (Object.prototype.hasOwnProperty.call(source, key)) {
  2180. target[key] = source[key];
  2181. }
  2182. }
  2183. }
  2184. return target;
  2185. };
  2186. return _extends$2.apply(this, arguments);
  2187. }
  2188. function ownerDocument(node) {
  2189. return node && node.ownerDocument || document;
  2190. }
  2191. function ownerWindow(node) {
  2192. var doc = ownerDocument(node);
  2193. return doc && doc.defaultView || window;
  2194. }
  2195. function getComputedStyle$1(node, psuedoElement) {
  2196. return ownerWindow(node).getComputedStyle(node, psuedoElement);
  2197. }
  2198. var rUpper = /([A-Z])/g;
  2199. function hyphenate(string) {
  2200. return string.replace(rUpper, '-$1').toLowerCase();
  2201. }
  2202. /**
  2203. * Copyright 2013-2014, Facebook, Inc.
  2204. * All rights reserved.
  2205. * https://github.com/facebook/react/blob/2aeb8a2a6beb00617a4217f7f8284924fa2ad819/src/vendor/core/hyphenateStyleName.js
  2206. */
  2207. var msPattern = /^ms-/;
  2208. function hyphenateStyleName(string) {
  2209. return hyphenate(string).replace(msPattern, '-ms-');
  2210. }
  2211. var supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i;
  2212. function isTransform(value) {
  2213. return !!(value && supportedTransforms.test(value));
  2214. }
  2215. function style(node, property) {
  2216. var css = '';
  2217. var transforms = '';
  2218. if (typeof property === 'string') {
  2219. return node.style.getPropertyValue(hyphenateStyleName(property)) || getComputedStyle$1(node).getPropertyValue(hyphenateStyleName(property));
  2220. }
  2221. Object.keys(property).forEach(function (key) {
  2222. var value = property[key];
  2223. if (!value && value !== 0) {
  2224. node.style.removeProperty(hyphenateStyleName(key));
  2225. } else if (isTransform(key)) {
  2226. transforms += key + "(" + value + ") ";
  2227. } else {
  2228. css += hyphenateStyleName(key) + ": " + value + ";";
  2229. }
  2230. });
  2231. if (transforms) {
  2232. css += "transform: " + transforms + ";";
  2233. }
  2234. node.style.cssText += ";" + css;
  2235. }
  2236. /* eslint-disable no-bitwise, no-cond-assign */
  2237. // HTML DOM and SVG DOM may have different support levels,
  2238. // so we need to check on context instead of a document root element.
  2239. function contains(context, node) {
  2240. if (context.contains) return context.contains(node);
  2241. if (context.compareDocumentPosition) return context === node || !!(context.compareDocumentPosition(node) & 16);
  2242. }
  2243. function isDocument(element) {
  2244. return 'nodeType' in element && element.nodeType === document.DOCUMENT_NODE;
  2245. }
  2246. function isWindow(node) {
  2247. if ('window' in node && node.window === node) return node;
  2248. if (isDocument(node)) return node.defaultView || false;
  2249. return false;
  2250. }
  2251. function getscrollAccessor(offset) {
  2252. var prop = offset === 'pageXOffset' ? 'scrollLeft' : 'scrollTop';
  2253. function scrollAccessor(node, val) {
  2254. var win = isWindow(node);
  2255. if (val === undefined) {
  2256. return win ? win[offset] : node[prop];
  2257. }
  2258. if (win) {
  2259. win.scrollTo(val, win[offset]);
  2260. } else {
  2261. node[prop] = val;
  2262. }
  2263. }
  2264. return scrollAccessor;
  2265. }
  2266. var getScrollLeft = getscrollAccessor('pageXOffset');
  2267. var getScrollTop = getscrollAccessor('pageYOffset');
  2268. function offset(node) {
  2269. var doc = ownerDocument(node);
  2270. var box = {
  2271. top: 0,
  2272. left: 0,
  2273. height: 0,
  2274. width: 0
  2275. };
  2276. var docElem = doc && doc.documentElement; // Make sure it's not a disconnected DOM node
  2277. if (!docElem || !contains(docElem, node)) return box;
  2278. if (node.getBoundingClientRect !== undefined) box = node.getBoundingClientRect();
  2279. box = {
  2280. top: box.top + getScrollTop(node) - (docElem.clientTop || 0),
  2281. left: box.left + getScrollLeft(node) - (docElem.clientLeft || 0),
  2282. width: box.width,
  2283. height: box.height
  2284. };
  2285. return box;
  2286. }
  2287. var isHTMLElement = function isHTMLElement(e) {
  2288. return !!e && 'offsetParent' in e;
  2289. };
  2290. function offsetParent(node) {
  2291. var doc = ownerDocument(node);
  2292. var parent = node && node.offsetParent;
  2293. while (isHTMLElement(parent) && parent.nodeName !== 'HTML' && style(parent, 'position') === 'static') {
  2294. parent = parent.offsetParent;
  2295. }
  2296. return parent || doc.documentElement;
  2297. }
  2298. var nodeName = function nodeName(node) {
  2299. return node.nodeName && node.nodeName.toLowerCase();
  2300. };
  2301. function position(node, offsetParent$1) {
  2302. var parentOffset = {
  2303. top: 0,
  2304. left: 0
  2305. };
  2306. var offset$1; // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
  2307. // because it is its only offset parent
  2308. if (style(node, 'position') === 'fixed') {
  2309. offset$1 = node.getBoundingClientRect();
  2310. } else {
  2311. var parent = offsetParent$1 || offsetParent(node);
  2312. offset$1 = offset(node);
  2313. if (nodeName(parent) !== 'html') parentOffset = offset(parent);
  2314. var borderTop = String(style(parent, 'borderTopWidth') || 0);
  2315. parentOffset.top += parseInt(borderTop, 10) - getScrollTop(parent) || 0;
  2316. var borderLeft = String(style(parent, 'borderLeftWidth') || 0);
  2317. parentOffset.left += parseInt(borderLeft, 10) - getScrollLeft(parent) || 0;
  2318. }
  2319. var marginTop = String(style(node, 'marginTop') || 0);
  2320. var marginLeft = String(style(node, 'marginLeft') || 0); // Subtract parent offsets and node margins
  2321. return _extends$2({}, offset$1, {
  2322. top: offset$1.top - parentOffset.top - (parseInt(marginTop, 10) || 0),
  2323. left: offset$1.left - parentOffset.left - (parseInt(marginLeft, 10) || 0)
  2324. });
  2325. }
  2326. var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
  2327. /* https://github.com/component/raf */
  2328. var prev = new Date().getTime();
  2329. function fallback(fn) {
  2330. var curr = new Date().getTime();
  2331. var ms = Math.max(0, 16 - (curr - prev));
  2332. var handle = setTimeout(fn, ms);
  2333. prev = curr;
  2334. return handle;
  2335. }
  2336. var vendors = ['', 'webkit', 'moz', 'o', 'ms'];
  2337. var cancelMethod = 'clearTimeout';
  2338. var rafImpl = fallback; // eslint-disable-next-line import/no-mutable-exports
  2339. var getKey = function getKey(vendor, k) {
  2340. return vendor + (!vendor ? k : k[0].toUpperCase() + k.substr(1)) + "AnimationFrame";
  2341. };
  2342. if (canUseDOM) {
  2343. vendors.some(function (vendor) {
  2344. var rafMethod = getKey(vendor, 'request');
  2345. if (rafMethod in window) {
  2346. cancelMethod = getKey(vendor, 'cancel'); // @ts-ignore
  2347. rafImpl = function rafImpl(cb) {
  2348. return window[rafMethod](cb);
  2349. };
  2350. }
  2351. return !!rafImpl;
  2352. });
  2353. }
  2354. var cancel = function cancel(id) {
  2355. // @ts-ignore
  2356. if (typeof window[cancelMethod] === 'function') window[cancelMethod](id);
  2357. };
  2358. var request = rafImpl;
  2359. var EventCell =
  2360. /*#__PURE__*/
  2361. function (_React$Component) {
  2362. _inheritsLoose(EventCell, _React$Component);
  2363. function EventCell() {
  2364. return _React$Component.apply(this, arguments) || this;
  2365. }
  2366. var _proto = EventCell.prototype;
  2367. _proto.render = function render() {
  2368. var _this$props = this.props,
  2369. style = _this$props.style,
  2370. className = _this$props.className,
  2371. event = _this$props.event,
  2372. selected = _this$props.selected,
  2373. isAllDay = _this$props.isAllDay,
  2374. onSelect = _this$props.onSelect,
  2375. _onDoubleClick = _this$props.onDoubleClick,
  2376. localizer = _this$props.localizer,
  2377. continuesPrior = _this$props.continuesPrior,
  2378. continuesAfter = _this$props.continuesAfter,
  2379. accessors = _this$props.accessors,
  2380. getters = _this$props.getters,
  2381. children = _this$props.children,
  2382. _this$props$component = _this$props.components,
  2383. Event = _this$props$component.event,
  2384. EventWrapper = _this$props$component.eventWrapper,
  2385. slotStart = _this$props.slotStart,
  2386. slotEnd = _this$props.slotEnd,
  2387. props = _objectWithoutPropertiesLoose(_this$props, ["style", "className", "event", "selected", "isAllDay", "onSelect", "onDoubleClick", "localizer", "continuesPrior", "continuesAfter", "accessors", "getters", "children", "components", "slotStart", "slotEnd"]);
  2388. var title = accessors.title(event);
  2389. var tooltip = accessors.tooltip(event);
  2390. var end = accessors.end(event);
  2391. var start = accessors.start(event);
  2392. var allDay = accessors.allDay(event);
  2393. var showAsAllDay = isAllDay || allDay || diff(start, ceil(end, 'day'), 'day') > 1;
  2394. var userProps = getters.eventProp(event, start, end, selected);
  2395. var content = React__default.createElement("div", {
  2396. className: "rbc-event-content",
  2397. title: tooltip || undefined
  2398. }, Event ? React__default.createElement(Event, {
  2399. event: event,
  2400. continuesPrior: continuesPrior,
  2401. continuesAfter: continuesAfter,
  2402. title: title,
  2403. isAllDay: allDay,
  2404. localizer: localizer,
  2405. slotStart: slotStart,
  2406. slotEnd: slotEnd
  2407. }) : title);
  2408. return React__default.createElement(EventWrapper, _extends({}, this.props, {
  2409. type: "date"
  2410. }), React__default.createElement("div", _extends({}, props, {
  2411. tabIndex: 0,
  2412. style: _extends({}, userProps.style, style),
  2413. className: clsx('rbc-event', className, userProps.className, {
  2414. 'rbc-selected': selected,
  2415. 'rbc-event-allday': showAsAllDay,
  2416. 'rbc-event-continues-prior': continuesPrior,
  2417. 'rbc-event-continues-after': continuesAfter
  2418. }),
  2419. onClick: function onClick(e) {
  2420. return onSelect && onSelect(event, e);
  2421. },
  2422. onDoubleClick: function onDoubleClick(e) {
  2423. return _onDoubleClick && _onDoubleClick(event, e);
  2424. }
  2425. }), typeof children === 'function' ? children(content) : content));
  2426. };
  2427. return EventCell;
  2428. }(React__default.Component);
  2429. EventCell.propTypes = {
  2430. event: propTypes.object.isRequired,
  2431. slotStart: propTypes.instanceOf(Date),
  2432. slotEnd: propTypes.instanceOf(Date),
  2433. selected: propTypes.bool,
  2434. isAllDay: propTypes.bool,
  2435. continuesPrior: propTypes.bool,
  2436. continuesAfter: propTypes.bool,
  2437. accessors: propTypes.object.isRequired,
  2438. components: propTypes.object.isRequired,
  2439. getters: propTypes.object.isRequired,
  2440. localizer: propTypes.object,
  2441. onSelect: propTypes.func,
  2442. onDoubleClick: propTypes.func
  2443. };
  2444. function isSelected(event, selected) {
  2445. if (!event || selected == null) return false;
  2446. return [].concat(selected).indexOf(event) !== -1;
  2447. }
  2448. function slotWidth(rowBox, slots) {
  2449. var rowWidth = rowBox.right - rowBox.left;
  2450. var cellWidth = rowWidth / slots;
  2451. return cellWidth;
  2452. }
  2453. function getSlotAtX(rowBox, x, rtl, slots) {
  2454. var cellWidth = slotWidth(rowBox, slots);
  2455. return rtl ? slots - 1 - Math.floor((x - rowBox.left) / cellWidth) : Math.floor((x - rowBox.left) / cellWidth);
  2456. }
  2457. function pointInBox(box, _ref) {
  2458. var x = _ref.x,
  2459. y = _ref.y;
  2460. return y >= box.top && y <= box.bottom && x >= box.left && x <= box.right;
  2461. }
  2462. function dateCellSelection(start, rowBox, box, slots, rtl) {
  2463. var startIdx = -1;
  2464. var endIdx = -1;
  2465. var lastSlotIdx = slots - 1;
  2466. var cellWidth = slotWidth(rowBox, slots); // cell under the mouse
  2467. var currentSlot = getSlotAtX(rowBox, box.x, rtl, slots); // Identify row as either the initial row
  2468. // or the row under the current mouse point
  2469. var isCurrentRow = rowBox.top < box.y && rowBox.bottom > box.y;
  2470. var isStartRow = rowBox.top < start.y && rowBox.bottom > start.y; // this row's position relative to the start point
  2471. var isAboveStart = start.y > rowBox.bottom;
  2472. var isBelowStart = rowBox.top > start.y;
  2473. var isBetween = box.top < rowBox.top && box.bottom > rowBox.bottom; // this row is between the current and start rows, so entirely selected
  2474. if (isBetween) {
  2475. startIdx = 0;
  2476. endIdx = lastSlotIdx;
  2477. }
  2478. if (isCurrentRow) {
  2479. if (isBelowStart) {
  2480. startIdx = 0;
  2481. endIdx = currentSlot;
  2482. } else if (isAboveStart) {
  2483. startIdx = currentSlot;
  2484. endIdx = lastSlotIdx;
  2485. }
  2486. }
  2487. if (isStartRow) {
  2488. // select the cell under the initial point
  2489. startIdx = endIdx = rtl ? lastSlotIdx - Math.floor((start.x - rowBox.left) / cellWidth) : Math.floor((start.x - rowBox.left) / cellWidth);
  2490. if (isCurrentRow) {
  2491. if (currentSlot < startIdx) startIdx = currentSlot;else endIdx = currentSlot; //select current range
  2492. } else if (start.y < box.y) {
  2493. // the current row is below start row
  2494. // select cells to the right of the start cell
  2495. endIdx = lastSlotIdx;
  2496. } else {
  2497. // select cells to the left of the start cell
  2498. startIdx = 0;
  2499. }
  2500. }
  2501. return {
  2502. startIdx: startIdx,
  2503. endIdx: endIdx
  2504. };
  2505. }
  2506. var Popup =
  2507. /*#__PURE__*/
  2508. function (_React$Component) {
  2509. _inheritsLoose(Popup, _React$Component);
  2510. function Popup() {
  2511. return _React$Component.apply(this, arguments) || this;
  2512. }
  2513. var _proto = Popup.prototype;
  2514. _proto.componentDidMount = function componentDidMount() {
  2515. var _this$props = this.props,
  2516. _this$props$popupOffs = _this$props.popupOffset,
  2517. popupOffset = _this$props$popupOffs === void 0 ? 5 : _this$props$popupOffs,
  2518. popperRef = _this$props.popperRef,
  2519. _getOffset = offset(popperRef.current),
  2520. top = _getOffset.top,
  2521. left = _getOffset.left,
  2522. width = _getOffset.width,
  2523. height = _getOffset.height,
  2524. viewBottom = window.innerHeight + getScrollTop(window),
  2525. viewRight = window.innerWidth + getScrollLeft(window),
  2526. bottom = top + height,
  2527. right = left + width;
  2528. if (bottom > viewBottom || right > viewRight) {
  2529. var topOffset, leftOffset;
  2530. if (bottom > viewBottom) topOffset = bottom - viewBottom + (popupOffset.y || +popupOffset || 0);
  2531. if (right > viewRight) leftOffset = right - viewRight + (popupOffset.x || +popupOffset || 0);
  2532. this.setState({
  2533. topOffset: topOffset,
  2534. leftOffset: leftOffset
  2535. }); //eslint-disable-line
  2536. }
  2537. };
  2538. _proto.render = function render() {
  2539. var _this$props2 = this.props,
  2540. events = _this$props2.events,
  2541. selected = _this$props2.selected,
  2542. getters = _this$props2.getters,
  2543. accessors = _this$props2.accessors,
  2544. components = _this$props2.components,
  2545. onSelect = _this$props2.onSelect,
  2546. onDoubleClick = _this$props2.onDoubleClick,
  2547. slotStart = _this$props2.slotStart,
  2548. slotEnd = _this$props2.slotEnd,
  2549. localizer = _this$props2.localizer,
  2550. popperRef = _this$props2.popperRef;
  2551. var width = this.props.position.width,
  2552. topOffset = (this.state || {}).topOffset || 0,
  2553. leftOffset = (this.state || {}).leftOffset || 0;
  2554. var style = {
  2555. top: -topOffset,
  2556. left: -leftOffset,
  2557. minWidth: width + width / 2
  2558. };
  2559. return React__default.createElement("div", {
  2560. style: _extends({}, this.props.style, style),
  2561. className: "rbc-overlay",
  2562. ref: popperRef
  2563. }, React__default.createElement("div", {
  2564. className: "rbc-overlay-header"
  2565. }, localizer.format(slotStart, 'dayHeaderFormat')), events.map(function (event, idx) {
  2566. return React__default.createElement(EventCell, {
  2567. key: idx,
  2568. type: "popup",
  2569. event: event,
  2570. getters: getters,
  2571. onSelect: onSelect,
  2572. accessors: accessors,
  2573. components: components,
  2574. onDoubleClick: onDoubleClick,
  2575. continuesPrior: lt(accessors.end(event), slotStart, 'day'),
  2576. continuesAfter: gte(accessors.start(event), slotEnd, 'day'),
  2577. slotStart: slotStart,
  2578. slotEnd: slotEnd,
  2579. selected: isSelected(event, selected)
  2580. });
  2581. }));
  2582. };
  2583. return Popup;
  2584. }(React__default.Component);
  2585. Popup.propTypes = {
  2586. position: propTypes.object,
  2587. popupOffset: propTypes.oneOfType([propTypes.number, propTypes.shape({
  2588. x: propTypes.number,
  2589. y: propTypes.number
  2590. })]),
  2591. events: propTypes.array,
  2592. selected: propTypes.object,
  2593. accessors: propTypes.object.isRequired,
  2594. components: propTypes.object.isRequired,
  2595. getters: propTypes.object.isRequired,
  2596. localizer: propTypes.object.isRequired,
  2597. onSelect: propTypes.func,
  2598. onDoubleClick: propTypes.func,
  2599. slotStart: propTypes.instanceOf(Date),
  2600. slotEnd: propTypes.number,
  2601. popperRef: propTypes.oneOfType([propTypes.func, propTypes.shape({
  2602. current: propTypes.Element
  2603. })])
  2604. /**
  2605. * The Overlay component, of react-overlays, creates a ref that is passed to the Popup, and
  2606. * requires proper ref forwarding to be used without error
  2607. */
  2608. };
  2609. var Popup$1 = React__default.forwardRef(function (props, ref) {
  2610. return React__default.createElement(Popup, _extends({
  2611. popperRef: ref
  2612. }, props));
  2613. });
  2614. function _extends$3() {
  2615. _extends$3 = Object.assign || function (target) {
  2616. for (var i = 1; i < arguments.length; i++) {
  2617. var source = arguments[i];
  2618. for (var key in source) {
  2619. if (Object.prototype.hasOwnProperty.call(source, key)) {
  2620. target[key] = source[key];
  2621. }
  2622. }
  2623. }
  2624. return target;
  2625. };
  2626. return _extends$3.apply(this, arguments);
  2627. }
  2628. function _objectWithoutPropertiesLoose$2(source, excluded) {
  2629. if (source == null) return {};
  2630. var target = {};
  2631. var sourceKeys = Object.keys(source);
  2632. var key, i;
  2633. for (i = 0; i < sourceKeys.length; i++) {
  2634. key = sourceKeys[i];
  2635. if (excluded.indexOf(key) >= 0) continue;
  2636. target[key] = source[key];
  2637. }
  2638. return target;
  2639. }
  2640. /**!
  2641. * @fileOverview Kickass library to create and place poppers near their reference elements.
  2642. * @version 1.15.0
  2643. * @license
  2644. * Copyright (c) 2016 Federico Zivolo and contributors
  2645. *
  2646. * Permission is hereby granted, free of charge, to any person obtaining a copy
  2647. * of this software and associated documentation files (the "Software"), to deal
  2648. * in the Software without restriction, including without limitation the rights
  2649. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  2650. * copies of the Software, and to permit persons to whom the Software is
  2651. * furnished to do so, subject to the following conditions:
  2652. *
  2653. * The above copyright notice and this permission notice shall be included in all
  2654. * copies or substantial portions of the Software.
  2655. *
  2656. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2657. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2658. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2659. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2660. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2661. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  2662. * SOFTWARE.
  2663. */
  2664. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
  2665. var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox'];
  2666. var timeoutDuration = 0;
  2667. for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) {
  2668. if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
  2669. timeoutDuration = 1;
  2670. break;
  2671. }
  2672. }
  2673. function microtaskDebounce(fn) {
  2674. var called = false;
  2675. return function () {
  2676. if (called) {
  2677. return;
  2678. }
  2679. called = true;
  2680. window.Promise.resolve().then(function () {
  2681. called = false;
  2682. fn();
  2683. });
  2684. };
  2685. }
  2686. function taskDebounce(fn) {
  2687. var scheduled = false;
  2688. return function () {
  2689. if (!scheduled) {
  2690. scheduled = true;
  2691. setTimeout(function () {
  2692. scheduled = false;
  2693. fn();
  2694. }, timeoutDuration);
  2695. }
  2696. };
  2697. }
  2698. var supportsMicroTasks = isBrowser && window.Promise;
  2699. /**
  2700. * Create a debounced version of a method, that's asynchronously deferred
  2701. * but called in the minimum time possible.
  2702. *
  2703. * @method
  2704. * @memberof Popper.Utils
  2705. * @argument {Function} fn
  2706. * @returns {Function}
  2707. */
  2708. var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce;
  2709. /**
  2710. * Check if the given variable is a function
  2711. * @method
  2712. * @memberof Popper.Utils
  2713. * @argument {Any} functionToCheck - variable to check
  2714. * @returns {Boolean} answer to: is a function?
  2715. */
  2716. function isFunction$1(functionToCheck) {
  2717. var getType = {};
  2718. return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
  2719. }
  2720. /**
  2721. * Get CSS computed property of the given element
  2722. * @method
  2723. * @memberof Popper.Utils
  2724. * @argument {Eement} element
  2725. * @argument {String} property
  2726. */
  2727. function getStyleComputedProperty(element, property) {
  2728. if (element.nodeType !== 1) {
  2729. return [];
  2730. }
  2731. // NOTE: 1 DOM access here
  2732. var window = element.ownerDocument.defaultView;
  2733. var css = window.getComputedStyle(element, null);
  2734. return property ? css[property] : css;
  2735. }
  2736. /**
  2737. * Returns the parentNode or the host of the element
  2738. * @method
  2739. * @memberof Popper.Utils
  2740. * @argument {Element} element
  2741. * @returns {Element} parent
  2742. */
  2743. function getParentNode(element) {
  2744. if (element.nodeName === 'HTML') {
  2745. return element;
  2746. }
  2747. return element.parentNode || element.host;
  2748. }
  2749. /**
  2750. * Returns the scrolling parent of the given element
  2751. * @method
  2752. * @memberof Popper.Utils
  2753. * @argument {Element} element
  2754. * @returns {Element} scroll parent
  2755. */
  2756. function getScrollParent(element) {
  2757. // Return body, `getScroll` will take care to get the correct `scrollTop` from it
  2758. if (!element) {
  2759. return document.body;
  2760. }
  2761. switch (element.nodeName) {
  2762. case 'HTML':
  2763. case 'BODY':
  2764. return element.ownerDocument.body;
  2765. case '#document':
  2766. return element.body;
  2767. }
  2768. // Firefox want us to check `-x` and `-y` variations as well
  2769. var _getStyleComputedProp = getStyleComputedProperty(element),
  2770. overflow = _getStyleComputedProp.overflow,
  2771. overflowX = _getStyleComputedProp.overflowX,
  2772. overflowY = _getStyleComputedProp.overflowY;
  2773. if (/(auto|scroll|overlay)/.test(overflow + overflowY + overflowX)) {
  2774. return element;
  2775. }
  2776. return getScrollParent(getParentNode(element));
  2777. }
  2778. var isIE11 = isBrowser && !!(window.MSInputMethodContext && document.documentMode);
  2779. var isIE10 = isBrowser && /MSIE 10/.test(navigator.userAgent);
  2780. /**
  2781. * Determines if the browser is Internet Explorer
  2782. * @method
  2783. * @memberof Popper.Utils
  2784. * @param {Number} version to check
  2785. * @returns {Boolean} isIE
  2786. */
  2787. function isIE(version) {
  2788. if (version === 11) {
  2789. return isIE11;
  2790. }
  2791. if (version === 10) {
  2792. return isIE10;
  2793. }
  2794. return isIE11 || isIE10;
  2795. }
  2796. /**
  2797. * Returns the offset parent of the given element
  2798. * @method
  2799. * @memberof Popper.Utils
  2800. * @argument {Element} element
  2801. * @returns {Element} offset parent
  2802. */
  2803. function getOffsetParent(element) {
  2804. if (!element) {
  2805. return document.documentElement;
  2806. }
  2807. var noOffsetParent = isIE(10) ? document.body : null;
  2808. // NOTE: 1 DOM access here
  2809. var offsetParent = element.offsetParent || null;
  2810. // Skip hidden elements which don't have an offsetParent
  2811. while (offsetParent === noOffsetParent && element.nextElementSibling) {
  2812. offsetParent = (element = element.nextElementSibling).offsetParent;
  2813. }
  2814. var nodeName = offsetParent && offsetParent.nodeName;
  2815. if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') {
  2816. return element ? element.ownerDocument.documentElement : document.documentElement;
  2817. }
  2818. // .offsetParent will return the closest TH, TD or TABLE in case
  2819. // no offsetParent is present, I hate this job...
  2820. if (['TH', 'TD', 'TABLE'].indexOf(offsetParent.nodeName) !== -1 && getStyleComputedProperty(offsetParent, 'position') === 'static') {
  2821. return getOffsetParent(offsetParent);
  2822. }
  2823. return offsetParent;
  2824. }
  2825. function isOffsetContainer(element) {
  2826. var nodeName = element.nodeName;
  2827. if (nodeName === 'BODY') {
  2828. return false;
  2829. }
  2830. return nodeName === 'HTML' || getOffsetParent(element.firstElementChild) === element;
  2831. }
  2832. /**
  2833. * Finds the root node (document, shadowDOM root) of the given element
  2834. * @method
  2835. * @memberof Popper.Utils
  2836. * @argument {Element} node
  2837. * @returns {Element} root node
  2838. */
  2839. function getRoot(node) {
  2840. if (node.parentNode !== null) {
  2841. return getRoot(node.parentNode);
  2842. }
  2843. return node;
  2844. }
  2845. /**
  2846. * Finds the offset parent common to the two provided nodes
  2847. * @method
  2848. * @memberof Popper.Utils
  2849. * @argument {Element} element1
  2850. * @argument {Element} element2
  2851. * @returns {Element} common offset parent
  2852. */
  2853. function findCommonOffsetParent(element1, element2) {
  2854. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  2855. if (!element1 || !element1.nodeType || !element2 || !element2.nodeType) {
  2856. return document.documentElement;
  2857. }
  2858. // Here we make sure to give as "start" the element that comes first in the DOM
  2859. var order = element1.compareDocumentPosition(element2) & Node.DOCUMENT_POSITION_FOLLOWING;
  2860. var start = order ? element1 : element2;
  2861. var end = order ? element2 : element1;
  2862. // Get common ancestor container
  2863. var range = document.createRange();
  2864. range.setStart(start, 0);
  2865. range.setEnd(end, 0);
  2866. var commonAncestorContainer = range.commonAncestorContainer;
  2867. // Both nodes are inside #document
  2868. if (element1 !== commonAncestorContainer && element2 !== commonAncestorContainer || start.contains(end)) {
  2869. if (isOffsetContainer(commonAncestorContainer)) {
  2870. return commonAncestorContainer;
  2871. }
  2872. return getOffsetParent(commonAncestorContainer);
  2873. }
  2874. // one of the nodes is inside shadowDOM, find which one
  2875. var element1root = getRoot(element1);
  2876. if (element1root.host) {
  2877. return findCommonOffsetParent(element1root.host, element2);
  2878. } else {
  2879. return findCommonOffsetParent(element1, getRoot(element2).host);
  2880. }
  2881. }
  2882. /**
  2883. * Gets the scroll value of the given element in the given side (top and left)
  2884. * @method
  2885. * @memberof Popper.Utils
  2886. * @argument {Element} element
  2887. * @argument {String} side `top` or `left`
  2888. * @returns {number} amount of scrolled pixels
  2889. */
  2890. function getScroll(element) {
  2891. var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top';
  2892. var upperSide = side === 'top' ? 'scrollTop' : 'scrollLeft';
  2893. var nodeName = element.nodeName;
  2894. if (nodeName === 'BODY' || nodeName === 'HTML') {
  2895. var html = element.ownerDocument.documentElement;
  2896. var scrollingElement = element.ownerDocument.scrollingElement || html;
  2897. return scrollingElement[upperSide];
  2898. }
  2899. return element[upperSide];
  2900. }
  2901. /*
  2902. * Sum or subtract the element scroll values (left and top) from a given rect object
  2903. * @method
  2904. * @memberof Popper.Utils
  2905. * @param {Object} rect - Rect object you want to change
  2906. * @param {HTMLElement} element - The element from the function reads the scroll values
  2907. * @param {Boolean} subtract - set to true if you want to subtract the scroll values
  2908. * @return {Object} rect - The modifier rect object
  2909. */
  2910. function includeScroll(rect, element) {
  2911. var subtract = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  2912. var scrollTop = getScroll(element, 'top');
  2913. var scrollLeft = getScroll(element, 'left');
  2914. var modifier = subtract ? -1 : 1;
  2915. rect.top += scrollTop * modifier;
  2916. rect.bottom += scrollTop * modifier;
  2917. rect.left += scrollLeft * modifier;
  2918. rect.right += scrollLeft * modifier;
  2919. return rect;
  2920. }
  2921. /*
  2922. * Helper to detect borders of a given element
  2923. * @method
  2924. * @memberof Popper.Utils
  2925. * @param {CSSStyleDeclaration} styles
  2926. * Result of `getStyleComputedProperty` on the given element
  2927. * @param {String} axis - `x` or `y`
  2928. * @return {number} borders - The borders size of the given axis
  2929. */
  2930. function getBordersSize(styles, axis) {
  2931. var sideA = axis === 'x' ? 'Left' : 'Top';
  2932. var sideB = sideA === 'Left' ? 'Right' : 'Bottom';
  2933. return parseFloat(styles['border' + sideA + 'Width'], 10) + parseFloat(styles['border' + sideB + 'Width'], 10);
  2934. }
  2935. function getSize(axis, body, html, computedStyle) {
  2936. 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);
  2937. }
  2938. function getWindowSizes(document) {
  2939. var body = document.body;
  2940. var html = document.documentElement;
  2941. var computedStyle = isIE(10) && getComputedStyle(html);
  2942. return {
  2943. height: getSize('Height', body, html, computedStyle),
  2944. width: getSize('Width', body, html, computedStyle)
  2945. };
  2946. }
  2947. var classCallCheck = function (instance, Constructor) {
  2948. if (!(instance instanceof Constructor)) {
  2949. throw new TypeError("Cannot call a class as a function");
  2950. }
  2951. };
  2952. var createClass = function () {
  2953. function defineProperties(target, props) {
  2954. for (var i = 0; i < props.length; i++) {
  2955. var descriptor = props[i];
  2956. descriptor.enumerable = descriptor.enumerable || false;
  2957. descriptor.configurable = true;
  2958. if ("value" in descriptor) descriptor.writable = true;
  2959. Object.defineProperty(target, descriptor.key, descriptor);
  2960. }
  2961. }
  2962. return function (Constructor, protoProps, staticProps) {
  2963. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  2964. if (staticProps) defineProperties(Constructor, staticProps);
  2965. return Constructor;
  2966. };
  2967. }();
  2968. var defineProperty = function (obj, key, value) {
  2969. if (key in obj) {
  2970. Object.defineProperty(obj, key, {
  2971. value: value,
  2972. enumerable: true,
  2973. configurable: true,
  2974. writable: true
  2975. });
  2976. } else {
  2977. obj[key] = value;
  2978. }
  2979. return obj;
  2980. };
  2981. var _extends$4 = Object.assign || function (target) {
  2982. for (var i = 1; i < arguments.length; i++) {
  2983. var source = arguments[i];
  2984. for (var key in source) {
  2985. if (Object.prototype.hasOwnProperty.call(source, key)) {
  2986. target[key] = source[key];
  2987. }
  2988. }
  2989. }
  2990. return target;
  2991. };
  2992. /**
  2993. * Given element offsets, generate an output similar to getBoundingClientRect
  2994. * @method
  2995. * @memberof Popper.Utils
  2996. * @argument {Object} offsets
  2997. * @returns {Object} ClientRect like output
  2998. */
  2999. function getClientRect(offsets) {
  3000. return _extends$4({}, offsets, {
  3001. right: offsets.left + offsets.width,
  3002. bottom: offsets.top + offsets.height
  3003. });
  3004. }
  3005. /**
  3006. * Get bounding client rect of given element
  3007. * @method
  3008. * @memberof Popper.Utils
  3009. * @param {HTMLElement} element
  3010. * @return {Object} client rect
  3011. */
  3012. function getBoundingClientRect(element) {
  3013. var rect = {};
  3014. // IE10 10 FIX: Please, don't ask, the element isn't
  3015. // considered in DOM in some circumstances...
  3016. // This isn't reproducible in IE10 compatibility mode of IE11
  3017. try {
  3018. if (isIE(10)) {
  3019. rect = element.getBoundingClientRect();
  3020. var scrollTop = getScroll(element, 'top');
  3021. var scrollLeft = getScroll(element, 'left');
  3022. rect.top += scrollTop;
  3023. rect.left += scrollLeft;
  3024. rect.bottom += scrollTop;
  3025. rect.right += scrollLeft;
  3026. } else {
  3027. rect = element.getBoundingClientRect();
  3028. }
  3029. } catch (e) {}
  3030. var result = {
  3031. left: rect.left,
  3032. top: rect.top,
  3033. width: rect.right - rect.left,
  3034. height: rect.bottom - rect.top
  3035. };
  3036. // subtract scrollbar size from sizes
  3037. var sizes = element.nodeName === 'HTML' ? getWindowSizes(element.ownerDocument) : {};
  3038. var width = sizes.width || element.clientWidth || result.right - result.left;
  3039. var height = sizes.height || element.clientHeight || result.bottom - result.top;
  3040. var horizScrollbar = element.offsetWidth - width;
  3041. var vertScrollbar = element.offsetHeight - height;
  3042. // if an hypothetical scrollbar is detected, we must be sure it's not a `border`
  3043. // we make this check conditional for performance reasons
  3044. if (horizScrollbar || vertScrollbar) {
  3045. var styles = getStyleComputedProperty(element);
  3046. horizScrollbar -= getBordersSize(styles, 'x');
  3047. vertScrollbar -= getBordersSize(styles, 'y');
  3048. result.width -= horizScrollbar;
  3049. result.height -= vertScrollbar;
  3050. }
  3051. return getClientRect(result);
  3052. }
  3053. function getOffsetRectRelativeToArbitraryNode(children, parent) {
  3054. var fixedPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  3055. var isIE10 = isIE(10);
  3056. var isHTML = parent.nodeName === 'HTML';
  3057. var childrenRect = getBoundingClientRect(children);
  3058. var parentRect = getBoundingClientRect(parent);
  3059. var scrollParent = getScrollParent(children);
  3060. var styles = getStyleComputedProperty(parent);
  3061. var borderTopWidth = parseFloat(styles.borderTopWidth, 10);
  3062. var borderLeftWidth = parseFloat(styles.borderLeftWidth, 10);
  3063. // In cases where the parent is fixed, we must ignore negative scroll in offset calc
  3064. if (fixedPosition && isHTML) {
  3065. parentRect.top = Math.max(parentRect.top, 0);
  3066. parentRect.left = Math.max(parentRect.left, 0);
  3067. }
  3068. var offsets = getClientRect({
  3069. top: childrenRect.top - parentRect.top - borderTopWidth,
  3070. left: childrenRect.left - parentRect.left - borderLeftWidth,
  3071. width: childrenRect.width,
  3072. height: childrenRect.height
  3073. });
  3074. offsets.marginTop = 0;
  3075. offsets.marginLeft = 0;
  3076. // Subtract margins of documentElement in case it's being used as parent
  3077. // we do this only on HTML because it's the only element that behaves
  3078. // differently when margins are applied to it. The margins are included in
  3079. // the box of the documentElement, in the other cases not.
  3080. if (!isIE10 && isHTML) {
  3081. var marginTop = parseFloat(styles.marginTop, 10);
  3082. var marginLeft = parseFloat(styles.marginLeft, 10);
  3083. offsets.top -= borderTopWidth - marginTop;
  3084. offsets.bottom -= borderTopWidth - marginTop;
  3085. offsets.left -= borderLeftWidth - marginLeft;
  3086. offsets.right -= borderLeftWidth - marginLeft;
  3087. // Attach marginTop and marginLeft because in some circumstances we may need them
  3088. offsets.marginTop = marginTop;
  3089. offsets.marginLeft = marginLeft;
  3090. }
  3091. if (isIE10 && !fixedPosition ? parent.contains(scrollParent) : parent === scrollParent && scrollParent.nodeName !== 'BODY') {
  3092. offsets = includeScroll(offsets, parent);
  3093. }
  3094. return offsets;
  3095. }
  3096. function getViewportOffsetRectRelativeToArtbitraryNode(element) {
  3097. var excludeScroll = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  3098. var html = element.ownerDocument.documentElement;
  3099. var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html);
  3100. var width = Math.max(html.clientWidth, window.innerWidth || 0);
  3101. var height = Math.max(html.clientHeight, window.innerHeight || 0);
  3102. var scrollTop = !excludeScroll ? getScroll(html) : 0;
  3103. var scrollLeft = !excludeScroll ? getScroll(html, 'left') : 0;
  3104. var offset = {
  3105. top: scrollTop - relativeOffset.top + relativeOffset.marginTop,
  3106. left: scrollLeft - relativeOffset.left + relativeOffset.marginLeft,
  3107. width: width,
  3108. height: height
  3109. };
  3110. return getClientRect(offset);
  3111. }
  3112. /**
  3113. * Check if the given element is fixed or is inside a fixed parent
  3114. * @method
  3115. * @memberof Popper.Utils
  3116. * @argument {Element} element
  3117. * @argument {Element} customContainer
  3118. * @returns {Boolean} answer to "isFixed?"
  3119. */
  3120. function isFixed(element) {
  3121. var nodeName = element.nodeName;
  3122. if (nodeName === 'BODY' || nodeName === 'HTML') {
  3123. return false;
  3124. }
  3125. if (getStyleComputedProperty(element, 'position') === 'fixed') {
  3126. return true;
  3127. }
  3128. var parentNode = getParentNode(element);
  3129. if (!parentNode) {
  3130. return false;
  3131. }
  3132. return isFixed(parentNode);
  3133. }
  3134. /**
  3135. * Finds the first parent of an element that has a transformed property defined
  3136. * @method
  3137. * @memberof Popper.Utils
  3138. * @argument {Element} element
  3139. * @returns {Element} first transformed parent or documentElement
  3140. */
  3141. function getFixedPositionOffsetParent(element) {
  3142. // This check is needed to avoid errors in case one of the elements isn't defined for any reason
  3143. if (!element || !element.parentElement || isIE()) {
  3144. return document.documentElement;
  3145. }
  3146. var el = element.parentElement;
  3147. while (el && getStyleComputedProperty(el, 'transform') === 'none') {
  3148. el = el.parentElement;
  3149. }
  3150. return el || document.documentElement;
  3151. }
  3152. /**
  3153. * Computed the boundaries limits and return them
  3154. * @method
  3155. * @memberof Popper.Utils
  3156. * @param {HTMLElement} popper
  3157. * @param {HTMLElement} reference
  3158. * @param {number} padding
  3159. * @param {HTMLElement} boundariesElement - Element used to define the boundaries
  3160. * @param {Boolean} fixedPosition - Is in fixed position mode
  3161. * @returns {Object} Coordinates of the boundaries
  3162. */
  3163. function getBoundaries(popper, reference, padding, boundariesElement) {
  3164. var fixedPosition = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
  3165. // NOTE: 1 DOM access here
  3166. var boundaries = { top: 0, left: 0 };
  3167. var offsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
  3168. // Handle viewport case
  3169. if (boundariesElement === 'viewport') {
  3170. boundaries = getViewportOffsetRectRelativeToArtbitraryNode(offsetParent, fixedPosition);
  3171. } else {
  3172. // Handle other cases based on DOM element used as boundaries
  3173. var boundariesNode = void 0;
  3174. if (boundariesElement === 'scrollParent') {
  3175. boundariesNode = getScrollParent(getParentNode(reference));
  3176. if (boundariesNode.nodeName === 'BODY') {
  3177. boundariesNode = popper.ownerDocument.documentElement;
  3178. }
  3179. } else if (boundariesElement === 'window') {
  3180. boundariesNode = popper.ownerDocument.documentElement;
  3181. } else {
  3182. boundariesNode = boundariesElement;
  3183. }
  3184. var offsets = getOffsetRectRelativeToArbitraryNode(boundariesNode, offsetParent, fixedPosition);
  3185. // In case of HTML, we need a different computation
  3186. if (boundariesNode.nodeName === 'HTML' && !isFixed(offsetParent)) {
  3187. var _getWindowSizes = getWindowSizes(popper.ownerDocument),
  3188. height = _getWindowSizes.height,
  3189. width = _getWindowSizes.width;
  3190. boundaries.top += offsets.top - offsets.marginTop;
  3191. boundaries.bottom = height + offsets.top;
  3192. boundaries.left += offsets.left - offsets.marginLeft;
  3193. boundaries.right = width + offsets.left;
  3194. } else {
  3195. // for all the other DOM elements, this one is good
  3196. boundaries = offsets;
  3197. }
  3198. }
  3199. // Add paddings
  3200. padding = padding || 0;
  3201. var isPaddingNumber = typeof padding === 'number';
  3202. boundaries.left += isPaddingNumber ? padding : padding.left || 0;
  3203. boundaries.top += isPaddingNumber ? padding : padding.top || 0;
  3204. boundaries.right -= isPaddingNumber ? padding : padding.right || 0;
  3205. boundaries.bottom -= isPaddingNumber ? padding : padding.bottom || 0;
  3206. return boundaries;
  3207. }
  3208. function getArea(_ref) {
  3209. var width = _ref.width,
  3210. height = _ref.height;
  3211. return width * height;
  3212. }
  3213. /**
  3214. * Utility used to transform the `auto` placement to the placement with more
  3215. * available space.
  3216. * @method
  3217. * @memberof Popper.Utils
  3218. * @argument {Object} data - The data object generated by update method
  3219. * @argument {Object} options - Modifiers configuration and options
  3220. * @returns {Object} The data object, properly modified
  3221. */
  3222. function computeAutoPlacement(placement, refRect, popper, reference, boundariesElement) {
  3223. var padding = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
  3224. if (placement.indexOf('auto') === -1) {
  3225. return placement;
  3226. }
  3227. var boundaries = getBoundaries(popper, reference, padding, boundariesElement);
  3228. var rects = {
  3229. top: {
  3230. width: boundaries.width,
  3231. height: refRect.top - boundaries.top
  3232. },
  3233. right: {
  3234. width: boundaries.right - refRect.right,
  3235. height: boundaries.height
  3236. },
  3237. bottom: {
  3238. width: boundaries.width,
  3239. height: boundaries.bottom - refRect.bottom
  3240. },
  3241. left: {
  3242. width: refRect.left - boundaries.left,
  3243. height: boundaries.height
  3244. }
  3245. };
  3246. var sortedAreas = Object.keys(rects).map(function (key) {
  3247. return _extends$4({
  3248. key: key
  3249. }, rects[key], {
  3250. area: getArea(rects[key])
  3251. });
  3252. }).sort(function (a, b) {
  3253. return b.area - a.area;
  3254. });
  3255. var filteredAreas = sortedAreas.filter(function (_ref2) {
  3256. var width = _ref2.width,
  3257. height = _ref2.height;
  3258. return width >= popper.clientWidth && height >= popper.clientHeight;
  3259. });
  3260. var computedPlacement = filteredAreas.length > 0 ? filteredAreas[0].key : sortedAreas[0].key;
  3261. var variation = placement.split('-')[1];
  3262. return computedPlacement + (variation ? '-' + variation : '');
  3263. }
  3264. /**
  3265. * Get offsets to the reference element
  3266. * @method
  3267. * @memberof Popper.Utils
  3268. * @param {Object} state
  3269. * @param {Element} popper - the popper element
  3270. * @param {Element} reference - the reference element (the popper will be relative to this)
  3271. * @param {Element} fixedPosition - is in fixed position mode
  3272. * @returns {Object} An object containing the offsets which will be applied to the popper
  3273. */
  3274. function getReferenceOffsets(state, popper, reference) {
  3275. var fixedPosition = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  3276. var commonOffsetParent = fixedPosition ? getFixedPositionOffsetParent(popper) : findCommonOffsetParent(popper, reference);
  3277. return getOffsetRectRelativeToArbitraryNode(reference, commonOffsetParent, fixedPosition);
  3278. }
  3279. /**
  3280. * Get the outer sizes of the given element (offset size + margins)
  3281. * @method
  3282. * @memberof Popper.Utils
  3283. * @argument {Element} element
  3284. * @returns {Object} object containing width and height properties
  3285. */
  3286. function getOuterSizes(element) {
  3287. var window = element.ownerDocument.defaultView;
  3288. var styles = window.getComputedStyle(element);
  3289. var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
  3290. var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
  3291. var result = {
  3292. width: element.offsetWidth + y,
  3293. height: element.offsetHeight + x
  3294. };
  3295. return result;
  3296. }
  3297. /**
  3298. * Get the opposite placement of the given one
  3299. * @method
  3300. * @memberof Popper.Utils
  3301. * @argument {String} placement
  3302. * @returns {String} flipped placement
  3303. */
  3304. function getOppositePlacement(placement) {
  3305. var hash = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' };
  3306. return placement.replace(/left|right|bottom|top/g, function (matched) {
  3307. return hash[matched];
  3308. });
  3309. }
  3310. /**
  3311. * Get offsets to the popper
  3312. * @method
  3313. * @memberof Popper.Utils
  3314. * @param {Object} position - CSS position the Popper will get applied
  3315. * @param {HTMLElement} popper - the popper element
  3316. * @param {Object} referenceOffsets - the reference offsets (the popper will be relative to this)
  3317. * @param {String} placement - one of the valid placement options
  3318. * @returns {Object} popperOffsets - An object containing the offsets which will be applied to the popper
  3319. */
  3320. function getPopperOffsets(popper, referenceOffsets, placement) {
  3321. placement = placement.split('-')[0];
  3322. // Get popper node sizes
  3323. var popperRect = getOuterSizes(popper);
  3324. // Add position, width and height to our offsets object
  3325. var popperOffsets = {
  3326. width: popperRect.width,
  3327. height: popperRect.height
  3328. };
  3329. // depending by the popper placement we have to compute its offsets slightly differently
  3330. var isHoriz = ['right', 'left'].indexOf(placement) !== -1;
  3331. var mainSide = isHoriz ? 'top' : 'left';
  3332. var secondarySide = isHoriz ? 'left' : 'top';
  3333. var measurement = isHoriz ? 'height' : 'width';
  3334. var secondaryMeasurement = !isHoriz ? 'height' : 'width';
  3335. popperOffsets[mainSide] = referenceOffsets[mainSide] + referenceOffsets[measurement] / 2 - popperRect[measurement] / 2;
  3336. if (placement === secondarySide) {
  3337. popperOffsets[secondarySide] = referenceOffsets[secondarySide] - popperRect[secondaryMeasurement];
  3338. } else {
  3339. popperOffsets[secondarySide] = referenceOffsets[getOppositePlacement(secondarySide)];
  3340. }
  3341. return popperOffsets;
  3342. }
  3343. /**
  3344. * Mimics the `find` method of Array
  3345. * @method
  3346. * @memberof Popper.Utils
  3347. * @argument {Array} arr
  3348. * @argument prop
  3349. * @argument value
  3350. * @returns index or -1
  3351. */
  3352. function find(arr, check) {
  3353. // use native find if supported
  3354. if (Array.prototype.find) {
  3355. return arr.find(check);
  3356. }
  3357. // use `filter` to obtain the same behavior of `find`
  3358. return arr.filter(check)[0];
  3359. }
  3360. /**
  3361. * Return the index of the matching object
  3362. * @method
  3363. * @memberof Popper.Utils
  3364. * @argument {Array} arr
  3365. * @argument prop
  3366. * @argument value
  3367. * @returns index or -1
  3368. */
  3369. function findIndex(arr, prop, value) {
  3370. // use native findIndex if supported
  3371. if (Array.prototype.findIndex) {
  3372. return arr.findIndex(function (cur) {
  3373. return cur[prop] === value;
  3374. });
  3375. }
  3376. // use `find` + `indexOf` if `findIndex` isn't supported
  3377. var match = find(arr, function (obj) {
  3378. return obj[prop] === value;
  3379. });
  3380. return arr.indexOf(match);
  3381. }
  3382. /**
  3383. * Loop trough the list of modifiers and run them in order,
  3384. * each of them will then edit the data object.
  3385. * @method
  3386. * @memberof Popper.Utils
  3387. * @param {dataObject} data
  3388. * @param {Array} modifiers
  3389. * @param {String} ends - Optional modifier name used as stopper
  3390. * @returns {dataObject}
  3391. */
  3392. function runModifiers(modifiers, data, ends) {
  3393. var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends));
  3394. modifiersToRun.forEach(function (modifier) {
  3395. if (modifier['function']) {
  3396. // eslint-disable-line dot-notation
  3397. console.warn('`modifier.function` is deprecated, use `modifier.fn`!');
  3398. }
  3399. var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation
  3400. if (modifier.enabled && isFunction$1(fn)) {
  3401. // Add properties to offsets to make them a complete clientRect object
  3402. // we do this before each modifier to make sure the previous one doesn't
  3403. // mess with these values
  3404. data.offsets.popper = getClientRect(data.offsets.popper);
  3405. data.offsets.reference = getClientRect(data.offsets.reference);
  3406. data = fn(data, modifier);
  3407. }
  3408. });
  3409. return data;
  3410. }
  3411. /**
  3412. * Updates the position of the popper, computing the new offsets and applying
  3413. * the new style.<br />
  3414. * Prefer `scheduleUpdate` over `update` because of performance reasons.
  3415. * @method
  3416. * @memberof Popper
  3417. */
  3418. function update() {
  3419. // if popper is destroyed, don't perform any further update
  3420. if (this.state.isDestroyed) {
  3421. return;
  3422. }
  3423. var data = {
  3424. instance: this,
  3425. styles: {},
  3426. arrowStyles: {},
  3427. attributes: {},
  3428. flipped: false,
  3429. offsets: {}
  3430. };
  3431. // compute reference element offsets
  3432. data.offsets.reference = getReferenceOffsets(this.state, this.popper, this.reference, this.options.positionFixed);
  3433. // compute auto placement, store placement inside the data object,
  3434. // modifiers will be able to edit `placement` if needed
  3435. // and refer to originalPlacement to know the original value
  3436. data.placement = computeAutoPlacement(this.options.placement, data.offsets.reference, this.popper, this.reference, this.options.modifiers.flip.boundariesElement, this.options.modifiers.flip.padding);
  3437. // store the computed placement inside `originalPlacement`
  3438. data.originalPlacement = data.placement;
  3439. data.positionFixed = this.options.positionFixed;
  3440. // compute the popper offsets
  3441. data.offsets.popper = getPopperOffsets(this.popper, data.offsets.reference, data.placement);
  3442. data.offsets.popper.position = this.options.positionFixed ? 'fixed' : 'absolute';
  3443. // run the modifiers
  3444. data = runModifiers(this.modifiers, data);
  3445. // the first `update` will call `onCreate` callback
  3446. // the other ones will call `onUpdate` callback
  3447. if (!this.state.isCreated) {
  3448. this.state.isCreated = true;
  3449. this.options.onCreate(data);
  3450. } else {
  3451. this.options.onUpdate(data);
  3452. }
  3453. }
  3454. /**
  3455. * Helper used to know if the given modifier is enabled.
  3456. * @method
  3457. * @memberof Popper.Utils
  3458. * @returns {Boolean}
  3459. */
  3460. function isModifierEnabled(modifiers, modifierName) {
  3461. return modifiers.some(function (_ref) {
  3462. var name = _ref.name,
  3463. enabled = _ref.enabled;
  3464. return enabled && name === modifierName;
  3465. });
  3466. }
  3467. /**
  3468. * Get the prefixed supported property name
  3469. * @method
  3470. * @memberof Popper.Utils
  3471. * @argument {String} property (camelCase)
  3472. * @returns {String} prefixed property (camelCase or PascalCase, depending on the vendor prefix)
  3473. */
  3474. function getSupportedPropertyName(property) {
  3475. var prefixes = [false, 'ms', 'Webkit', 'Moz', 'O'];
  3476. var upperProp = property.charAt(0).toUpperCase() + property.slice(1);
  3477. for (var i = 0; i < prefixes.length; i++) {
  3478. var prefix = prefixes[i];
  3479. var toCheck = prefix ? '' + prefix + upperProp : property;
  3480. if (typeof document.body.style[toCheck] !== 'undefined') {
  3481. return toCheck;
  3482. }
  3483. }
  3484. return null;
  3485. }
  3486. /**
  3487. * Destroys the popper.
  3488. * @method
  3489. * @memberof Popper
  3490. */
  3491. function destroy() {
  3492. this.state.isDestroyed = true;
  3493. // touch DOM only if `applyStyle` modifier is enabled
  3494. if (isModifierEnabled(this.modifiers, 'applyStyle')) {
  3495. this.popper.removeAttribute('x-placement');
  3496. this.popper.style.position = '';
  3497. this.popper.style.top = '';
  3498. this.popper.style.left = '';
  3499. this.popper.style.right = '';
  3500. this.popper.style.bottom = '';
  3501. this.popper.style.willChange = '';
  3502. this.popper.style[getSupportedPropertyName('transform')] = '';
  3503. }
  3504. this.disableEventListeners();
  3505. // remove the popper if user explicity asked for the deletion on destroy
  3506. // do not use `remove` because IE11 doesn't support it
  3507. if (this.options.removeOnDestroy) {
  3508. this.popper.parentNode.removeChild(this.popper);
  3509. }
  3510. return this;
  3511. }
  3512. /**
  3513. * Get the window associated with the element
  3514. * @argument {Element} element
  3515. * @returns {Window}
  3516. */
  3517. function getWindow(element) {
  3518. var ownerDocument = element.ownerDocument;
  3519. return ownerDocument ? ownerDocument.defaultView : window;
  3520. }
  3521. function attachToScrollParents(scrollParent, event, callback, scrollParents) {
  3522. var isBody = scrollParent.nodeName === 'BODY';
  3523. var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent;
  3524. target.addEventListener(event, callback, { passive: true });
  3525. if (!isBody) {
  3526. attachToScrollParents(getScrollParent(target.parentNode), event, callback, scrollParents);
  3527. }
  3528. scrollParents.push(target);
  3529. }
  3530. /**
  3531. * Setup needed event listeners used to update the popper position
  3532. * @method
  3533. * @memberof Popper.Utils
  3534. * @private
  3535. */
  3536. function setupEventListeners(reference, options, state, updateBound) {
  3537. // Resize event listener on window
  3538. state.updateBound = updateBound;
  3539. getWindow(reference).addEventListener('resize', state.updateBound, { passive: true });
  3540. // Scroll event listener on scroll parents
  3541. var scrollElement = getScrollParent(reference);
  3542. attachToScrollParents(scrollElement, 'scroll', state.updateBound, state.scrollParents);
  3543. state.scrollElement = scrollElement;
  3544. state.eventsEnabled = true;
  3545. return state;
  3546. }
  3547. /**
  3548. * It will add resize/scroll events and start recalculating
  3549. * position of the popper element when they are triggered.
  3550. * @method
  3551. * @memberof Popper
  3552. */
  3553. function enableEventListeners() {
  3554. if (!this.state.eventsEnabled) {
  3555. this.state = setupEventListeners(this.reference, this.options, this.state, this.scheduleUpdate);
  3556. }
  3557. }
  3558. /**
  3559. * Remove event listeners used to update the popper position
  3560. * @method
  3561. * @memberof Popper.Utils
  3562. * @private
  3563. */
  3564. function removeEventListeners(reference, state) {
  3565. // Remove resize event listener on window
  3566. getWindow(reference).removeEventListener('resize', state.updateBound);
  3567. // Remove scroll event listener on scroll parents
  3568. state.scrollParents.forEach(function (target) {
  3569. target.removeEventListener('scroll', state.updateBound);
  3570. });
  3571. // Reset state
  3572. state.updateBound = null;
  3573. state.scrollParents = [];
  3574. state.scrollElement = null;
  3575. state.eventsEnabled = false;
  3576. return state;
  3577. }
  3578. /**
  3579. * It will remove resize/scroll events and won't recalculate popper position
  3580. * when they are triggered. It also won't trigger `onUpdate` callback anymore,
  3581. * unless you call `update` method manually.
  3582. * @method
  3583. * @memberof Popper
  3584. */
  3585. function disableEventListeners() {
  3586. if (this.state.eventsEnabled) {
  3587. cancelAnimationFrame(this.scheduleUpdate);
  3588. this.state = removeEventListeners(this.reference, this.state);
  3589. }
  3590. }
  3591. /**
  3592. * Tells if a given input is a number
  3593. * @method
  3594. * @memberof Popper.Utils
  3595. * @param {*} input to check
  3596. * @return {Boolean}
  3597. */
  3598. function isNumeric(n) {
  3599. return n !== '' && !isNaN(parseFloat(n)) && isFinite(n);
  3600. }
  3601. /**
  3602. * Set the style to the given popper
  3603. * @method
  3604. * @memberof Popper.Utils
  3605. * @argument {Element} element - Element to apply the style to
  3606. * @argument {Object} styles
  3607. * Object with a list of properties and values which will be applied to the element
  3608. */
  3609. function setStyles(element, styles) {
  3610. Object.keys(styles).forEach(function (prop) {
  3611. var unit = '';
  3612. // add unit if the value is numeric and is one of the following
  3613. if (['width', 'height', 'top', 'right', 'bottom', 'left'].indexOf(prop) !== -1 && isNumeric(styles[prop])) {
  3614. unit = 'px';
  3615. }
  3616. element.style[prop] = styles[prop] + unit;
  3617. });
  3618. }
  3619. /**
  3620. * Set the attributes to the given popper
  3621. * @method
  3622. * @memberof Popper.Utils
  3623. * @argument {Element} element - Element to apply the attributes to
  3624. * @argument {Object} styles
  3625. * Object with a list of properties and values which will be applied to the element
  3626. */
  3627. function setAttributes(element, attributes) {
  3628. Object.keys(attributes).forEach(function (prop) {
  3629. var value = attributes[prop];
  3630. if (value !== false) {
  3631. element.setAttribute(prop, attributes[prop]);
  3632. } else {
  3633. element.removeAttribute(prop);
  3634. }
  3635. });
  3636. }
  3637. /**
  3638. * @function
  3639. * @memberof Modifiers
  3640. * @argument {Object} data - The data object generated by `update` method
  3641. * @argument {Object} data.styles - List of style properties - values to apply to popper element
  3642. * @argument {Object} data.attributes - List of attribute properties - values to apply to popper element
  3643. * @argument {Object} options - Modifiers configuration and options
  3644. * @returns {Object} The same data object
  3645. */
  3646. function applyStyle(data) {
  3647. // any property present in `data.styles` will be applied to the popper,
  3648. // in this way we can make the 3rd party modifiers add custom styles to it
  3649. // Be aware, modifiers could override the properties defined in the previous
  3650. // lines of this modifier!
  3651. setStyles(data.instance.popper, data.styles);
  3652. // any property present in `data.attributes` will be applied to the popper,
  3653. // they will be set as HTML attributes of the element
  3654. setAttributes(data.instance.popper, data.attributes);
  3655. // if arrowElement is defined and arrowStyles has some properties
  3656. if (data.arrowElement && Object.keys(data.arrowStyles).length) {
  3657. setStyles(data.arrowElement, data.arrowStyles);
  3658. }
  3659. return data;
  3660. }
  3661. /**
  3662. * Set the x-placement attribute before everything else because it could be used
  3663. * to add margins to the popper margins needs to be calculated to get the
  3664. * correct popper offsets.
  3665. * @method
  3666. * @memberof Popper.modifiers
  3667. * @param {HTMLElement} reference - The reference element used to position the popper
  3668. * @param {HTMLElement} popper - The HTML element used as popper
  3669. * @param {Object} options - Popper.js options
  3670. */
  3671. function applyStyleOnLoad(reference, popper, options, modifierOptions, state) {
  3672. // compute reference element offsets
  3673. var referenceOffsets = getReferenceOffsets(state, popper, reference, options.positionFixed);
  3674. // compute auto placement, store placement inside the data object,
  3675. // modifiers will be able to edit `placement` if needed
  3676. // and refer to originalPlacement to know the original value
  3677. var placement = computeAutoPlacement(options.placement, referenceOffsets, popper, reference, options.modifiers.flip.boundariesElement, options.modifiers.flip.padding);
  3678. popper.setAttribute('x-placement', placement);
  3679. // Apply `position` to popper before anything else because
  3680. // without the position applied we can't guarantee correct computations
  3681. setStyles(popper, { position: options.positionFixed ? 'fixed' : 'absolute' });
  3682. return options;
  3683. }
  3684. /**
  3685. * @function
  3686. * @memberof Popper.Utils
  3687. * @argument {Object} data - The data object generated by `update` method
  3688. * @argument {Boolean} shouldRound - If the offsets should be rounded at all
  3689. * @returns {Object} The popper's position offsets rounded
  3690. *
  3691. * The tale of pixel-perfect positioning. It's still not 100% perfect, but as
  3692. * good as it can be within reason.
  3693. * Discussion here: https://github.com/FezVrasta/popper.js/pull/715
  3694. *
  3695. * Low DPI screens cause a popper to be blurry if not using full pixels (Safari
  3696. * as well on High DPI screens).
  3697. *
  3698. * Firefox prefers no rounding for positioning and does not have blurriness on
  3699. * high DPI screens.
  3700. *
  3701. * Only horizontal placement and left/right values need to be considered.
  3702. */
  3703. function getRoundedOffsets(data, shouldRound) {
  3704. var _data$offsets = data.offsets,
  3705. popper = _data$offsets.popper,
  3706. reference = _data$offsets.reference;
  3707. var round = Math.round,
  3708. floor = Math.floor;
  3709. var noRound = function noRound(v) {
  3710. return v;
  3711. };
  3712. var referenceWidth = round(reference.width);
  3713. var popperWidth = round(popper.width);
  3714. var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
  3715. var isVariation = data.placement.indexOf('-') !== -1;
  3716. var sameWidthParity = referenceWidth % 2 === popperWidth % 2;
  3717. var bothOddWidth = referenceWidth % 2 === 1 && popperWidth % 2 === 1;
  3718. var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthParity ? round : floor;
  3719. var verticalToInteger = !shouldRound ? noRound : round;
  3720. return {
  3721. left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
  3722. top: verticalToInteger(popper.top),
  3723. bottom: verticalToInteger(popper.bottom),
  3724. right: horizontalToInteger(popper.right)
  3725. };
  3726. }
  3727. var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
  3728. /**
  3729. * @function
  3730. * @memberof Modifiers
  3731. * @argument {Object} data - The data object generated by `update` method
  3732. * @argument {Object} options - Modifiers configuration and options
  3733. * @returns {Object} The data object, properly modified
  3734. */
  3735. function computeStyle(data, options) {
  3736. var x = options.x,
  3737. y = options.y;
  3738. var popper = data.offsets.popper;
  3739. // Remove this legacy support in Popper.js v2
  3740. var legacyGpuAccelerationOption = find(data.instance.modifiers, function (modifier) {
  3741. return modifier.name === 'applyStyle';
  3742. }).gpuAcceleration;
  3743. if (legacyGpuAccelerationOption !== undefined) {
  3744. console.warn('WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!');
  3745. }
  3746. var gpuAcceleration = legacyGpuAccelerationOption !== undefined ? legacyGpuAccelerationOption : options.gpuAcceleration;
  3747. var offsetParent = getOffsetParent(data.instance.popper);
  3748. var offsetParentRect = getBoundingClientRect(offsetParent);
  3749. // Styles
  3750. var styles = {
  3751. position: popper.position
  3752. };
  3753. var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
  3754. var sideA = x === 'bottom' ? 'top' : 'bottom';
  3755. var sideB = y === 'right' ? 'left' : 'right';
  3756. // if gpuAcceleration is set to `true` and transform is supported,
  3757. // we use `translate3d` to apply the position to the popper we
  3758. // automatically use the supported prefixed version if needed
  3759. var prefixedProperty = getSupportedPropertyName('transform');
  3760. // now, let's make a step back and look at this code closely (wtf?)
  3761. // If the content of the popper grows once it's been positioned, it
  3762. // may happen that the popper gets misplaced because of the new content
  3763. // overflowing its reference element
  3764. // To avoid this problem, we provide two options (x and y), which allow
  3765. // the consumer to define the offset origin.
  3766. // If we position a popper on top of a reference element, we can set
  3767. // `x` to `top` to make the popper grow towards its top instead of
  3768. // its bottom.
  3769. var left = void 0,
  3770. top = void 0;
  3771. if (sideA === 'bottom') {
  3772. // when offsetParent is <html> the positioning is relative to the bottom of the screen (excluding the scrollbar)
  3773. // and not the bottom of the html element
  3774. if (offsetParent.nodeName === 'HTML') {
  3775. top = -offsetParent.clientHeight + offsets.bottom;
  3776. } else {
  3777. top = -offsetParentRect.height + offsets.bottom;
  3778. }
  3779. } else {
  3780. top = offsets.top;
  3781. }
  3782. if (sideB === 'right') {
  3783. if (offsetParent.nodeName === 'HTML') {
  3784. left = -offsetParent.clientWidth + offsets.right;
  3785. } else {
  3786. left = -offsetParentRect.width + offsets.right;
  3787. }
  3788. } else {
  3789. left = offsets.left;
  3790. }
  3791. if (gpuAcceleration && prefixedProperty) {
  3792. styles[prefixedProperty] = 'translate3d(' + left + 'px, ' + top + 'px, 0)';
  3793. styles[sideA] = 0;
  3794. styles[sideB] = 0;
  3795. styles.willChange = 'transform';
  3796. } else {
  3797. // othwerise, we use the standard `top`, `left`, `bottom` and `right` properties
  3798. var invertTop = sideA === 'bottom' ? -1 : 1;
  3799. var invertLeft = sideB === 'right' ? -1 : 1;
  3800. styles[sideA] = top * invertTop;
  3801. styles[sideB] = left * invertLeft;
  3802. styles.willChange = sideA + ', ' + sideB;
  3803. }
  3804. // Attributes
  3805. var attributes = {
  3806. 'x-placement': data.placement
  3807. };
  3808. // Update `data` attributes, styles and arrowStyles
  3809. data.attributes = _extends$4({}, attributes, data.attributes);
  3810. data.styles = _extends$4({}, styles, data.styles);
  3811. data.arrowStyles = _extends$4({}, data.offsets.arrow, data.arrowStyles);
  3812. return data;
  3813. }
  3814. /**
  3815. * Helper used to know if the given modifier depends from another one.<br />
  3816. * It checks if the needed modifier is listed and enabled.
  3817. * @method
  3818. * @memberof Popper.Utils
  3819. * @param {Array} modifiers - list of modifiers
  3820. * @param {String} requestingName - name of requesting modifier
  3821. * @param {String} requestedName - name of requested modifier
  3822. * @returns {Boolean}
  3823. */
  3824. function isModifierRequired(modifiers, requestingName, requestedName) {
  3825. var requesting = find(modifiers, function (_ref) {
  3826. var name = _ref.name;
  3827. return name === requestingName;
  3828. });
  3829. var isRequired = !!requesting && modifiers.some(function (modifier) {
  3830. return modifier.name === requestedName && modifier.enabled && modifier.order < requesting.order;
  3831. });
  3832. if (!isRequired) {
  3833. var _requesting = '`' + requestingName + '`';
  3834. var requested = '`' + requestedName + '`';
  3835. console.warn(requested + ' modifier is required by ' + _requesting + ' modifier in order to work, be sure to include it before ' + _requesting + '!');
  3836. }
  3837. return isRequired;
  3838. }
  3839. /**
  3840. * @function
  3841. * @memberof Modifiers
  3842. * @argument {Object} data - The data object generated by update method
  3843. * @argument {Object} options - Modifiers configuration and options
  3844. * @returns {Object} The data object, properly modified
  3845. */
  3846. function arrow(data, options) {
  3847. var _data$offsets$arrow;
  3848. // arrow depends on keepTogether in order to work
  3849. if (!isModifierRequired(data.instance.modifiers, 'arrow', 'keepTogether')) {
  3850. return data;
  3851. }
  3852. var arrowElement = options.element;
  3853. // if arrowElement is a string, suppose it's a CSS selector
  3854. if (typeof arrowElement === 'string') {
  3855. arrowElement = data.instance.popper.querySelector(arrowElement);
  3856. // if arrowElement is not found, don't run the modifier
  3857. if (!arrowElement) {
  3858. return data;
  3859. }
  3860. } else {
  3861. // if the arrowElement isn't a query selector we must check that the
  3862. // provided DOM node is child of its popper node
  3863. if (!data.instance.popper.contains(arrowElement)) {
  3864. console.warn('WARNING: `arrow.element` must be child of its popper element!');
  3865. return data;
  3866. }
  3867. }
  3868. var placement = data.placement.split('-')[0];
  3869. var _data$offsets = data.offsets,
  3870. popper = _data$offsets.popper,
  3871. reference = _data$offsets.reference;
  3872. var isVertical = ['left', 'right'].indexOf(placement) !== -1;
  3873. var len = isVertical ? 'height' : 'width';
  3874. var sideCapitalized = isVertical ? 'Top' : 'Left';
  3875. var side = sideCapitalized.toLowerCase();
  3876. var altSide = isVertical ? 'left' : 'top';
  3877. var opSide = isVertical ? 'bottom' : 'right';
  3878. var arrowElementSize = getOuterSizes(arrowElement)[len];
  3879. //
  3880. // extends keepTogether behavior making sure the popper and its
  3881. // reference have enough pixels in conjunction
  3882. //
  3883. // top/left side
  3884. if (reference[opSide] - arrowElementSize < popper[side]) {
  3885. data.offsets.popper[side] -= popper[side] - (reference[opSide] - arrowElementSize);
  3886. }
  3887. // bottom/right side
  3888. if (reference[side] + arrowElementSize > popper[opSide]) {
  3889. data.offsets.popper[side] += reference[side] + arrowElementSize - popper[opSide];
  3890. }
  3891. data.offsets.popper = getClientRect(data.offsets.popper);
  3892. // compute center of the popper
  3893. var center = reference[side] + reference[len] / 2 - arrowElementSize / 2;
  3894. // Compute the sideValue using the updated popper offsets
  3895. // take popper margin in account because we don't have this info available
  3896. var css = getStyleComputedProperty(data.instance.popper);
  3897. var popperMarginSide = parseFloat(css['margin' + sideCapitalized], 10);
  3898. var popperBorderSide = parseFloat(css['border' + sideCapitalized + 'Width'], 10);
  3899. var sideValue = center - data.offsets.popper[side] - popperMarginSide - popperBorderSide;
  3900. // prevent arrowElement from being placed not contiguously to its popper
  3901. sideValue = Math.max(Math.min(popper[len] - arrowElementSize, sideValue), 0);
  3902. data.arrowElement = arrowElement;
  3903. data.offsets.arrow = (_data$offsets$arrow = {}, defineProperty(_data$offsets$arrow, side, Math.round(sideValue)), defineProperty(_data$offsets$arrow, altSide, ''), _data$offsets$arrow);
  3904. return data;
  3905. }
  3906. /**
  3907. * Get the opposite placement variation of the given one
  3908. * @method
  3909. * @memberof Popper.Utils
  3910. * @argument {String} placement variation
  3911. * @returns {String} flipped placement variation
  3912. */
  3913. function getOppositeVariation(variation) {
  3914. if (variation === 'end') {
  3915. return 'start';
  3916. } else if (variation === 'start') {
  3917. return 'end';
  3918. }
  3919. return variation;
  3920. }
  3921. /**
  3922. * List of accepted placements to use as values of the `placement` option.<br />
  3923. * Valid placements are:
  3924. * - `auto`
  3925. * - `top`
  3926. * - `right`
  3927. * - `bottom`
  3928. * - `left`
  3929. *
  3930. * Each placement can have a variation from this list:
  3931. * - `-start`
  3932. * - `-end`
  3933. *
  3934. * Variations are interpreted easily if you think of them as the left to right
  3935. * written languages. Horizontally (`top` and `bottom`), `start` is left and `end`
  3936. * is right.<br />
  3937. * Vertically (`left` and `right`), `start` is top and `end` is bottom.
  3938. *
  3939. * Some valid examples are:
  3940. * - `top-end` (on top of reference, right aligned)
  3941. * - `right-start` (on right of reference, top aligned)
  3942. * - `bottom` (on bottom, centered)
  3943. * - `auto-end` (on the side with more space available, alignment depends by placement)
  3944. *
  3945. * @static
  3946. * @type {Array}
  3947. * @enum {String}
  3948. * @readonly
  3949. * @method placements
  3950. * @memberof Popper
  3951. */
  3952. 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'];
  3953. // Get rid of `auto` `auto-start` and `auto-end`
  3954. var validPlacements = placements.slice(3);
  3955. /**
  3956. * Given an initial placement, returns all the subsequent placements
  3957. * clockwise (or counter-clockwise).
  3958. *
  3959. * @method
  3960. * @memberof Popper.Utils
  3961. * @argument {String} placement - A valid placement (it accepts variations)
  3962. * @argument {Boolean} counter - Set to true to walk the placements counterclockwise
  3963. * @returns {Array} placements including their variations
  3964. */
  3965. function clockwise(placement) {
  3966. var counter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  3967. var index = validPlacements.indexOf(placement);
  3968. var arr = validPlacements.slice(index + 1).concat(validPlacements.slice(0, index));
  3969. return counter ? arr.reverse() : arr;
  3970. }
  3971. var BEHAVIORS = {
  3972. FLIP: 'flip',
  3973. CLOCKWISE: 'clockwise',
  3974. COUNTERCLOCKWISE: 'counterclockwise'
  3975. };
  3976. /**
  3977. * @function
  3978. * @memberof Modifiers
  3979. * @argument {Object} data - The data object generated by update method
  3980. * @argument {Object} options - Modifiers configuration and options
  3981. * @returns {Object} The data object, properly modified
  3982. */
  3983. function flip(data, options) {
  3984. // if `inner` modifier is enabled, we can't use the `flip` modifier
  3985. if (isModifierEnabled(data.instance.modifiers, 'inner')) {
  3986. return data;
  3987. }
  3988. if (data.flipped && data.placement === data.originalPlacement) {
  3989. // seems like flip is trying to loop, probably there's not enough space on any of the flippable sides
  3990. return data;
  3991. }
  3992. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, options.boundariesElement, data.positionFixed);
  3993. var placement = data.placement.split('-')[0];
  3994. var placementOpposite = getOppositePlacement(placement);
  3995. var variation = data.placement.split('-')[1] || '';
  3996. var flipOrder = [];
  3997. switch (options.behavior) {
  3998. case BEHAVIORS.FLIP:
  3999. flipOrder = [placement, placementOpposite];
  4000. break;
  4001. case BEHAVIORS.CLOCKWISE:
  4002. flipOrder = clockwise(placement);
  4003. break;
  4004. case BEHAVIORS.COUNTERCLOCKWISE:
  4005. flipOrder = clockwise(placement, true);
  4006. break;
  4007. default:
  4008. flipOrder = options.behavior;
  4009. }
  4010. flipOrder.forEach(function (step, index) {
  4011. if (placement !== step || flipOrder.length === index + 1) {
  4012. return data;
  4013. }
  4014. placement = data.placement.split('-')[0];
  4015. placementOpposite = getOppositePlacement(placement);
  4016. var popperOffsets = data.offsets.popper;
  4017. var refOffsets = data.offsets.reference;
  4018. // using floor because the reference offsets may contain decimals we are not going to consider here
  4019. var floor = Math.floor;
  4020. 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);
  4021. var overflowsLeft = floor(popperOffsets.left) < floor(boundaries.left);
  4022. var overflowsRight = floor(popperOffsets.right) > floor(boundaries.right);
  4023. var overflowsTop = floor(popperOffsets.top) < floor(boundaries.top);
  4024. var overflowsBottom = floor(popperOffsets.bottom) > floor(boundaries.bottom);
  4025. var overflowsBoundaries = placement === 'left' && overflowsLeft || placement === 'right' && overflowsRight || placement === 'top' && overflowsTop || placement === 'bottom' && overflowsBottom;
  4026. // flip the variation if required
  4027. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  4028. // flips variation if reference element overflows boundaries
  4029. var flippedVariationByRef = !!options.flipVariations && (isVertical && variation === 'start' && overflowsLeft || isVertical && variation === 'end' && overflowsRight || !isVertical && variation === 'start' && overflowsTop || !isVertical && variation === 'end' && overflowsBottom);
  4030. // flips variation if popper content overflows boundaries
  4031. var flippedVariationByContent = !!options.flipVariationsByContent && (isVertical && variation === 'start' && overflowsRight || isVertical && variation === 'end' && overflowsLeft || !isVertical && variation === 'start' && overflowsBottom || !isVertical && variation === 'end' && overflowsTop);
  4032. var flippedVariation = flippedVariationByRef || flippedVariationByContent;
  4033. if (overlapsRef || overflowsBoundaries || flippedVariation) {
  4034. // this boolean to detect any flip loop
  4035. data.flipped = true;
  4036. if (overlapsRef || overflowsBoundaries) {
  4037. placement = flipOrder[index + 1];
  4038. }
  4039. if (flippedVariation) {
  4040. variation = getOppositeVariation(variation);
  4041. }
  4042. data.placement = placement + (variation ? '-' + variation : '');
  4043. // this object contains `position`, we want to preserve it along with
  4044. // any additional property we may add in the future
  4045. data.offsets.popper = _extends$4({}, data.offsets.popper, getPopperOffsets(data.instance.popper, data.offsets.reference, data.placement));
  4046. data = runModifiers(data.instance.modifiers, data, 'flip');
  4047. }
  4048. });
  4049. return data;
  4050. }
  4051. /**
  4052. * @function
  4053. * @memberof Modifiers
  4054. * @argument {Object} data - The data object generated by update method
  4055. * @argument {Object} options - Modifiers configuration and options
  4056. * @returns {Object} The data object, properly modified
  4057. */
  4058. function keepTogether(data) {
  4059. var _data$offsets = data.offsets,
  4060. popper = _data$offsets.popper,
  4061. reference = _data$offsets.reference;
  4062. var placement = data.placement.split('-')[0];
  4063. var floor = Math.floor;
  4064. var isVertical = ['top', 'bottom'].indexOf(placement) !== -1;
  4065. var side = isVertical ? 'right' : 'bottom';
  4066. var opSide = isVertical ? 'left' : 'top';
  4067. var measurement = isVertical ? 'width' : 'height';
  4068. if (popper[side] < floor(reference[opSide])) {
  4069. data.offsets.popper[opSide] = floor(reference[opSide]) - popper[measurement];
  4070. }
  4071. if (popper[opSide] > floor(reference[side])) {
  4072. data.offsets.popper[opSide] = floor(reference[side]);
  4073. }
  4074. return data;
  4075. }
  4076. /**
  4077. * Converts a string containing value + unit into a px value number
  4078. * @function
  4079. * @memberof {modifiers~offset}
  4080. * @private
  4081. * @argument {String} str - Value + unit string
  4082. * @argument {String} measurement - `height` or `width`
  4083. * @argument {Object} popperOffsets
  4084. * @argument {Object} referenceOffsets
  4085. * @returns {Number|String}
  4086. * Value in pixels, or original string if no values were extracted
  4087. */
  4088. function toValue(str, measurement, popperOffsets, referenceOffsets) {
  4089. // separate value from unit
  4090. var split = str.match(/((?:\-|\+)?\d*\.?\d*)(.*)/);
  4091. var value = +split[1];
  4092. var unit = split[2];
  4093. // If it's not a number it's an operator, I guess
  4094. if (!value) {
  4095. return str;
  4096. }
  4097. if (unit.indexOf('%') === 0) {
  4098. var element = void 0;
  4099. switch (unit) {
  4100. case '%p':
  4101. element = popperOffsets;
  4102. break;
  4103. case '%':
  4104. case '%r':
  4105. default:
  4106. element = referenceOffsets;
  4107. }
  4108. var rect = getClientRect(element);
  4109. return rect[measurement] / 100 * value;
  4110. } else if (unit === 'vh' || unit === 'vw') {
  4111. // if is a vh or vw, we calculate the size based on the viewport
  4112. var size = void 0;
  4113. if (unit === 'vh') {
  4114. size = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
  4115. } else {
  4116. size = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
  4117. }
  4118. return size / 100 * value;
  4119. } else {
  4120. // if is an explicit pixel unit, we get rid of the unit and keep the value
  4121. // if is an implicit unit, it's px, and we return just the value
  4122. return value;
  4123. }
  4124. }
  4125. /**
  4126. * Parse an `offset` string to extrapolate `x` and `y` numeric offsets.
  4127. * @function
  4128. * @memberof {modifiers~offset}
  4129. * @private
  4130. * @argument {String} offset
  4131. * @argument {Object} popperOffsets
  4132. * @argument {Object} referenceOffsets
  4133. * @argument {String} basePlacement
  4134. * @returns {Array} a two cells array with x and y offsets in numbers
  4135. */
  4136. function parseOffset(offset, popperOffsets, referenceOffsets, basePlacement) {
  4137. var offsets = [0, 0];
  4138. // Use height if placement is left or right and index is 0 otherwise use width
  4139. // in this way the first offset will use an axis and the second one
  4140. // will use the other one
  4141. var useHeight = ['right', 'left'].indexOf(basePlacement) !== -1;
  4142. // Split the offset string to obtain a list of values and operands
  4143. // The regex addresses values with the plus or minus sign in front (+10, -20, etc)
  4144. var fragments = offset.split(/(\+|\-)/).map(function (frag) {
  4145. return frag.trim();
  4146. });
  4147. // Detect if the offset string contains a pair of values or a single one
  4148. // they could be separated by comma or space
  4149. var divider = fragments.indexOf(find(fragments, function (frag) {
  4150. return frag.search(/,|\s/) !== -1;
  4151. }));
  4152. if (fragments[divider] && fragments[divider].indexOf(',') === -1) {
  4153. console.warn('Offsets separated by white space(s) are deprecated, use a comma (,) instead.');
  4154. }
  4155. // If divider is found, we divide the list of values and operands to divide
  4156. // them by ofset X and Y.
  4157. var splitRegex = /\s*,\s*|\s+/;
  4158. 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];
  4159. // Convert the values with units to absolute pixels to allow our computations
  4160. ops = ops.map(function (op, index) {
  4161. // Most of the units rely on the orientation of the popper
  4162. var measurement = (index === 1 ? !useHeight : useHeight) ? 'height' : 'width';
  4163. var mergeWithPrevious = false;
  4164. return op
  4165. // This aggregates any `+` or `-` sign that aren't considered operators
  4166. // e.g.: 10 + +5 => [10, +, +5]
  4167. .reduce(function (a, b) {
  4168. if (a[a.length - 1] === '' && ['+', '-'].indexOf(b) !== -1) {
  4169. a[a.length - 1] = b;
  4170. mergeWithPrevious = true;
  4171. return a;
  4172. } else if (mergeWithPrevious) {
  4173. a[a.length - 1] += b;
  4174. mergeWithPrevious = false;
  4175. return a;
  4176. } else {
  4177. return a.concat(b);
  4178. }
  4179. }, [])
  4180. // Here we convert the string values into number values (in px)
  4181. .map(function (str) {
  4182. return toValue(str, measurement, popperOffsets, referenceOffsets);
  4183. });
  4184. });
  4185. // Loop trough the offsets arrays and execute the operations
  4186. ops.forEach(function (op, index) {
  4187. op.forEach(function (frag, index2) {
  4188. if (isNumeric(frag)) {
  4189. offsets[index] += frag * (op[index2 - 1] === '-' ? -1 : 1);
  4190. }
  4191. });
  4192. });
  4193. return offsets;
  4194. }
  4195. /**
  4196. * @function
  4197. * @memberof Modifiers
  4198. * @argument {Object} data - The data object generated by update method
  4199. * @argument {Object} options - Modifiers configuration and options
  4200. * @argument {Number|String} options.offset=0
  4201. * The offset value as described in the modifier description
  4202. * @returns {Object} The data object, properly modified
  4203. */
  4204. function offset$1(data, _ref) {
  4205. var offset = _ref.offset;
  4206. var placement = data.placement,
  4207. _data$offsets = data.offsets,
  4208. popper = _data$offsets.popper,
  4209. reference = _data$offsets.reference;
  4210. var basePlacement = placement.split('-')[0];
  4211. var offsets = void 0;
  4212. if (isNumeric(+offset)) {
  4213. offsets = [+offset, 0];
  4214. } else {
  4215. offsets = parseOffset(offset, popper, reference, basePlacement);
  4216. }
  4217. if (basePlacement === 'left') {
  4218. popper.top += offsets[0];
  4219. popper.left -= offsets[1];
  4220. } else if (basePlacement === 'right') {
  4221. popper.top += offsets[0];
  4222. popper.left += offsets[1];
  4223. } else if (basePlacement === 'top') {
  4224. popper.left += offsets[0];
  4225. popper.top -= offsets[1];
  4226. } else if (basePlacement === 'bottom') {
  4227. popper.left += offsets[0];
  4228. popper.top += offsets[1];
  4229. }
  4230. data.popper = popper;
  4231. return data;
  4232. }
  4233. /**
  4234. * @function
  4235. * @memberof Modifiers
  4236. * @argument {Object} data - The data object generated by `update` method
  4237. * @argument {Object} options - Modifiers configuration and options
  4238. * @returns {Object} The data object, properly modified
  4239. */
  4240. function preventOverflow(data, options) {
  4241. var boundariesElement = options.boundariesElement || getOffsetParent(data.instance.popper);
  4242. // If offsetParent is the reference element, we really want to
  4243. // go one step up and use the next offsetParent as reference to
  4244. // avoid to make this modifier completely useless and look like broken
  4245. if (data.instance.reference === boundariesElement) {
  4246. boundariesElement = getOffsetParent(boundariesElement);
  4247. }
  4248. // NOTE: DOM access here
  4249. // resets the popper's position so that the document size can be calculated excluding
  4250. // the size of the popper element itself
  4251. var transformProp = getSupportedPropertyName('transform');
  4252. var popperStyles = data.instance.popper.style; // assignment to help minification
  4253. var top = popperStyles.top,
  4254. left = popperStyles.left,
  4255. transform = popperStyles[transformProp];
  4256. popperStyles.top = '';
  4257. popperStyles.left = '';
  4258. popperStyles[transformProp] = '';
  4259. var boundaries = getBoundaries(data.instance.popper, data.instance.reference, options.padding, boundariesElement, data.positionFixed);
  4260. // NOTE: DOM access here
  4261. // restores the original style properties after the offsets have been computed
  4262. popperStyles.top = top;
  4263. popperStyles.left = left;
  4264. popperStyles[transformProp] = transform;
  4265. options.boundaries = boundaries;
  4266. var order = options.priority;
  4267. var popper = data.offsets.popper;
  4268. var check = {
  4269. primary: function primary(placement) {
  4270. var value = popper[placement];
  4271. if (popper[placement] < boundaries[placement] && !options.escapeWithReference) {
  4272. value = Math.max(popper[placement], boundaries[placement]);
  4273. }
  4274. return defineProperty({}, placement, value);
  4275. },
  4276. secondary: function secondary(placement) {
  4277. var mainSide = placement === 'right' ? 'left' : 'top';
  4278. var value = popper[mainSide];
  4279. if (popper[placement] > boundaries[placement] && !options.escapeWithReference) {
  4280. value = Math.min(popper[mainSide], boundaries[placement] - (placement === 'right' ? popper.width : popper.height));
  4281. }
  4282. return defineProperty({}, mainSide, value);
  4283. }
  4284. };
  4285. order.forEach(function (placement) {
  4286. var side = ['left', 'top'].indexOf(placement) !== -1 ? 'primary' : 'secondary';
  4287. popper = _extends$4({}, popper, check[side](placement));
  4288. });
  4289. data.offsets.popper = popper;
  4290. return data;
  4291. }
  4292. /**
  4293. * @function
  4294. * @memberof Modifiers
  4295. * @argument {Object} data - The data object generated by `update` method
  4296. * @argument {Object} options - Modifiers configuration and options
  4297. * @returns {Object} The data object, properly modified
  4298. */
  4299. function shift(data) {
  4300. var placement = data.placement;
  4301. var basePlacement = placement.split('-')[0];
  4302. var shiftvariation = placement.split('-')[1];
  4303. // if shift shiftvariation is specified, run the modifier
  4304. if (shiftvariation) {
  4305. var _data$offsets = data.offsets,
  4306. reference = _data$offsets.reference,
  4307. popper = _data$offsets.popper;
  4308. var isVertical = ['bottom', 'top'].indexOf(basePlacement) !== -1;
  4309. var side = isVertical ? 'left' : 'top';
  4310. var measurement = isVertical ? 'width' : 'height';
  4311. var shiftOffsets = {
  4312. start: defineProperty({}, side, reference[side]),
  4313. end: defineProperty({}, side, reference[side] + reference[measurement] - popper[measurement])
  4314. };
  4315. data.offsets.popper = _extends$4({}, popper, shiftOffsets[shiftvariation]);
  4316. }
  4317. return data;
  4318. }
  4319. /**
  4320. * @function
  4321. * @memberof Modifiers
  4322. * @argument {Object} data - The data object generated by update method
  4323. * @argument {Object} options - Modifiers configuration and options
  4324. * @returns {Object} The data object, properly modified
  4325. */
  4326. function hide(data) {
  4327. if (!isModifierRequired(data.instance.modifiers, 'hide', 'preventOverflow')) {
  4328. return data;
  4329. }
  4330. var refRect = data.offsets.reference;
  4331. var bound = find(data.instance.modifiers, function (modifier) {
  4332. return modifier.name === 'preventOverflow';
  4333. }).boundaries;
  4334. if (refRect.bottom < bound.top || refRect.left > bound.right || refRect.top > bound.bottom || refRect.right < bound.left) {
  4335. // Avoid unnecessary DOM access if visibility hasn't changed
  4336. if (data.hide === true) {
  4337. return data;
  4338. }
  4339. data.hide = true;
  4340. data.attributes['x-out-of-boundaries'] = '';
  4341. } else {
  4342. // Avoid unnecessary DOM access if visibility hasn't changed
  4343. if (data.hide === false) {
  4344. return data;
  4345. }
  4346. data.hide = false;
  4347. data.attributes['x-out-of-boundaries'] = false;
  4348. }
  4349. return data;
  4350. }
  4351. /**
  4352. * @function
  4353. * @memberof Modifiers
  4354. * @argument {Object} data - The data object generated by `update` method
  4355. * @argument {Object} options - Modifiers configuration and options
  4356. * @returns {Object} The data object, properly modified
  4357. */
  4358. function inner(data) {
  4359. var placement = data.placement;
  4360. var basePlacement = placement.split('-')[0];
  4361. var _data$offsets = data.offsets,
  4362. popper = _data$offsets.popper,
  4363. reference = _data$offsets.reference;
  4364. var isHoriz = ['left', 'right'].indexOf(basePlacement) !== -1;
  4365. var subtractLength = ['top', 'left'].indexOf(basePlacement) === -1;
  4366. popper[isHoriz ? 'left' : 'top'] = reference[basePlacement] - (subtractLength ? popper[isHoriz ? 'width' : 'height'] : 0);
  4367. data.placement = getOppositePlacement(placement);
  4368. data.offsets.popper = getClientRect(popper);
  4369. return data;
  4370. }
  4371. /**
  4372. * Modifier function, each modifier can have a function of this type assigned
  4373. * to its `fn` property.<br />
  4374. * These functions will be called on each update, this means that you must
  4375. * make sure they are performant enough to avoid performance bottlenecks.
  4376. *
  4377. * @function ModifierFn
  4378. * @argument {dataObject} data - The data object generated by `update` method
  4379. * @argument {Object} options - Modifiers configuration and options
  4380. * @returns {dataObject} The data object, properly modified
  4381. */
  4382. /**
  4383. * Modifiers are plugins used to alter the behavior of your poppers.<br />
  4384. * Popper.js uses a set of 9 modifiers to provide all the basic functionalities
  4385. * needed by the library.
  4386. *
  4387. * Usually you don't want to override the `order`, `fn` and `onLoad` props.
  4388. * All the other properties are configurations that could be tweaked.
  4389. * @namespace modifiers
  4390. */
  4391. var modifiers = {
  4392. /**
  4393. * Modifier used to shift the popper on the start or end of its reference
  4394. * element.<br />
  4395. * It will read the variation of the `placement` property.<br />
  4396. * It can be one either `-end` or `-start`.
  4397. * @memberof modifiers
  4398. * @inner
  4399. */
  4400. shift: {
  4401. /** @prop {number} order=100 - Index used to define the order of execution */
  4402. order: 100,
  4403. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  4404. enabled: true,
  4405. /** @prop {ModifierFn} */
  4406. fn: shift
  4407. },
  4408. /**
  4409. * The `offset` modifier can shift your popper on both its axis.
  4410. *
  4411. * It accepts the following units:
  4412. * - `px` or unit-less, interpreted as pixels
  4413. * - `%` or `%r`, percentage relative to the length of the reference element
  4414. * - `%p`, percentage relative to the length of the popper element
  4415. * - `vw`, CSS viewport width unit
  4416. * - `vh`, CSS viewport height unit
  4417. *
  4418. * For length is intended the main axis relative to the placement of the popper.<br />
  4419. * This means that if the placement is `top` or `bottom`, the length will be the
  4420. * `width`. In case of `left` or `right`, it will be the `height`.
  4421. *
  4422. * You can provide a single value (as `Number` or `String`), or a pair of values
  4423. * as `String` divided by a comma or one (or more) white spaces.<br />
  4424. * The latter is a deprecated method because it leads to confusion and will be
  4425. * removed in v2.<br />
  4426. * Additionally, it accepts additions and subtractions between different units.
  4427. * Note that multiplications and divisions aren't supported.
  4428. *
  4429. * Valid examples are:
  4430. * ```
  4431. * 10
  4432. * '10%'
  4433. * '10, 10'
  4434. * '10%, 10'
  4435. * '10 + 10%'
  4436. * '10 - 5vh + 3%'
  4437. * '-10px + 5vh, 5px - 6%'
  4438. * ```
  4439. * > **NB**: If you desire to apply offsets to your poppers in a way that may make them overlap
  4440. * > with their reference element, unfortunately, you will have to disable the `flip` modifier.
  4441. * > You can read more on this at this [issue](https://github.com/FezVrasta/popper.js/issues/373).
  4442. *
  4443. * @memberof modifiers
  4444. * @inner
  4445. */
  4446. offset: {
  4447. /** @prop {number} order=200 - Index used to define the order of execution */
  4448. order: 200,
  4449. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  4450. enabled: true,
  4451. /** @prop {ModifierFn} */
  4452. fn: offset$1,
  4453. /** @prop {Number|String} offset=0
  4454. * The offset value as described in the modifier description
  4455. */
  4456. offset: 0
  4457. },
  4458. /**
  4459. * Modifier used to prevent the popper from being positioned outside the boundary.
  4460. *
  4461. * A scenario exists where the reference itself is not within the boundaries.<br />
  4462. * We can say it has "escaped the boundaries" — or just "escaped".<br />
  4463. * In this case we need to decide whether the popper should either:
  4464. *
  4465. * - detach from the reference and remain "trapped" in the boundaries, or
  4466. * - if it should ignore the boundary and "escape with its reference"
  4467. *
  4468. * When `escapeWithReference` is set to`true` and reference is completely
  4469. * outside its boundaries, the popper will overflow (or completely leave)
  4470. * the boundaries in order to remain attached to the edge of the reference.
  4471. *
  4472. * @memberof modifiers
  4473. * @inner
  4474. */
  4475. preventOverflow: {
  4476. /** @prop {number} order=300 - Index used to define the order of execution */
  4477. order: 300,
  4478. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  4479. enabled: true,
  4480. /** @prop {ModifierFn} */
  4481. fn: preventOverflow,
  4482. /**
  4483. * @prop {Array} [priority=['left','right','top','bottom']]
  4484. * Popper will try to prevent overflow following these priorities by default,
  4485. * then, it could overflow on the left and on top of the `boundariesElement`
  4486. */
  4487. priority: ['left', 'right', 'top', 'bottom'],
  4488. /**
  4489. * @prop {number} padding=5
  4490. * Amount of pixel used to define a minimum distance between the boundaries
  4491. * and the popper. This makes sure the popper always has a little padding
  4492. * between the edges of its container
  4493. */
  4494. padding: 5,
  4495. /**
  4496. * @prop {String|HTMLElement} boundariesElement='scrollParent'
  4497. * Boundaries used by the modifier. Can be `scrollParent`, `window`,
  4498. * `viewport` or any DOM element.
  4499. */
  4500. boundariesElement: 'scrollParent'
  4501. },
  4502. /**
  4503. * Modifier used to make sure the reference and its popper stay near each other
  4504. * without leaving any gap between the two. Especially useful when the arrow is
  4505. * enabled and you want to ensure that it points to its reference element.
  4506. * It cares only about the first axis. You can still have poppers with margin
  4507. * between the popper and its reference element.
  4508. * @memberof modifiers
  4509. * @inner
  4510. */
  4511. keepTogether: {
  4512. /** @prop {number} order=400 - Index used to define the order of execution */
  4513. order: 400,
  4514. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  4515. enabled: true,
  4516. /** @prop {ModifierFn} */
  4517. fn: keepTogether
  4518. },
  4519. /**
  4520. * This modifier is used to move the `arrowElement` of the popper to make
  4521. * sure it is positioned between the reference element and its popper element.
  4522. * It will read the outer size of the `arrowElement` node to detect how many
  4523. * pixels of conjunction are needed.
  4524. *
  4525. * It has no effect if no `arrowElement` is provided.
  4526. * @memberof modifiers
  4527. * @inner
  4528. */
  4529. arrow: {
  4530. /** @prop {number} order=500 - Index used to define the order of execution */
  4531. order: 500,
  4532. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  4533. enabled: true,
  4534. /** @prop {ModifierFn} */
  4535. fn: arrow,
  4536. /** @prop {String|HTMLElement} element='[x-arrow]' - Selector or node used as arrow */
  4537. element: '[x-arrow]'
  4538. },
  4539. /**
  4540. * Modifier used to flip the popper's placement when it starts to overlap its
  4541. * reference element.
  4542. *
  4543. * Requires the `preventOverflow` modifier before it in order to work.
  4544. *
  4545. * **NOTE:** this modifier will interrupt the current update cycle and will
  4546. * restart it if it detects the need to flip the placement.
  4547. * @memberof modifiers
  4548. * @inner
  4549. */
  4550. flip: {
  4551. /** @prop {number} order=600 - Index used to define the order of execution */
  4552. order: 600,
  4553. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  4554. enabled: true,
  4555. /** @prop {ModifierFn} */
  4556. fn: flip,
  4557. /**
  4558. * @prop {String|Array} behavior='flip'
  4559. * The behavior used to change the popper's placement. It can be one of
  4560. * `flip`, `clockwise`, `counterclockwise` or an array with a list of valid
  4561. * placements (with optional variations)
  4562. */
  4563. behavior: 'flip',
  4564. /**
  4565. * @prop {number} padding=5
  4566. * The popper will flip if it hits the edges of the `boundariesElement`
  4567. */
  4568. padding: 5,
  4569. /**
  4570. * @prop {String|HTMLElement} boundariesElement='viewport'
  4571. * The element which will define the boundaries of the popper position.
  4572. * The popper will never be placed outside of the defined boundaries
  4573. * (except if `keepTogether` is enabled)
  4574. */
  4575. boundariesElement: 'viewport',
  4576. /**
  4577. * @prop {Boolean} flipVariations=false
  4578. * The popper will switch placement variation between `-start` and `-end` when
  4579. * the reference element overlaps its boundaries.
  4580. *
  4581. * The original placement should have a set variation.
  4582. */
  4583. flipVariations: false,
  4584. /**
  4585. * @prop {Boolean} flipVariationsByContent=false
  4586. * The popper will switch placement variation between `-start` and `-end` when
  4587. * the popper element overlaps its reference boundaries.
  4588. *
  4589. * The original placement should have a set variation.
  4590. */
  4591. flipVariationsByContent: false
  4592. },
  4593. /**
  4594. * Modifier used to make the popper flow toward the inner of the reference element.
  4595. * By default, when this modifier is disabled, the popper will be placed outside
  4596. * the reference element.
  4597. * @memberof modifiers
  4598. * @inner
  4599. */
  4600. inner: {
  4601. /** @prop {number} order=700 - Index used to define the order of execution */
  4602. order: 700,
  4603. /** @prop {Boolean} enabled=false - Whether the modifier is enabled or not */
  4604. enabled: false,
  4605. /** @prop {ModifierFn} */
  4606. fn: inner
  4607. },
  4608. /**
  4609. * Modifier used to hide the popper when its reference element is outside of the
  4610. * popper boundaries. It will set a `x-out-of-boundaries` attribute which can
  4611. * be used to hide with a CSS selector the popper when its reference is
  4612. * out of boundaries.
  4613. *
  4614. * Requires the `preventOverflow` modifier before it in order to work.
  4615. * @memberof modifiers
  4616. * @inner
  4617. */
  4618. hide: {
  4619. /** @prop {number} order=800 - Index used to define the order of execution */
  4620. order: 800,
  4621. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  4622. enabled: true,
  4623. /** @prop {ModifierFn} */
  4624. fn: hide
  4625. },
  4626. /**
  4627. * Computes the style that will be applied to the popper element to gets
  4628. * properly positioned.
  4629. *
  4630. * Note that this modifier will not touch the DOM, it just prepares the styles
  4631. * so that `applyStyle` modifier can apply it. This separation is useful
  4632. * in case you need to replace `applyStyle` with a custom implementation.
  4633. *
  4634. * This modifier has `850` as `order` value to maintain backward compatibility
  4635. * with previous versions of Popper.js. Expect the modifiers ordering method
  4636. * to change in future major versions of the library.
  4637. *
  4638. * @memberof modifiers
  4639. * @inner
  4640. */
  4641. computeStyle: {
  4642. /** @prop {number} order=850 - Index used to define the order of execution */
  4643. order: 850,
  4644. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  4645. enabled: true,
  4646. /** @prop {ModifierFn} */
  4647. fn: computeStyle,
  4648. /**
  4649. * @prop {Boolean} gpuAcceleration=true
  4650. * If true, it uses the CSS 3D transformation to position the popper.
  4651. * Otherwise, it will use the `top` and `left` properties
  4652. */
  4653. gpuAcceleration: true,
  4654. /**
  4655. * @prop {string} [x='bottom']
  4656. * Where to anchor the X axis (`bottom` or `top`). AKA X offset origin.
  4657. * Change this if your popper should grow in a direction different from `bottom`
  4658. */
  4659. x: 'bottom',
  4660. /**
  4661. * @prop {string} [x='left']
  4662. * Where to anchor the Y axis (`left` or `right`). AKA Y offset origin.
  4663. * Change this if your popper should grow in a direction different from `right`
  4664. */
  4665. y: 'right'
  4666. },
  4667. /**
  4668. * Applies the computed styles to the popper element.
  4669. *
  4670. * All the DOM manipulations are limited to this modifier. This is useful in case
  4671. * you want to integrate Popper.js inside a framework or view library and you
  4672. * want to delegate all the DOM manipulations to it.
  4673. *
  4674. * Note that if you disable this modifier, you must make sure the popper element
  4675. * has its position set to `absolute` before Popper.js can do its work!
  4676. *
  4677. * Just disable this modifier and define your own to achieve the desired effect.
  4678. *
  4679. * @memberof modifiers
  4680. * @inner
  4681. */
  4682. applyStyle: {
  4683. /** @prop {number} order=900 - Index used to define the order of execution */
  4684. order: 900,
  4685. /** @prop {Boolean} enabled=true - Whether the modifier is enabled or not */
  4686. enabled: true,
  4687. /** @prop {ModifierFn} */
  4688. fn: applyStyle,
  4689. /** @prop {Function} */
  4690. onLoad: applyStyleOnLoad,
  4691. /**
  4692. * @deprecated since version 1.10.0, the property moved to `computeStyle` modifier
  4693. * @prop {Boolean} gpuAcceleration=true
  4694. * If true, it uses the CSS 3D transformation to position the popper.
  4695. * Otherwise, it will use the `top` and `left` properties
  4696. */
  4697. gpuAcceleration: undefined
  4698. }
  4699. };
  4700. /**
  4701. * The `dataObject` is an object containing all the information used by Popper.js.
  4702. * This object is passed to modifiers and to the `onCreate` and `onUpdate` callbacks.
  4703. * @name dataObject
  4704. * @property {Object} data.instance The Popper.js instance
  4705. * @property {String} data.placement Placement applied to popper
  4706. * @property {String} data.originalPlacement Placement originally defined on init
  4707. * @property {Boolean} data.flipped True if popper has been flipped by flip modifier
  4708. * @property {Boolean} data.hide True if the reference element is out of boundaries, useful to know when to hide the popper
  4709. * @property {HTMLElement} data.arrowElement Node used as arrow by arrow modifier
  4710. * @property {Object} data.styles Any CSS property defined here will be applied to the popper. It expects the JavaScript nomenclature (eg. `marginBottom`)
  4711. * @property {Object} data.arrowStyles Any CSS property defined here will be applied to the popper arrow. It expects the JavaScript nomenclature (eg. `marginBottom`)
  4712. * @property {Object} data.boundaries Offsets of the popper boundaries
  4713. * @property {Object} data.offsets The measurements of popper, reference and arrow elements
  4714. * @property {Object} data.offsets.popper `top`, `left`, `width`, `height` values
  4715. * @property {Object} data.offsets.reference `top`, `left`, `width`, `height` values
  4716. * @property {Object} data.offsets.arrow] `top` and `left` offsets, only one of them will be different from 0
  4717. */
  4718. /**
  4719. * Default options provided to Popper.js constructor.<br />
  4720. * These can be overridden using the `options` argument of Popper.js.<br />
  4721. * To override an option, simply pass an object with the same
  4722. * structure of the `options` object, as the 3rd argument. For example:
  4723. * ```
  4724. * new Popper(ref, pop, {
  4725. * modifiers: {
  4726. * preventOverflow: { enabled: false }
  4727. * }
  4728. * })
  4729. * ```
  4730. * @type {Object}
  4731. * @static
  4732. * @memberof Popper
  4733. */
  4734. var Defaults = {
  4735. /**
  4736. * Popper's placement.
  4737. * @prop {Popper.placements} placement='bottom'
  4738. */
  4739. placement: 'bottom',
  4740. /**
  4741. * Set this to true if you want popper to position it self in 'fixed' mode
  4742. * @prop {Boolean} positionFixed=false
  4743. */
  4744. positionFixed: false,
  4745. /**
  4746. * Whether events (resize, scroll) are initially enabled.
  4747. * @prop {Boolean} eventsEnabled=true
  4748. */
  4749. eventsEnabled: true,
  4750. /**
  4751. * Set to true if you want to automatically remove the popper when
  4752. * you call the `destroy` method.
  4753. * @prop {Boolean} removeOnDestroy=false
  4754. */
  4755. removeOnDestroy: false,
  4756. /**
  4757. * Callback called when the popper is created.<br />
  4758. * By default, it is set to no-op.<br />
  4759. * Access Popper.js instance with `data.instance`.
  4760. * @prop {onCreate}
  4761. */
  4762. onCreate: function onCreate() {},
  4763. /**
  4764. * Callback called when the popper is updated. This callback is not called
  4765. * on the initialization/creation of the popper, but only on subsequent
  4766. * updates.<br />
  4767. * By default, it is set to no-op.<br />
  4768. * Access Popper.js instance with `data.instance`.
  4769. * @prop {onUpdate}
  4770. */
  4771. onUpdate: function onUpdate() {},
  4772. /**
  4773. * List of modifiers used to modify the offsets before they are applied to the popper.
  4774. * They provide most of the functionalities of Popper.js.
  4775. * @prop {modifiers}
  4776. */
  4777. modifiers: modifiers
  4778. };
  4779. /**
  4780. * @callback onCreate
  4781. * @param {dataObject} data
  4782. */
  4783. /**
  4784. * @callback onUpdate
  4785. * @param {dataObject} data
  4786. */
  4787. // Utils
  4788. // Methods
  4789. var Popper = function () {
  4790. /**
  4791. * Creates a new Popper.js instance.
  4792. * @class Popper
  4793. * @param {Element|referenceObject} reference - The reference element used to position the popper
  4794. * @param {Element} popper - The HTML / XML element used as the popper
  4795. * @param {Object} options - Your custom options to override the ones defined in [Defaults](#defaults)
  4796. * @return {Object} instance - The generated Popper.js instance
  4797. */
  4798. function Popper(reference, popper) {
  4799. var _this = this;
  4800. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  4801. classCallCheck(this, Popper);
  4802. this.scheduleUpdate = function () {
  4803. return requestAnimationFrame(_this.update);
  4804. };
  4805. // make update() debounced, so that it only runs at most once-per-tick
  4806. this.update = debounce(this.update.bind(this));
  4807. // with {} we create a new object with the options inside it
  4808. this.options = _extends$4({}, Popper.Defaults, options);
  4809. // init state
  4810. this.state = {
  4811. isDestroyed: false,
  4812. isCreated: false,
  4813. scrollParents: []
  4814. };
  4815. // get reference and popper elements (allow jQuery wrappers)
  4816. this.reference = reference && reference.jquery ? reference[0] : reference;
  4817. this.popper = popper && popper.jquery ? popper[0] : popper;
  4818. // Deep merge modifiers options
  4819. this.options.modifiers = {};
  4820. Object.keys(_extends$4({}, Popper.Defaults.modifiers, options.modifiers)).forEach(function (name) {
  4821. _this.options.modifiers[name] = _extends$4({}, Popper.Defaults.modifiers[name] || {}, options.modifiers ? options.modifiers[name] : {});
  4822. });
  4823. // Refactoring modifiers' list (Object => Array)
  4824. this.modifiers = Object.keys(this.options.modifiers).map(function (name) {
  4825. return _extends$4({
  4826. name: name
  4827. }, _this.options.modifiers[name]);
  4828. })
  4829. // sort the modifiers by order
  4830. .sort(function (a, b) {
  4831. return a.order - b.order;
  4832. });
  4833. // modifiers have the ability to execute arbitrary code when Popper.js get inited
  4834. // such code is executed in the same order of its modifier
  4835. // they could add new properties to their options configuration
  4836. // BE AWARE: don't add options to `options.modifiers.name` but to `modifierOptions`!
  4837. this.modifiers.forEach(function (modifierOptions) {
  4838. if (modifierOptions.enabled && isFunction$1(modifierOptions.onLoad)) {
  4839. modifierOptions.onLoad(_this.reference, _this.popper, _this.options, modifierOptions, _this.state);
  4840. }
  4841. });
  4842. // fire the first update to position the popper in the right place
  4843. this.update();
  4844. var eventsEnabled = this.options.eventsEnabled;
  4845. if (eventsEnabled) {
  4846. // setup event listeners, they will take care of update the position in specific situations
  4847. this.enableEventListeners();
  4848. }
  4849. this.state.eventsEnabled = eventsEnabled;
  4850. }
  4851. // We can't use class properties because they don't get listed in the
  4852. // class prototype and break stuff like Sinon stubs
  4853. createClass(Popper, [{
  4854. key: 'update',
  4855. value: function update$$1() {
  4856. return update.call(this);
  4857. }
  4858. }, {
  4859. key: 'destroy',
  4860. value: function destroy$$1() {
  4861. return destroy.call(this);
  4862. }
  4863. }, {
  4864. key: 'enableEventListeners',
  4865. value: function enableEventListeners$$1() {
  4866. return enableEventListeners.call(this);
  4867. }
  4868. }, {
  4869. key: 'disableEventListeners',
  4870. value: function disableEventListeners$$1() {
  4871. return disableEventListeners.call(this);
  4872. }
  4873. /**
  4874. * Schedules an update. It will run on the next UI update available.
  4875. * @method scheduleUpdate
  4876. * @memberof Popper
  4877. */
  4878. /**
  4879. * Collection of utilities useful when writing custom modifiers.
  4880. * Starting from version 1.7, this method is available only if you
  4881. * include `popper-utils.js` before `popper.js`.
  4882. *
  4883. * **DEPRECATION**: This way to access PopperUtils is deprecated
  4884. * and will be removed in v2! Use the PopperUtils module directly instead.
  4885. * Due to the high instability of the methods contained in Utils, we can't
  4886. * guarantee them to follow semver. Use them at your own risk!
  4887. * @static
  4888. * @private
  4889. * @type {Object}
  4890. * @deprecated since version 1.8
  4891. * @member Utils
  4892. * @memberof Popper
  4893. */
  4894. }]);
  4895. return Popper;
  4896. }();
  4897. /**
  4898. * The `referenceObject` is an object that provides an interface compatible with Popper.js
  4899. * and lets you use it as replacement of a real DOM node.<br />
  4900. * You can use this method to position a popper relatively to a set of coordinates
  4901. * in case you don't have a DOM node to use as reference.
  4902. *
  4903. * ```
  4904. * new Popper(referenceObject, popperNode);
  4905. * ```
  4906. *
  4907. * NB: This feature isn't supported in Internet Explorer 10.
  4908. * @name referenceObject
  4909. * @property {Function} data.getBoundingClientRect
  4910. * A function that returns a set of coordinates compatible with the native `getBoundingClientRect` method.
  4911. * @property {number} data.clientWidth
  4912. * An ES6 getter that will return the width of the virtual reference element.
  4913. * @property {number} data.clientHeight
  4914. * An ES6 getter that will return the height of the virtual reference element.
  4915. */
  4916. Popper.Utils = (typeof window !== 'undefined' ? window : global).PopperUtils;
  4917. Popper.placements = placements;
  4918. Popper.Defaults = Defaults;
  4919. /**
  4920. * A convenience hook around `useState` designed to be paired with
  4921. * the component [callback ref](https://reactjs.org/docs/refs-and-the-dom.html#callback-refs) api.
  4922. * Callback refs are useful over `useRef()` when you need to respond to the ref being set
  4923. * instead of lazily accessing it in an effect.
  4924. *
  4925. * ```ts
  4926. * const [element, attachRef] = useCallbackRef<HTMLDivElement>()
  4927. *
  4928. * useEffect(() => {
  4929. * if (!element) return
  4930. *
  4931. * const calendar = new FullCalendar.Calendar(element)
  4932. *
  4933. * return () => {
  4934. * calendar.destroy()
  4935. * }
  4936. * }, [element])
  4937. *
  4938. * return <div ref={attachRef} />
  4939. * ```
  4940. */
  4941. function useCallbackRef() {
  4942. return React.useState(null);
  4943. }
  4944. var toFnRef = function toFnRef(ref) {
  4945. return !ref || typeof ref === 'function' ? ref : function (value) {
  4946. ref.current = value;
  4947. };
  4948. };
  4949. function mergeRefs(refA, refB) {
  4950. var a = toFnRef(refA);
  4951. var b = toFnRef(refB);
  4952. return function (value) {
  4953. if (a) a(value);
  4954. if (b) b(value);
  4955. };
  4956. }
  4957. /**
  4958. * Create and returns a single callback ref composed from two other Refs.
  4959. *
  4960. * ```tsx
  4961. * const Button = React.forwardRef((props, ref) => {
  4962. * const [element, attachRef] = useCallbackRef<HTMLButtonElement>();
  4963. * const mergedRef = useMergedRefs(ref, attachRef);
  4964. *
  4965. * return <button ref={mergedRef} {...props}/>
  4966. * })
  4967. * ```
  4968. *
  4969. * @param refA A Callback or mutable Ref
  4970. * @param refB A Callback or mutable Ref
  4971. */
  4972. function useMergedRefs(refA, refB) {
  4973. return React.useMemo(function () {
  4974. return mergeRefs(refA, refB);
  4975. }, [refA, refB]);
  4976. }
  4977. var initialPopperStyles = {
  4978. position: 'absolute',
  4979. top: '0',
  4980. left: '0',
  4981. opacity: '0',
  4982. pointerEvents: 'none'
  4983. };
  4984. var initialArrowStyles = {};
  4985. /**
  4986. * Position an element relative some reference element using Popper.js
  4987. *
  4988. * @param {HTMLElement} referenceElement The element
  4989. * @param {HTMLElement} popperElement
  4990. * @param {Object} options
  4991. * @param {Object} options.modifiers Popper.js modifiers
  4992. * @param {Boolean} options.enabled toggle the popper functionality on/off
  4993. * @param {String} options.placement The popper element placement relative to the reference element
  4994. * @param {Boolean} options.positionFixed use fixed positioning
  4995. * @param {Boolean} options.eventsEnabled have Popper listen on window resize events to reposition the element
  4996. */
  4997. function usePopper(referenceElement, popperElement, _temp) {
  4998. var _ref = _temp === void 0 ? {} : _temp,
  4999. _ref$enabled = _ref.enabled,
  5000. enabled = _ref$enabled === void 0 ? true : _ref$enabled,
  5001. _ref$placement = _ref.placement,
  5002. placement = _ref$placement === void 0 ? 'bottom' : _ref$placement,
  5003. _ref$positionFixed = _ref.positionFixed,
  5004. positionFixed = _ref$positionFixed === void 0 ? false : _ref$positionFixed,
  5005. _ref$eventsEnabled = _ref.eventsEnabled,
  5006. eventsEnabled = _ref$eventsEnabled === void 0 ? true : _ref$eventsEnabled,
  5007. _ref$modifiers = _ref.modifiers,
  5008. modifiers = _ref$modifiers === void 0 ? {} : _ref$modifiers;
  5009. var popperInstanceRef = React.useRef();
  5010. var hasArrow = !!(modifiers.arrow && modifiers.arrow.element);
  5011. var scheduleUpdate = React.useCallback(function () {
  5012. if (popperInstanceRef.current) {
  5013. popperInstanceRef.current.scheduleUpdate();
  5014. }
  5015. }, []);
  5016. var _useState = React.useState({
  5017. placement: placement,
  5018. scheduleUpdate: scheduleUpdate,
  5019. outOfBoundaries: false,
  5020. styles: initialPopperStyles,
  5021. arrowStyles: initialArrowStyles
  5022. }),
  5023. state = _useState[0],
  5024. setState = _useState[1]; // A placement difference in state means popper determined a new placement
  5025. // apart from the props value. By the time the popper element is rendered with
  5026. // the new position Popper has already measured it, if the place change triggers
  5027. // a size change it will result in a misaligned popper. So we schedule an update to be sure.
  5028. React.useEffect(function () {
  5029. scheduleUpdate();
  5030. }, [state.placement, scheduleUpdate]);
  5031. /** Toggle Events */
  5032. React.useEffect(function () {
  5033. if (popperInstanceRef.current) {
  5034. // eslint-disable-next-line no-unused-expressions
  5035. eventsEnabled ? popperInstanceRef.current.enableEventListeners() : popperInstanceRef.current.disableEventListeners();
  5036. }
  5037. }, [eventsEnabled]);
  5038. React.useEffect(function () {
  5039. if (!enabled || referenceElement === null || popperElement === null) {
  5040. return undefined;
  5041. }
  5042. var arrow = modifiers.arrow && _extends$3({}, modifiers.arrow, {
  5043. element: modifiers.arrow.element
  5044. });
  5045. popperInstanceRef.current = new Popper(referenceElement, popperElement, {
  5046. placement: placement,
  5047. positionFixed: positionFixed,
  5048. modifiers: _extends$3({}, modifiers, {
  5049. arrow: arrow,
  5050. applyStyle: {
  5051. enabled: false
  5052. },
  5053. updateStateModifier: {
  5054. enabled: true,
  5055. order: 900,
  5056. fn: function fn(data) {
  5057. setState({
  5058. scheduleUpdate: scheduleUpdate,
  5059. styles: _extends$3({
  5060. position: data.offsets.popper.position
  5061. }, data.styles),
  5062. arrowStyles: data.arrowStyles,
  5063. outOfBoundaries: data.hide,
  5064. placement: data.placement
  5065. });
  5066. }
  5067. }
  5068. })
  5069. });
  5070. return function () {
  5071. if (popperInstanceRef.current !== null) {
  5072. popperInstanceRef.current.destroy();
  5073. popperInstanceRef.current = null;
  5074. }
  5075. }; // intentionally NOT re-running on new modifiers
  5076. // eslint-disable-next-line react-hooks/exhaustive-deps
  5077. }, [enabled, placement, positionFixed, referenceElement, popperElement, hasArrow]);
  5078. return state;
  5079. }
  5080. var interopRequireDefault = createCommonjsModule(function (module) {
  5081. function _interopRequireDefault(obj) {
  5082. return obj && obj.__esModule ? obj : {
  5083. "default": obj
  5084. };
  5085. }
  5086. module.exports = _interopRequireDefault;
  5087. });
  5088. unwrapExports(interopRequireDefault);
  5089. var inDOM = createCommonjsModule(function (module, exports) {
  5090. exports.__esModule = true;
  5091. exports.default = void 0;
  5092. var _default = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
  5093. exports.default = _default;
  5094. module.exports = exports["default"];
  5095. });
  5096. unwrapExports(inDOM);
  5097. var contains$1 = createCommonjsModule(function (module, exports) {
  5098. exports.__esModule = true;
  5099. exports.default = void 0;
  5100. var _inDOM = interopRequireDefault(inDOM);
  5101. var _default = function () {
  5102. // HTML DOM and SVG DOM may have different support levels,
  5103. // so we need to check on context instead of a document root element.
  5104. return _inDOM.default ? function (context, node) {
  5105. if (context.contains) {
  5106. return context.contains(node);
  5107. } else if (context.compareDocumentPosition) {
  5108. return context === node || !!(context.compareDocumentPosition(node) & 16);
  5109. } else {
  5110. return fallback(context, node);
  5111. }
  5112. } : fallback;
  5113. }();
  5114. exports.default = _default;
  5115. function fallback(context, node) {
  5116. if (node) do {
  5117. if (node === context) return true;
  5118. } while (node = node.parentNode);
  5119. return false;
  5120. }
  5121. module.exports = exports["default"];
  5122. });
  5123. var contains$2 = unwrapExports(contains$1);
  5124. var on_1 = createCommonjsModule(function (module, exports) {
  5125. exports.__esModule = true;
  5126. exports.default = void 0;
  5127. var _inDOM = interopRequireDefault(inDOM);
  5128. var on = function on() {};
  5129. if (_inDOM.default) {
  5130. on = function () {
  5131. if (document.addEventListener) return function (node, eventName, handler, capture) {
  5132. return node.addEventListener(eventName, handler, capture || false);
  5133. };else if (document.attachEvent) return function (node, eventName, handler) {
  5134. return node.attachEvent('on' + eventName, function (e) {
  5135. e = e || window.event;
  5136. e.target = e.target || e.srcElement;
  5137. e.currentTarget = node;
  5138. handler.call(node, e);
  5139. });
  5140. };
  5141. }();
  5142. }
  5143. var _default = on;
  5144. exports.default = _default;
  5145. module.exports = exports["default"];
  5146. });
  5147. unwrapExports(on_1);
  5148. var off_1 = createCommonjsModule(function (module, exports) {
  5149. exports.__esModule = true;
  5150. exports.default = void 0;
  5151. var _inDOM = interopRequireDefault(inDOM);
  5152. var off = function off() {};
  5153. if (_inDOM.default) {
  5154. off = function () {
  5155. if (document.addEventListener) return function (node, eventName, handler, capture) {
  5156. return node.removeEventListener(eventName, handler, capture || false);
  5157. };else if (document.attachEvent) return function (node, eventName, handler) {
  5158. return node.detachEvent('on' + eventName, handler);
  5159. };
  5160. }();
  5161. }
  5162. var _default = off;
  5163. exports.default = _default;
  5164. module.exports = exports["default"];
  5165. });
  5166. unwrapExports(off_1);
  5167. var listen_1 = createCommonjsModule(function (module, exports) {
  5168. exports.__esModule = true;
  5169. exports.default = void 0;
  5170. var _inDOM = interopRequireDefault(inDOM);
  5171. var _on = interopRequireDefault(on_1);
  5172. var _off = interopRequireDefault(off_1);
  5173. var listen = function listen() {};
  5174. if (_inDOM.default) {
  5175. listen = function listen(node, eventName, handler, capture) {
  5176. (0, _on.default)(node, eventName, handler, capture);
  5177. return function () {
  5178. (0, _off.default)(node, eventName, handler, capture);
  5179. };
  5180. };
  5181. }
  5182. var _default = listen;
  5183. exports.default = _default;
  5184. module.exports = exports["default"];
  5185. });
  5186. var listen = unwrapExports(listen_1);
  5187. /**
  5188. * Creates a `Ref` whose value is updated in an effect, ensuring the most recent
  5189. * value is the one rendered with. Generally only required for Concurrent mode usage
  5190. * where previous work in `render()` may be discarded befor being used.
  5191. *
  5192. * This is safe to access in an event handler.
  5193. *
  5194. * @param value The `Ref` value
  5195. */
  5196. function useCommittedRef(value) {
  5197. var ref = React.useRef(value);
  5198. React.useEffect(function () {
  5199. ref.current = value;
  5200. }, [value]);
  5201. return ref;
  5202. }
  5203. function useEventCallback(fn) {
  5204. var ref = useCommittedRef(fn);
  5205. return React.useCallback(function () {
  5206. return ref.current && ref.current.apply(ref, arguments);
  5207. }, [ref]);
  5208. }
  5209. var escapeKeyCode = 27;
  5210. var noop$1 = function noop() {};
  5211. function isLeftClickEvent(event) {
  5212. return event.button === 0;
  5213. }
  5214. function isModifiedEvent(event) {
  5215. return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
  5216. }
  5217. /**
  5218. * The `useRootClose` hook registers your callback on the document
  5219. * when rendered. Powers the `<Overlay/>` component. This is used achieve modal
  5220. * style behavior where your callback is triggered when the user tries to
  5221. * interact with the rest of the document or hits the `esc` key.
  5222. *
  5223. * @param {Ref<HTMLElement>|HTMLElement} ref The element boundary
  5224. * @param {function} onRootClose
  5225. * @param {object} options
  5226. * @param {boolean} options.disabled
  5227. * @param {string} options.clickTrigger The DOM event name (click, mousedown, etc) to attach listeners on
  5228. */
  5229. function useRootClose(ref, onRootClose, _temp) {
  5230. var _ref = _temp === void 0 ? {} : _temp,
  5231. disabled = _ref.disabled,
  5232. _ref$clickTrigger = _ref.clickTrigger,
  5233. clickTrigger = _ref$clickTrigger === void 0 ? 'click' : _ref$clickTrigger;
  5234. var preventMouseRootCloseRef = React.useRef(false);
  5235. var onClose = onRootClose || noop$1;
  5236. var handleMouseCapture = React.useCallback(function (e) {
  5237. var currentTarget = ref && ('current' in ref ? ref.current : ref);
  5238. warning_1(!!currentTarget, 'RootClose captured a close event but does not have a ref to compare it to. ' + 'useRootClose(), should be passed a ref that resolves to a DOM node');
  5239. preventMouseRootCloseRef.current = !currentTarget || isModifiedEvent(e) || !isLeftClickEvent(e) || contains$2(currentTarget, e.target);
  5240. }, [ref]);
  5241. var handleMouse = useEventCallback(function (e) {
  5242. if (!preventMouseRootCloseRef.current) {
  5243. onClose(e);
  5244. }
  5245. });
  5246. var handleKeyUp = useEventCallback(function (e) {
  5247. if (e.keyCode === escapeKeyCode) {
  5248. onClose(e);
  5249. }
  5250. });
  5251. React.useEffect(function () {
  5252. if (disabled || ref == null) return undefined; // Use capture for this listener so it fires before React's listener, to
  5253. // avoid false positives in the contains() check below if the target DOM
  5254. // element is removed in the React mouse callback.
  5255. var removeMouseCaptureListener = listen(document, clickTrigger, handleMouseCapture, true);
  5256. var removeMouseListener = listen(document, clickTrigger, handleMouse);
  5257. var removeKeyupListener = listen(document, 'keyup', handleKeyUp);
  5258. var mobileSafariHackListeners = [];
  5259. if ('ontouchstart' in document.documentElement) {
  5260. mobileSafariHackListeners = [].slice.call(document.body.children).map(function (el) {
  5261. return listen(el, 'mousemove', noop$1);
  5262. });
  5263. }
  5264. return function () {
  5265. removeMouseCaptureListener();
  5266. removeMouseListener();
  5267. removeKeyupListener();
  5268. mobileSafariHackListeners.forEach(function (remove) {
  5269. return remove();
  5270. });
  5271. };
  5272. }, [ref, disabled, clickTrigger, handleMouseCapture, handleMouse, handleKeyUp]);
  5273. }
  5274. var ownerDocument_1 = createCommonjsModule(function (module, exports) {
  5275. exports.__esModule = true;
  5276. exports.default = ownerDocument;
  5277. function ownerDocument(node) {
  5278. return node && node.ownerDocument || document;
  5279. }
  5280. module.exports = exports["default"];
  5281. });
  5282. var ownerDocument$1 = unwrapExports(ownerDocument_1);
  5283. var resolveRef = function resolveRef(ref) {
  5284. if (ref == null) return ownerDocument$1().body;
  5285. if (typeof ref === 'function') ref = ref();
  5286. if (ref && ref.current) ref = ref.current;
  5287. if (ref && ref.nodeType) return ref;
  5288. return null;
  5289. };
  5290. function useWaitForDOMRef(ref, onResolved) {
  5291. var _useState = React.useState(function () {
  5292. return resolveRef(ref);
  5293. }),
  5294. resolvedRef = _useState[0],
  5295. setRef = _useState[1];
  5296. if (!resolvedRef) {
  5297. var earlyRef = resolveRef(ref);
  5298. if (earlyRef) setRef(earlyRef);
  5299. }
  5300. React.useEffect(function () {
  5301. if (onResolved && resolvedRef) {
  5302. onResolved(resolvedRef);
  5303. }
  5304. }, [onResolved, resolvedRef]);
  5305. React.useEffect(function () {
  5306. var nextRef = resolveRef(ref);
  5307. if (nextRef !== resolvedRef) {
  5308. setRef(nextRef);
  5309. }
  5310. }, [ref, resolvedRef]);
  5311. return resolvedRef;
  5312. }
  5313. /**
  5314. * Built on top of `Popper.js`, the overlay component is
  5315. * great for custom tooltip overlays.
  5316. */
  5317. var Overlay = React__default.forwardRef(function (props, outerRef) {
  5318. var flip = props.flip,
  5319. placement = props.placement,
  5320. containerPadding = props.containerPadding,
  5321. _props$popperConfig = props.popperConfig,
  5322. popperConfig = _props$popperConfig === void 0 ? {} : _props$popperConfig,
  5323. Transition = props.transition;
  5324. var _useCallbackRef = useCallbackRef(),
  5325. rootElement = _useCallbackRef[0],
  5326. attachRef = _useCallbackRef[1];
  5327. var _useCallbackRef2 = useCallbackRef(),
  5328. arrowElement = _useCallbackRef2[0],
  5329. attachArrowRef = _useCallbackRef2[1];
  5330. var mergedRef = useMergedRefs(attachRef, outerRef);
  5331. var container = useWaitForDOMRef(props.container);
  5332. var target = useWaitForDOMRef(props.target);
  5333. var _useState = React.useState(!props.show),
  5334. exited = _useState[0],
  5335. setExited = _useState[1];
  5336. var _popperConfig$modifie = popperConfig.modifiers,
  5337. modifiers = _popperConfig$modifie === void 0 ? {} : _popperConfig$modifie;
  5338. var _usePopper = usePopper(target, rootElement, _extends$3({}, popperConfig, {
  5339. placement: placement || 'bottom',
  5340. enableEvents: props.show,
  5341. modifiers: _extends$3({}, modifiers, {
  5342. preventOverflow: _extends$3({
  5343. padding: containerPadding || 5
  5344. }, modifiers.preventOverflow),
  5345. arrow: _extends$3({}, modifiers.arrow, {
  5346. enabled: !!arrowElement,
  5347. element: arrowElement
  5348. }),
  5349. flip: _extends$3({
  5350. enabled: !!flip
  5351. }, modifiers.preventOverflow)
  5352. })
  5353. })),
  5354. styles = _usePopper.styles,
  5355. arrowStyles = _usePopper.arrowStyles,
  5356. popper = _objectWithoutPropertiesLoose$2(_usePopper, ["styles", "arrowStyles"]);
  5357. if (props.show) {
  5358. if (exited) setExited(false);
  5359. } else if (!props.transition && !exited) {
  5360. setExited(true);
  5361. }
  5362. var handleHidden = function handleHidden() {
  5363. setExited(true);
  5364. if (props.onExited) {
  5365. props.onExited.apply(props, arguments);
  5366. }
  5367. }; // Don't un-render the overlay while it's transitioning out.
  5368. var mountOverlay = props.show || Transition && !exited;
  5369. useRootClose(rootElement, props.onHide, {
  5370. disabled: !props.rootClose || props.rootCloseDisabled,
  5371. clickTrigger: props.rootCloseEvent
  5372. });
  5373. if (!mountOverlay) {
  5374. // Don't bother showing anything if we don't have to.
  5375. return null;
  5376. }
  5377. var child = props.children(_extends$3({}, popper, {
  5378. show: props.show,
  5379. props: {
  5380. style: styles,
  5381. ref: mergedRef
  5382. },
  5383. arrowProps: {
  5384. style: arrowStyles,
  5385. ref: attachArrowRef
  5386. }
  5387. }));
  5388. if (Transition) {
  5389. var onExit = props.onExit,
  5390. onExiting = props.onExiting,
  5391. onEnter = props.onEnter,
  5392. onEntering = props.onEntering,
  5393. onEntered = props.onEntered;
  5394. child = React__default.createElement(Transition, {
  5395. "in": props.show,
  5396. appear: true,
  5397. onExit: onExit,
  5398. onExiting: onExiting,
  5399. onExited: handleHidden,
  5400. onEnter: onEnter,
  5401. onEntering: onEntering,
  5402. onEntered: onEntered
  5403. }, child);
  5404. }
  5405. return container ? ReactDOM__default.createPortal(child, container) : null;
  5406. });
  5407. Overlay.displayName = 'Overlay';
  5408. Overlay.propTypes = {
  5409. /**
  5410. * Set the visibility of the Overlay
  5411. */
  5412. show: propTypes.bool,
  5413. /** Specify where the overlay element is positioned in relation to the target element */
  5414. placement: propTypes.oneOf(Popper.placements),
  5415. /**
  5416. * A DOM Element, Ref to an element, or function that returns either. The `target` element is where
  5417. * the overlay is positioned relative to.
  5418. */
  5419. target: propTypes.any,
  5420. /**
  5421. * A DOM Element, Ref to an element, or function that returns either. The `container` will have the Portal children
  5422. * appended to it.
  5423. */
  5424. container: propTypes.any,
  5425. /**
  5426. * Enables the Popper.js `flip` modifier, allowing the Overlay to
  5427. * automatically adjust it's placement in case of overlap with the viewport or toggle.
  5428. * Refer to the [flip docs](https://popper.js.org/popper-documentation.html#modifiers..flip.enabled) for more info
  5429. */
  5430. flip: propTypes.bool,
  5431. /**
  5432. * A render prop that returns an element to overlay and position. See
  5433. * the [react-popper documentation](https://github.com/FezVrasta/react-popper#children) for more info.
  5434. *
  5435. * @type {Function ({
  5436. * show: boolean,
  5437. * placement: Placement,
  5438. * outOfBoundaries: ?boolean,
  5439. * scheduleUpdate: () => void,
  5440. * props: {
  5441. * ref: (?HTMLElement) => void,
  5442. * style: { [string]: string | number },
  5443. * aria-labelledby: ?string
  5444. * },
  5445. * arrowProps: {
  5446. * ref: (?HTMLElement) => void,
  5447. * style: { [string]: string | number },
  5448. * },
  5449. * }) => React.Element}
  5450. */
  5451. children: propTypes.func.isRequired,
  5452. /**
  5453. * Control how much space there is between the edge of the boundary element and overlay.
  5454. * A convenience shortcut to setting `popperConfig.modfiers.preventOverflow.padding`
  5455. */
  5456. containerPadding: propTypes.number,
  5457. /**
  5458. * A set of popper options and props passed directly to react-popper's Popper component.
  5459. */
  5460. popperConfig: propTypes.object,
  5461. /**
  5462. * Specify whether the overlay should trigger `onHide` when the user clicks outside the overlay
  5463. */
  5464. rootClose: propTypes.bool,
  5465. /**
  5466. * Specify event for toggling overlay
  5467. */
  5468. rootCloseEvent: propTypes.oneOf(['click', 'mousedown']),
  5469. /**
  5470. * Specify disabled for disable RootCloseWrapper
  5471. */
  5472. rootCloseDisabled: propTypes.bool,
  5473. /**
  5474. * A Callback fired by the Overlay when it wishes to be hidden.
  5475. *
  5476. * __required__ when `rootClose` is `true`.
  5477. *
  5478. * @type func
  5479. */
  5480. onHide: function onHide(props) {
  5481. var propType = propTypes.func;
  5482. if (props.rootClose) {
  5483. propType = propType.isRequired;
  5484. }
  5485. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  5486. args[_key - 1] = arguments[_key];
  5487. }
  5488. return propType.apply(void 0, [props].concat(args));
  5489. },
  5490. /**
  5491. * A `react-transition-group@2.0.0` `<Transition/>` component
  5492. * used to animate the overlay as it changes visibility.
  5493. */
  5494. transition: propTypes.elementType,
  5495. /**
  5496. * Callback fired before the Overlay transitions in
  5497. */
  5498. onEnter: propTypes.func,
  5499. /**
  5500. * Callback fired as the Overlay begins to transition in
  5501. */
  5502. onEntering: propTypes.func,
  5503. /**
  5504. * Callback fired after the Overlay finishes transitioning in
  5505. */
  5506. onEntered: propTypes.func,
  5507. /**
  5508. * Callback fired right before the Overlay transitions out
  5509. */
  5510. onExit: propTypes.func,
  5511. /**
  5512. * Callback fired as the Overlay begins to transition out
  5513. */
  5514. onExiting: propTypes.func,
  5515. /**
  5516. * Callback fired after the Overlay finishes transitioning out
  5517. */
  5518. onExited: propTypes.func
  5519. };
  5520. Overlay.defaultProps = {
  5521. containerPadding: 5
  5522. };
  5523. function height(node, client) {
  5524. var win = isWindow(node);
  5525. return win ? win.innerHeight : client ? node.clientHeight : offset(node).height;
  5526. }
  5527. var toArray = Function.prototype.bind.call(Function.prototype.call, [].slice);
  5528. function qsa(element, selector) {
  5529. return toArray(element.querySelectorAll(selector));
  5530. }
  5531. var matchesImpl;
  5532. function matches(node, selector) {
  5533. if (!matchesImpl) {
  5534. var body = document.body;
  5535. var nativeMatch = body.matches || body.matchesSelector || body.webkitMatchesSelector || body.mozMatchesSelector || body.msMatchesSelector;
  5536. matchesImpl = function matchesImpl(n, s) {
  5537. return nativeMatch.call(n, s);
  5538. };
  5539. }
  5540. return matchesImpl(node, selector);
  5541. }
  5542. function closest(node, selector, stopAt) {
  5543. if (node.closest && !stopAt) node.closest(selector);
  5544. var nextNode = node;
  5545. do {
  5546. if (matches(nextNode, selector)) return nextNode;
  5547. nextNode = nextNode.parentElement;
  5548. } while (nextNode && nextNode !== stopAt && nextNode.nodeType === document.ELEMENT_NODE);
  5549. return null;
  5550. }
  5551. /* eslint-disable no-return-assign */
  5552. var optionsSupported = false;
  5553. var onceSupported = false;
  5554. try {
  5555. var options = {
  5556. get passive() {
  5557. return optionsSupported = true;
  5558. },
  5559. get once() {
  5560. // eslint-disable-next-line no-multi-assign
  5561. return onceSupported = optionsSupported = true;
  5562. }
  5563. };
  5564. if (canUseDOM) {
  5565. window.addEventListener('test', options, options);
  5566. window.removeEventListener('test', options, true);
  5567. }
  5568. } catch (e) {
  5569. /* */
  5570. }
  5571. /**
  5572. * An `addEventListener` ponyfill, supports the `once` option
  5573. */
  5574. function addEventListener(node, eventName, handler, options) {
  5575. if (options && typeof options !== 'boolean' && !onceSupported) {
  5576. var once = options.once,
  5577. capture = options.capture;
  5578. var wrappedHandler = handler;
  5579. if (!onceSupported && once) {
  5580. wrappedHandler = handler.__once || function onceHandler(event) {
  5581. this.removeEventListener(eventName, onceHandler, capture);
  5582. handler.call(this, event);
  5583. };
  5584. handler.__once = wrappedHandler;
  5585. }
  5586. node.addEventListener(eventName, wrappedHandler, optionsSupported ? options : capture);
  5587. }
  5588. node.addEventListener(eventName, handler, options);
  5589. }
  5590. function removeEventListener(node, eventName, handler, options) {
  5591. var capture = options && typeof options !== 'boolean' ? options.capture : options;
  5592. node.removeEventListener(eventName, handler, capture);
  5593. if (handler.__once) {
  5594. node.removeEventListener(eventName, handler.__once, capture);
  5595. }
  5596. }
  5597. function listen$1(node, eventName, handler, options) {
  5598. addEventListener(node, eventName, handler, options);
  5599. return function () {
  5600. removeEventListener(node, eventName, handler, options);
  5601. };
  5602. }
  5603. function addEventListener$1(type, handler, target) {
  5604. if (target === void 0) {
  5605. target = document;
  5606. }
  5607. return listen$1(target, type, handler, {
  5608. passive: false
  5609. });
  5610. }
  5611. function isOverContainer(container, x, y) {
  5612. return !container || contains(container, document.elementFromPoint(x, y));
  5613. }
  5614. function getEventNodeFromPoint(node, _ref) {
  5615. var clientX = _ref.clientX,
  5616. clientY = _ref.clientY;
  5617. var target = document.elementFromPoint(clientX, clientY);
  5618. return closest(target, '.rbc-event', node);
  5619. }
  5620. function isEvent(node, bounds) {
  5621. return !!getEventNodeFromPoint(node, bounds);
  5622. }
  5623. function getEventCoordinates(e) {
  5624. var target = e;
  5625. if (e.touches && e.touches.length) {
  5626. target = e.touches[0];
  5627. }
  5628. return {
  5629. clientX: target.clientX,
  5630. clientY: target.clientY,
  5631. pageX: target.pageX,
  5632. pageY: target.pageY
  5633. };
  5634. }
  5635. var clickTolerance = 5;
  5636. var clickInterval = 250;
  5637. var Selection =
  5638. /*#__PURE__*/
  5639. function () {
  5640. function Selection(node, _temp) {
  5641. var _ref2 = _temp === void 0 ? {} : _temp,
  5642. _ref2$global = _ref2.global,
  5643. global = _ref2$global === void 0 ? false : _ref2$global,
  5644. _ref2$longPressThresh = _ref2.longPressThreshold,
  5645. longPressThreshold = _ref2$longPressThresh === void 0 ? 250 : _ref2$longPressThresh;
  5646. this.isDetached = false;
  5647. this.container = node;
  5648. this.globalMouse = !node || global;
  5649. this.longPressThreshold = longPressThreshold;
  5650. this._listeners = Object.create(null);
  5651. this._handleInitialEvent = this._handleInitialEvent.bind(this);
  5652. this._handleMoveEvent = this._handleMoveEvent.bind(this);
  5653. this._handleTerminatingEvent = this._handleTerminatingEvent.bind(this);
  5654. this._keyListener = this._keyListener.bind(this);
  5655. this._dropFromOutsideListener = this._dropFromOutsideListener.bind(this);
  5656. this._dragOverFromOutsideListener = this._dragOverFromOutsideListener.bind(this); // Fixes an iOS 10 bug where scrolling could not be prevented on the window.
  5657. // https://github.com/metafizzy/flickity/issues/457#issuecomment-254501356
  5658. this._removeTouchMoveWindowListener = addEventListener$1('touchmove', function () {}, window);
  5659. this._removeKeyDownListener = addEventListener$1('keydown', this._keyListener);
  5660. this._removeKeyUpListener = addEventListener$1('keyup', this._keyListener);
  5661. this._removeDropFromOutsideListener = addEventListener$1('drop', this._dropFromOutsideListener);
  5662. this._onDragOverfromOutisde = addEventListener$1('dragover', this._dragOverFromOutsideListener);
  5663. this._addInitialEventListener();
  5664. }
  5665. var _proto = Selection.prototype;
  5666. _proto.on = function on(type, handler) {
  5667. var handlers = this._listeners[type] || (this._listeners[type] = []);
  5668. handlers.push(handler);
  5669. return {
  5670. remove: function remove() {
  5671. var idx = handlers.indexOf(handler);
  5672. if (idx !== -1) handlers.splice(idx, 1);
  5673. }
  5674. };
  5675. };
  5676. _proto.emit = function emit(type) {
  5677. for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  5678. args[_key - 1] = arguments[_key];
  5679. }
  5680. var result;
  5681. var handlers = this._listeners[type] || [];
  5682. handlers.forEach(function (fn) {
  5683. if (result === undefined) result = fn.apply(void 0, args);
  5684. });
  5685. return result;
  5686. };
  5687. _proto.teardown = function teardown() {
  5688. this.isDetached = true;
  5689. this.listeners = Object.create(null);
  5690. this._removeTouchMoveWindowListener && this._removeTouchMoveWindowListener();
  5691. this._removeInitialEventListener && this._removeInitialEventListener();
  5692. this._removeEndListener && this._removeEndListener();
  5693. this._onEscListener && this._onEscListener();
  5694. this._removeMoveListener && this._removeMoveListener();
  5695. this._removeKeyUpListener && this._removeKeyUpListener();
  5696. this._removeKeyDownListener && this._removeKeyDownListener();
  5697. this._removeDropFromOutsideListener && this._removeDropFromOutsideListener();
  5698. };
  5699. _proto.isSelected = function isSelected(node) {
  5700. var box = this._selectRect;
  5701. if (!box || !this.selecting) return false;
  5702. return objectsCollide(box, getBoundsForNode(node));
  5703. };
  5704. _proto.filter = function filter(items) {
  5705. var box = this._selectRect; //not selecting
  5706. if (!box || !this.selecting) return [];
  5707. return items.filter(this.isSelected, this);
  5708. } // Adds a listener that will call the handler only after the user has pressed on the screen
  5709. // without moving their finger for 250ms.
  5710. ;
  5711. _proto._addLongPressListener = function _addLongPressListener(handler, initialEvent) {
  5712. var _this = this;
  5713. var timer = null;
  5714. var removeTouchMoveListener = null;
  5715. var removeTouchEndListener = null;
  5716. var handleTouchStart = function handleTouchStart(initialEvent) {
  5717. timer = setTimeout(function () {
  5718. cleanup();
  5719. handler(initialEvent);
  5720. }, _this.longPressThreshold);
  5721. removeTouchMoveListener = addEventListener$1('touchmove', function () {
  5722. return cleanup();
  5723. });
  5724. removeTouchEndListener = addEventListener$1('touchend', function () {
  5725. return cleanup();
  5726. });
  5727. };
  5728. var removeTouchStartListener = addEventListener$1('touchstart', handleTouchStart);
  5729. var cleanup = function cleanup() {
  5730. if (timer) {
  5731. clearTimeout(timer);
  5732. }
  5733. if (removeTouchMoveListener) {
  5734. removeTouchMoveListener();
  5735. }
  5736. if (removeTouchEndListener) {
  5737. removeTouchEndListener();
  5738. }
  5739. timer = null;
  5740. removeTouchMoveListener = null;
  5741. removeTouchEndListener = null;
  5742. };
  5743. if (initialEvent) {
  5744. handleTouchStart(initialEvent);
  5745. }
  5746. return function () {
  5747. cleanup();
  5748. removeTouchStartListener();
  5749. };
  5750. } // Listen for mousedown and touchstart events. When one is received, disable the other and setup
  5751. // future event handling based on the type of event.
  5752. ;
  5753. _proto._addInitialEventListener = function _addInitialEventListener() {
  5754. var _this2 = this;
  5755. var removeMouseDownListener = addEventListener$1('mousedown', function (e) {
  5756. _this2._removeInitialEventListener();
  5757. _this2._handleInitialEvent(e);
  5758. _this2._removeInitialEventListener = addEventListener$1('mousedown', _this2._handleInitialEvent);
  5759. });
  5760. var removeTouchStartListener = addEventListener$1('touchstart', function (e) {
  5761. _this2._removeInitialEventListener();
  5762. _this2._removeInitialEventListener = _this2._addLongPressListener(_this2._handleInitialEvent, e);
  5763. });
  5764. this._removeInitialEventListener = function () {
  5765. removeMouseDownListener();
  5766. removeTouchStartListener();
  5767. };
  5768. };
  5769. _proto._dropFromOutsideListener = function _dropFromOutsideListener(e) {
  5770. var _getEventCoordinates = getEventCoordinates(e),
  5771. pageX = _getEventCoordinates.pageX,
  5772. pageY = _getEventCoordinates.pageY,
  5773. clientX = _getEventCoordinates.clientX,
  5774. clientY = _getEventCoordinates.clientY;
  5775. this.emit('dropFromOutside', {
  5776. x: pageX,
  5777. y: pageY,
  5778. clientX: clientX,
  5779. clientY: clientY
  5780. });
  5781. e.preventDefault();
  5782. };
  5783. _proto._dragOverFromOutsideListener = function _dragOverFromOutsideListener(e) {
  5784. var _getEventCoordinates2 = getEventCoordinates(e),
  5785. pageX = _getEventCoordinates2.pageX,
  5786. pageY = _getEventCoordinates2.pageY,
  5787. clientX = _getEventCoordinates2.clientX,
  5788. clientY = _getEventCoordinates2.clientY;
  5789. this.emit('dragOverFromOutside', {
  5790. x: pageX,
  5791. y: pageY,
  5792. clientX: clientX,
  5793. clientY: clientY
  5794. });
  5795. e.preventDefault();
  5796. };
  5797. _proto._handleInitialEvent = function _handleInitialEvent(e) {
  5798. if (this.isDetached) {
  5799. return;
  5800. }
  5801. var _getEventCoordinates3 = getEventCoordinates(e),
  5802. clientX = _getEventCoordinates3.clientX,
  5803. clientY = _getEventCoordinates3.clientY,
  5804. pageX = _getEventCoordinates3.pageX,
  5805. pageY = _getEventCoordinates3.pageY;
  5806. var node = this.container(),
  5807. collides,
  5808. offsetData; // Right clicks
  5809. if (e.which === 3 || e.button === 2 || !isOverContainer(node, clientX, clientY)) return;
  5810. if (!this.globalMouse && node && !contains(node, e.target)) {
  5811. var _normalizeDistance = normalizeDistance(0),
  5812. top = _normalizeDistance.top,
  5813. left = _normalizeDistance.left,
  5814. bottom = _normalizeDistance.bottom,
  5815. right = _normalizeDistance.right;
  5816. offsetData = getBoundsForNode(node);
  5817. collides = objectsCollide({
  5818. top: offsetData.top - top,
  5819. left: offsetData.left - left,
  5820. bottom: offsetData.bottom + bottom,
  5821. right: offsetData.right + right
  5822. }, {
  5823. top: pageY,
  5824. left: pageX
  5825. });
  5826. if (!collides) return;
  5827. }
  5828. var result = this.emit('beforeSelect', this._initialEventData = {
  5829. isTouch: /^touch/.test(e.type),
  5830. x: pageX,
  5831. y: pageY,
  5832. clientX: clientX,
  5833. clientY: clientY
  5834. });
  5835. if (result === false) return;
  5836. switch (e.type) {
  5837. case 'mousedown':
  5838. this._removeEndListener = addEventListener$1('mouseup', this._handleTerminatingEvent);
  5839. this._onEscListener = addEventListener$1('keydown', this._handleTerminatingEvent);
  5840. this._removeMoveListener = addEventListener$1('mousemove', this._handleMoveEvent);
  5841. break;
  5842. case 'touchstart':
  5843. this._handleMoveEvent(e);
  5844. this._removeEndListener = addEventListener$1('touchend', this._handleTerminatingEvent);
  5845. this._removeMoveListener = addEventListener$1('touchmove', this._handleMoveEvent);
  5846. break;
  5847. default:
  5848. break;
  5849. }
  5850. };
  5851. _proto._handleTerminatingEvent = function _handleTerminatingEvent(e) {
  5852. var _getEventCoordinates4 = getEventCoordinates(e),
  5853. pageX = _getEventCoordinates4.pageX,
  5854. pageY = _getEventCoordinates4.pageY;
  5855. this.selecting = false;
  5856. this._removeEndListener && this._removeEndListener();
  5857. this._removeMoveListener && this._removeMoveListener();
  5858. if (!this._initialEventData) return;
  5859. var inRoot = !this.container || contains(this.container(), e.target);
  5860. var bounds = this._selectRect;
  5861. var click = this.isClick(pageX, pageY);
  5862. this._initialEventData = null;
  5863. if (e.key === 'Escape') {
  5864. return this.emit('reset');
  5865. }
  5866. if (!inRoot) {
  5867. return this.emit('reset');
  5868. }
  5869. if (click && inRoot) {
  5870. return this._handleClickEvent(e);
  5871. } // User drag-clicked in the Selectable area
  5872. if (!click) return this.emit('select', bounds);
  5873. };
  5874. _proto._handleClickEvent = function _handleClickEvent(e) {
  5875. var _getEventCoordinates5 = getEventCoordinates(e),
  5876. pageX = _getEventCoordinates5.pageX,
  5877. pageY = _getEventCoordinates5.pageY,
  5878. clientX = _getEventCoordinates5.clientX,
  5879. clientY = _getEventCoordinates5.clientY;
  5880. var now = new Date().getTime();
  5881. if (this._lastClickData && now - this._lastClickData.timestamp < clickInterval) {
  5882. // Double click event
  5883. this._lastClickData = null;
  5884. return this.emit('doubleClick', {
  5885. x: pageX,
  5886. y: pageY,
  5887. clientX: clientX,
  5888. clientY: clientY
  5889. });
  5890. } // Click event
  5891. this._lastClickData = {
  5892. timestamp: now
  5893. };
  5894. return this.emit('click', {
  5895. x: pageX,
  5896. y: pageY,
  5897. clientX: clientX,
  5898. clientY: clientY
  5899. });
  5900. };
  5901. _proto._handleMoveEvent = function _handleMoveEvent(e) {
  5902. if (this._initialEventData === null || this.isDetached) {
  5903. return;
  5904. }
  5905. var _this$_initialEventDa = this._initialEventData,
  5906. x = _this$_initialEventDa.x,
  5907. y = _this$_initialEventDa.y;
  5908. var _getEventCoordinates6 = getEventCoordinates(e),
  5909. pageX = _getEventCoordinates6.pageX,
  5910. pageY = _getEventCoordinates6.pageY;
  5911. var w = Math.abs(x - pageX);
  5912. var h = Math.abs(y - pageY);
  5913. var left = Math.min(pageX, x),
  5914. top = Math.min(pageY, y),
  5915. old = this.selecting; // Prevent emitting selectStart event until mouse is moved.
  5916. // in Chrome on Windows, mouseMove event may be fired just after mouseDown event.
  5917. if (this.isClick(pageX, pageY) && !old && !(w || h)) {
  5918. return;
  5919. }
  5920. this.selecting = true;
  5921. this._selectRect = {
  5922. top: top,
  5923. left: left,
  5924. x: pageX,
  5925. y: pageY,
  5926. right: left + w,
  5927. bottom: top + h
  5928. };
  5929. if (!old) {
  5930. this.emit('selectStart', this._initialEventData);
  5931. }
  5932. if (!this.isClick(pageX, pageY)) this.emit('selecting', this._selectRect);
  5933. e.preventDefault();
  5934. };
  5935. _proto._keyListener = function _keyListener(e) {
  5936. this.ctrl = e.metaKey || e.ctrlKey;
  5937. };
  5938. _proto.isClick = function isClick(pageX, pageY) {
  5939. var _this$_initialEventDa2 = this._initialEventData,
  5940. x = _this$_initialEventDa2.x,
  5941. y = _this$_initialEventDa2.y,
  5942. isTouch = _this$_initialEventDa2.isTouch;
  5943. return !isTouch && Math.abs(pageX - x) <= clickTolerance && Math.abs(pageY - y) <= clickTolerance;
  5944. };
  5945. return Selection;
  5946. }();
  5947. /**
  5948. * Resolve the disance prop from either an Int or an Object
  5949. * @return {Object}
  5950. */
  5951. function normalizeDistance(distance) {
  5952. if (distance === void 0) {
  5953. distance = 0;
  5954. }
  5955. if (typeof distance !== 'object') distance = {
  5956. top: distance,
  5957. left: distance,
  5958. right: distance,
  5959. bottom: distance
  5960. };
  5961. return distance;
  5962. }
  5963. /**
  5964. * Given two objects containing "top", "left", "offsetWidth" and "offsetHeight"
  5965. * properties, determine if they collide.
  5966. * @param {Object|HTMLElement} a
  5967. * @param {Object|HTMLElement} b
  5968. * @return {bool}
  5969. */
  5970. function objectsCollide(nodeA, nodeB, tolerance) {
  5971. if (tolerance === void 0) {
  5972. tolerance = 0;
  5973. }
  5974. var _getBoundsForNode = getBoundsForNode(nodeA),
  5975. aTop = _getBoundsForNode.top,
  5976. aLeft = _getBoundsForNode.left,
  5977. _getBoundsForNode$rig = _getBoundsForNode.right,
  5978. aRight = _getBoundsForNode$rig === void 0 ? aLeft : _getBoundsForNode$rig,
  5979. _getBoundsForNode$bot = _getBoundsForNode.bottom,
  5980. aBottom = _getBoundsForNode$bot === void 0 ? aTop : _getBoundsForNode$bot;
  5981. var _getBoundsForNode2 = getBoundsForNode(nodeB),
  5982. bTop = _getBoundsForNode2.top,
  5983. bLeft = _getBoundsForNode2.left,
  5984. _getBoundsForNode2$ri = _getBoundsForNode2.right,
  5985. bRight = _getBoundsForNode2$ri === void 0 ? bLeft : _getBoundsForNode2$ri,
  5986. _getBoundsForNode2$bo = _getBoundsForNode2.bottom,
  5987. bBottom = _getBoundsForNode2$bo === void 0 ? bTop : _getBoundsForNode2$bo;
  5988. return !( // 'a' bottom doesn't touch 'b' top
  5989. aBottom - tolerance < bTop || // 'a' top doesn't touch 'b' bottom
  5990. aTop + tolerance > bBottom || // 'a' right doesn't touch 'b' left
  5991. aRight - tolerance < bLeft || // 'a' left doesn't touch 'b' right
  5992. aLeft + tolerance > bRight);
  5993. }
  5994. /**
  5995. * Given a node, get everything needed to calculate its boundaries
  5996. * @param {HTMLElement} node
  5997. * @return {Object}
  5998. */
  5999. function getBoundsForNode(node) {
  6000. if (!node.getBoundingClientRect) return node;
  6001. var rect = node.getBoundingClientRect(),
  6002. left = rect.left + pageOffset('left'),
  6003. top = rect.top + pageOffset('top');
  6004. return {
  6005. top: top,
  6006. left: left,
  6007. right: (node.offsetWidth || 0) + left,
  6008. bottom: (node.offsetHeight || 0) + top
  6009. };
  6010. }
  6011. function pageOffset(dir) {
  6012. if (dir === 'left') return window.pageXOffset || document.body.scrollLeft || 0;
  6013. if (dir === 'top') return window.pageYOffset || document.body.scrollTop || 0;
  6014. }
  6015. var BackgroundCells =
  6016. /*#__PURE__*/
  6017. function (_React$Component) {
  6018. _inheritsLoose(BackgroundCells, _React$Component);
  6019. function BackgroundCells(props, context) {
  6020. var _this;
  6021. _this = _React$Component.call(this, props, context) || this;
  6022. _this.state = {
  6023. selecting: false
  6024. };
  6025. return _this;
  6026. }
  6027. var _proto = BackgroundCells.prototype;
  6028. _proto.componentDidMount = function componentDidMount() {
  6029. this.props.selectable && this._selectable();
  6030. };
  6031. _proto.componentWillUnmount = function componentWillUnmount() {
  6032. this._teardownSelectable();
  6033. };
  6034. _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
  6035. if (nextProps.selectable && !this.props.selectable) this._selectable();
  6036. if (!nextProps.selectable && this.props.selectable) this._teardownSelectable();
  6037. };
  6038. _proto.render = function render() {
  6039. var _this$props = this.props,
  6040. range = _this$props.range,
  6041. getNow = _this$props.getNow,
  6042. getters = _this$props.getters,
  6043. currentDate = _this$props.date,
  6044. Wrapper = _this$props.components.dateCellWrapper;
  6045. var _this$state = this.state,
  6046. selecting = _this$state.selecting,
  6047. startIdx = _this$state.startIdx,
  6048. endIdx = _this$state.endIdx;
  6049. var current = getNow();
  6050. return React__default.createElement("div", {
  6051. className: "rbc-row-bg"
  6052. }, range.map(function (date, index) {
  6053. var selected = selecting && index >= startIdx && index <= endIdx;
  6054. var _getters$dayProp = getters.dayProp(date),
  6055. className = _getters$dayProp.className,
  6056. style = _getters$dayProp.style;
  6057. return React__default.createElement(Wrapper, {
  6058. key: index,
  6059. value: date,
  6060. range: range
  6061. }, React__default.createElement("div", {
  6062. style: style,
  6063. className: clsx('rbc-day-bg', className, selected && 'rbc-selected-cell', eq(date, current, 'day') && 'rbc-today', currentDate && month(currentDate) !== month(date) && 'rbc-off-range-bg')
  6064. }));
  6065. }));
  6066. };
  6067. _proto._selectable = function _selectable() {
  6068. var _this2 = this;
  6069. var node = ReactDOM.findDOMNode(this);
  6070. var selector = this._selector = new Selection(this.props.container, {
  6071. longPressThreshold: this.props.longPressThreshold
  6072. });
  6073. var selectorClicksHandler = function selectorClicksHandler(point, actionType) {
  6074. if (!isEvent(ReactDOM.findDOMNode(_this2), point)) {
  6075. var rowBox = getBoundsForNode(node);
  6076. var _this2$props = _this2.props,
  6077. range = _this2$props.range,
  6078. rtl = _this2$props.rtl;
  6079. if (pointInBox(rowBox, point)) {
  6080. var currentCell = getSlotAtX(rowBox, point.x, rtl, range.length);
  6081. _this2._selectSlot({
  6082. startIdx: currentCell,
  6083. endIdx: currentCell,
  6084. action: actionType,
  6085. box: point
  6086. });
  6087. }
  6088. }
  6089. _this2._initial = {};
  6090. _this2.setState({
  6091. selecting: false
  6092. });
  6093. };
  6094. selector.on('selecting', function (box) {
  6095. var _this2$props2 = _this2.props,
  6096. range = _this2$props2.range,
  6097. rtl = _this2$props2.rtl;
  6098. var startIdx = -1;
  6099. var endIdx = -1;
  6100. if (!_this2.state.selecting) {
  6101. notify(_this2.props.onSelectStart, [box]);
  6102. _this2._initial = {
  6103. x: box.x,
  6104. y: box.y
  6105. };
  6106. }
  6107. if (selector.isSelected(node)) {
  6108. var nodeBox = getBoundsForNode(node);
  6109. var _dateCellSelection = dateCellSelection(_this2._initial, nodeBox, box, range.length, rtl);
  6110. startIdx = _dateCellSelection.startIdx;
  6111. endIdx = _dateCellSelection.endIdx;
  6112. }
  6113. _this2.setState({
  6114. selecting: true,
  6115. startIdx: startIdx,
  6116. endIdx: endIdx
  6117. });
  6118. });
  6119. selector.on('beforeSelect', function (box) {
  6120. if (_this2.props.selectable !== 'ignoreEvents') return;
  6121. return !isEvent(ReactDOM.findDOMNode(_this2), box);
  6122. });
  6123. selector.on('click', function (point) {
  6124. return selectorClicksHandler(point, 'click');
  6125. });
  6126. selector.on('doubleClick', function (point) {
  6127. return selectorClicksHandler(point, 'doubleClick');
  6128. });
  6129. selector.on('select', function (bounds) {
  6130. _this2._selectSlot(_extends({}, _this2.state, {
  6131. action: 'select',
  6132. bounds: bounds
  6133. }));
  6134. _this2._initial = {};
  6135. _this2.setState({
  6136. selecting: false
  6137. });
  6138. notify(_this2.props.onSelectEnd, [_this2.state]);
  6139. });
  6140. };
  6141. _proto._teardownSelectable = function _teardownSelectable() {
  6142. if (!this._selector) return;
  6143. this._selector.teardown();
  6144. this._selector = null;
  6145. };
  6146. _proto._selectSlot = function _selectSlot(_ref) {
  6147. var endIdx = _ref.endIdx,
  6148. startIdx = _ref.startIdx,
  6149. action = _ref.action,
  6150. bounds = _ref.bounds,
  6151. box = _ref.box;
  6152. if (endIdx !== -1 && startIdx !== -1) this.props.onSelectSlot && this.props.onSelectSlot({
  6153. start: startIdx,
  6154. end: endIdx,
  6155. action: action,
  6156. bounds: bounds,
  6157. box: box
  6158. });
  6159. };
  6160. return BackgroundCells;
  6161. }(React__default.Component);
  6162. BackgroundCells.propTypes = {
  6163. date: propTypes.instanceOf(Date),
  6164. getNow: propTypes.func.isRequired,
  6165. getters: propTypes.object.isRequired,
  6166. components: propTypes.object.isRequired,
  6167. container: propTypes.func,
  6168. dayPropGetter: propTypes.func,
  6169. selectable: propTypes.oneOf([true, false, 'ignoreEvents']),
  6170. longPressThreshold: propTypes.number,
  6171. onSelectSlot: propTypes.func.isRequired,
  6172. onSelectEnd: propTypes.func,
  6173. onSelectStart: propTypes.func,
  6174. range: propTypes.arrayOf(propTypes.instanceOf(Date)),
  6175. rtl: propTypes.bool,
  6176. type: propTypes.string
  6177. };
  6178. /* eslint-disable react/prop-types */
  6179. var EventRowMixin = {
  6180. propTypes: {
  6181. slotMetrics: propTypes.object.isRequired,
  6182. selected: propTypes.object,
  6183. isAllDay: propTypes.bool,
  6184. accessors: propTypes.object.isRequired,
  6185. localizer: propTypes.object.isRequired,
  6186. components: propTypes.object.isRequired,
  6187. getters: propTypes.object.isRequired,
  6188. onSelect: propTypes.func,
  6189. onDoubleClick: propTypes.func
  6190. },
  6191. defaultProps: {
  6192. segments: [],
  6193. selected: {}
  6194. },
  6195. renderEvent: function renderEvent(props, event) {
  6196. var selected = props.selected,
  6197. _ = props.isAllDay,
  6198. accessors = props.accessors,
  6199. getters = props.getters,
  6200. onSelect = props.onSelect,
  6201. onDoubleClick = props.onDoubleClick,
  6202. localizer = props.localizer,
  6203. slotMetrics = props.slotMetrics,
  6204. components = props.components;
  6205. var continuesPrior = slotMetrics.continuesPrior(event);
  6206. var continuesAfter = slotMetrics.continuesAfter(event);
  6207. return React__default.createElement(EventCell, {
  6208. event: event,
  6209. getters: getters,
  6210. localizer: localizer,
  6211. accessors: accessors,
  6212. components: components,
  6213. onSelect: onSelect,
  6214. onDoubleClick: onDoubleClick,
  6215. continuesPrior: continuesPrior,
  6216. continuesAfter: continuesAfter,
  6217. slotStart: slotMetrics.first,
  6218. slotEnd: slotMetrics.last,
  6219. selected: isSelected(event, selected)
  6220. });
  6221. },
  6222. renderSpan: function renderSpan(slots, len, key, content) {
  6223. if (content === void 0) {
  6224. content = ' ';
  6225. }
  6226. var per = Math.abs(len) / slots * 100 + '%';
  6227. return React__default.createElement("div", {
  6228. key: key,
  6229. className: "rbc-row-segment" // IE10/11 need max-width. flex-basis doesn't respect box-sizing
  6230. ,
  6231. style: {
  6232. WebkitFlexBasis: per,
  6233. flexBasis: per,
  6234. maxWidth: per
  6235. }
  6236. }, content);
  6237. }
  6238. };
  6239. var EventRow =
  6240. /*#__PURE__*/
  6241. function (_React$Component) {
  6242. _inheritsLoose(EventRow, _React$Component);
  6243. function EventRow() {
  6244. return _React$Component.apply(this, arguments) || this;
  6245. }
  6246. var _proto = EventRow.prototype;
  6247. _proto.render = function render() {
  6248. var _this = this;
  6249. var _this$props = this.props,
  6250. segments = _this$props.segments,
  6251. slots = _this$props.slotMetrics.slots,
  6252. className = _this$props.className;
  6253. var lastEnd = 1;
  6254. return React__default.createElement("div", {
  6255. className: clsx(className, 'rbc-row')
  6256. }, segments.reduce(function (row, _ref, li) {
  6257. var event = _ref.event,
  6258. left = _ref.left,
  6259. right = _ref.right,
  6260. span = _ref.span;
  6261. var key = '_lvl_' + li;
  6262. var gap = left - lastEnd;
  6263. var content = EventRowMixin.renderEvent(_this.props, event);
  6264. if (gap) row.push(EventRowMixin.renderSpan(slots, gap, key + "_gap"));
  6265. row.push(EventRowMixin.renderSpan(slots, span, key, content));
  6266. lastEnd = right + 1;
  6267. return row;
  6268. }, []));
  6269. };
  6270. return EventRow;
  6271. }(React__default.Component);
  6272. EventRow.propTypes = _extends({
  6273. segments: propTypes.array
  6274. }, EventRowMixin.propTypes);
  6275. EventRow.defaultProps = _extends({}, EventRowMixin.defaultProps);
  6276. /**
  6277. * The base implementation of `_.findIndex` and `_.findLastIndex` without
  6278. * support for iteratee shorthands.
  6279. *
  6280. * @private
  6281. * @param {Array} array The array to inspect.
  6282. * @param {Function} predicate The function invoked per iteration.
  6283. * @param {number} fromIndex The index to search from.
  6284. * @param {boolean} [fromRight] Specify iterating from right to left.
  6285. * @returns {number} Returns the index of the matched value, else `-1`.
  6286. */
  6287. function baseFindIndex(array, predicate, fromIndex, fromRight) {
  6288. var length = array.length,
  6289. index = fromIndex + (fromRight ? 1 : -1);
  6290. while ((fromRight ? index-- : ++index < length)) {
  6291. if (predicate(array[index], index, array)) {
  6292. return index;
  6293. }
  6294. }
  6295. return -1;
  6296. }
  6297. /**
  6298. * Removes all key-value entries from the list cache.
  6299. *
  6300. * @private
  6301. * @name clear
  6302. * @memberOf ListCache
  6303. */
  6304. function listCacheClear() {
  6305. this.__data__ = [];
  6306. this.size = 0;
  6307. }
  6308. /**
  6309. * Gets the index at which the `key` is found in `array` of key-value pairs.
  6310. *
  6311. * @private
  6312. * @param {Array} array The array to inspect.
  6313. * @param {*} key The key to search for.
  6314. * @returns {number} Returns the index of the matched value, else `-1`.
  6315. */
  6316. function assocIndexOf(array, key) {
  6317. var length = array.length;
  6318. while (length--) {
  6319. if (eq$1(array[length][0], key)) {
  6320. return length;
  6321. }
  6322. }
  6323. return -1;
  6324. }
  6325. /** Used for built-in method references. */
  6326. var arrayProto = Array.prototype;
  6327. /** Built-in value references. */
  6328. var splice = arrayProto.splice;
  6329. /**
  6330. * Removes `key` and its value from the list cache.
  6331. *
  6332. * @private
  6333. * @name delete
  6334. * @memberOf ListCache
  6335. * @param {string} key The key of the value to remove.
  6336. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  6337. */
  6338. function listCacheDelete(key) {
  6339. var data = this.__data__,
  6340. index = assocIndexOf(data, key);
  6341. if (index < 0) {
  6342. return false;
  6343. }
  6344. var lastIndex = data.length - 1;
  6345. if (index == lastIndex) {
  6346. data.pop();
  6347. } else {
  6348. splice.call(data, index, 1);
  6349. }
  6350. --this.size;
  6351. return true;
  6352. }
  6353. /**
  6354. * Gets the list cache value for `key`.
  6355. *
  6356. * @private
  6357. * @name get
  6358. * @memberOf ListCache
  6359. * @param {string} key The key of the value to get.
  6360. * @returns {*} Returns the entry value.
  6361. */
  6362. function listCacheGet(key) {
  6363. var data = this.__data__,
  6364. index = assocIndexOf(data, key);
  6365. return index < 0 ? undefined : data[index][1];
  6366. }
  6367. /**
  6368. * Checks if a list cache value for `key` exists.
  6369. *
  6370. * @private
  6371. * @name has
  6372. * @memberOf ListCache
  6373. * @param {string} key The key of the entry to check.
  6374. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6375. */
  6376. function listCacheHas(key) {
  6377. return assocIndexOf(this.__data__, key) > -1;
  6378. }
  6379. /**
  6380. * Sets the list cache `key` to `value`.
  6381. *
  6382. * @private
  6383. * @name set
  6384. * @memberOf ListCache
  6385. * @param {string} key The key of the value to set.
  6386. * @param {*} value The value to set.
  6387. * @returns {Object} Returns the list cache instance.
  6388. */
  6389. function listCacheSet(key, value) {
  6390. var data = this.__data__,
  6391. index = assocIndexOf(data, key);
  6392. if (index < 0) {
  6393. ++this.size;
  6394. data.push([key, value]);
  6395. } else {
  6396. data[index][1] = value;
  6397. }
  6398. return this;
  6399. }
  6400. /**
  6401. * Creates an list cache object.
  6402. *
  6403. * @private
  6404. * @constructor
  6405. * @param {Array} [entries] The key-value pairs to cache.
  6406. */
  6407. function ListCache(entries) {
  6408. var index = -1,
  6409. length = entries == null ? 0 : entries.length;
  6410. this.clear();
  6411. while (++index < length) {
  6412. var entry = entries[index];
  6413. this.set(entry[0], entry[1]);
  6414. }
  6415. }
  6416. // Add methods to `ListCache`.
  6417. ListCache.prototype.clear = listCacheClear;
  6418. ListCache.prototype['delete'] = listCacheDelete;
  6419. ListCache.prototype.get = listCacheGet;
  6420. ListCache.prototype.has = listCacheHas;
  6421. ListCache.prototype.set = listCacheSet;
  6422. /**
  6423. * Removes all key-value entries from the stack.
  6424. *
  6425. * @private
  6426. * @name clear
  6427. * @memberOf Stack
  6428. */
  6429. function stackClear() {
  6430. this.__data__ = new ListCache;
  6431. this.size = 0;
  6432. }
  6433. /**
  6434. * Removes `key` and its value from the stack.
  6435. *
  6436. * @private
  6437. * @name delete
  6438. * @memberOf Stack
  6439. * @param {string} key The key of the value to remove.
  6440. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  6441. */
  6442. function stackDelete(key) {
  6443. var data = this.__data__,
  6444. result = data['delete'](key);
  6445. this.size = data.size;
  6446. return result;
  6447. }
  6448. /**
  6449. * Gets the stack value for `key`.
  6450. *
  6451. * @private
  6452. * @name get
  6453. * @memberOf Stack
  6454. * @param {string} key The key of the value to get.
  6455. * @returns {*} Returns the entry value.
  6456. */
  6457. function stackGet(key) {
  6458. return this.__data__.get(key);
  6459. }
  6460. /**
  6461. * Checks if a stack value for `key` exists.
  6462. *
  6463. * @private
  6464. * @name has
  6465. * @memberOf Stack
  6466. * @param {string} key The key of the entry to check.
  6467. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6468. */
  6469. function stackHas(key) {
  6470. return this.__data__.has(key);
  6471. }
  6472. /** Used to detect overreaching core-js shims. */
  6473. var coreJsData = root['__core-js_shared__'];
  6474. /** Used to detect methods masquerading as native. */
  6475. var maskSrcKey = (function() {
  6476. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  6477. return uid ? ('Symbol(src)_1.' + uid) : '';
  6478. }());
  6479. /**
  6480. * Checks if `func` has its source masked.
  6481. *
  6482. * @private
  6483. * @param {Function} func The function to check.
  6484. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  6485. */
  6486. function isMasked(func) {
  6487. return !!maskSrcKey && (maskSrcKey in func);
  6488. }
  6489. /** Used for built-in method references. */
  6490. var funcProto = Function.prototype;
  6491. /** Used to resolve the decompiled source of functions. */
  6492. var funcToString = funcProto.toString;
  6493. /**
  6494. * Converts `func` to its source code.
  6495. *
  6496. * @private
  6497. * @param {Function} func The function to convert.
  6498. * @returns {string} Returns the source code.
  6499. */
  6500. function toSource(func) {
  6501. if (func != null) {
  6502. try {
  6503. return funcToString.call(func);
  6504. } catch (e) {}
  6505. try {
  6506. return (func + '');
  6507. } catch (e) {}
  6508. }
  6509. return '';
  6510. }
  6511. /**
  6512. * Used to match `RegExp`
  6513. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  6514. */
  6515. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  6516. /** Used to detect host constructors (Safari). */
  6517. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  6518. /** Used for built-in method references. */
  6519. var funcProto$1 = Function.prototype,
  6520. objectProto$2 = Object.prototype;
  6521. /** Used to resolve the decompiled source of functions. */
  6522. var funcToString$1 = funcProto$1.toString;
  6523. /** Used to check objects for own properties. */
  6524. var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
  6525. /** Used to detect if a method is native. */
  6526. var reIsNative = RegExp('^' +
  6527. funcToString$1.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
  6528. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  6529. );
  6530. /**
  6531. * The base implementation of `_.isNative` without bad shim checks.
  6532. *
  6533. * @private
  6534. * @param {*} value The value to check.
  6535. * @returns {boolean} Returns `true` if `value` is a native function,
  6536. * else `false`.
  6537. */
  6538. function baseIsNative(value) {
  6539. if (!isObject(value) || isMasked(value)) {
  6540. return false;
  6541. }
  6542. var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
  6543. return pattern.test(toSource(value));
  6544. }
  6545. /**
  6546. * Gets the value at `key` of `object`.
  6547. *
  6548. * @private
  6549. * @param {Object} [object] The object to query.
  6550. * @param {string} key The key of the property to get.
  6551. * @returns {*} Returns the property value.
  6552. */
  6553. function getValue(object, key) {
  6554. return object == null ? undefined : object[key];
  6555. }
  6556. /**
  6557. * Gets the native function at `key` of `object`.
  6558. *
  6559. * @private
  6560. * @param {Object} object The object to query.
  6561. * @param {string} key The key of the method to get.
  6562. * @returns {*} Returns the function if it's native, else `undefined`.
  6563. */
  6564. function getNative(object, key) {
  6565. var value = getValue(object, key);
  6566. return baseIsNative(value) ? value : undefined;
  6567. }
  6568. /* Built-in method references that are verified to be native. */
  6569. var Map$1 = getNative(root, 'Map');
  6570. /* Built-in method references that are verified to be native. */
  6571. var nativeCreate = getNative(Object, 'create');
  6572. /**
  6573. * Removes all key-value entries from the hash.
  6574. *
  6575. * @private
  6576. * @name clear
  6577. * @memberOf Hash
  6578. */
  6579. function hashClear() {
  6580. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  6581. this.size = 0;
  6582. }
  6583. /**
  6584. * Removes `key` and its value from the hash.
  6585. *
  6586. * @private
  6587. * @name delete
  6588. * @memberOf Hash
  6589. * @param {Object} hash The hash to modify.
  6590. * @param {string} key The key of the value to remove.
  6591. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  6592. */
  6593. function hashDelete(key) {
  6594. var result = this.has(key) && delete this.__data__[key];
  6595. this.size -= result ? 1 : 0;
  6596. return result;
  6597. }
  6598. /** Used to stand-in for `undefined` hash values. */
  6599. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  6600. /** Used for built-in method references. */
  6601. var objectProto$3 = Object.prototype;
  6602. /** Used to check objects for own properties. */
  6603. var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
  6604. /**
  6605. * Gets the hash value for `key`.
  6606. *
  6607. * @private
  6608. * @name get
  6609. * @memberOf Hash
  6610. * @param {string} key The key of the value to get.
  6611. * @returns {*} Returns the entry value.
  6612. */
  6613. function hashGet(key) {
  6614. var data = this.__data__;
  6615. if (nativeCreate) {
  6616. var result = data[key];
  6617. return result === HASH_UNDEFINED ? undefined : result;
  6618. }
  6619. return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
  6620. }
  6621. /** Used for built-in method references. */
  6622. var objectProto$4 = Object.prototype;
  6623. /** Used to check objects for own properties. */
  6624. var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
  6625. /**
  6626. * Checks if a hash value for `key` exists.
  6627. *
  6628. * @private
  6629. * @name has
  6630. * @memberOf Hash
  6631. * @param {string} key The key of the entry to check.
  6632. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6633. */
  6634. function hashHas(key) {
  6635. var data = this.__data__;
  6636. return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$4.call(data, key);
  6637. }
  6638. /** Used to stand-in for `undefined` hash values. */
  6639. var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
  6640. /**
  6641. * Sets the hash `key` to `value`.
  6642. *
  6643. * @private
  6644. * @name set
  6645. * @memberOf Hash
  6646. * @param {string} key The key of the value to set.
  6647. * @param {*} value The value to set.
  6648. * @returns {Object} Returns the hash instance.
  6649. */
  6650. function hashSet(key, value) {
  6651. var data = this.__data__;
  6652. this.size += this.has(key) ? 0 : 1;
  6653. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
  6654. return this;
  6655. }
  6656. /**
  6657. * Creates a hash object.
  6658. *
  6659. * @private
  6660. * @constructor
  6661. * @param {Array} [entries] The key-value pairs to cache.
  6662. */
  6663. function Hash(entries) {
  6664. var index = -1,
  6665. length = entries == null ? 0 : entries.length;
  6666. this.clear();
  6667. while (++index < length) {
  6668. var entry = entries[index];
  6669. this.set(entry[0], entry[1]);
  6670. }
  6671. }
  6672. // Add methods to `Hash`.
  6673. Hash.prototype.clear = hashClear;
  6674. Hash.prototype['delete'] = hashDelete;
  6675. Hash.prototype.get = hashGet;
  6676. Hash.prototype.has = hashHas;
  6677. Hash.prototype.set = hashSet;
  6678. /**
  6679. * Removes all key-value entries from the map.
  6680. *
  6681. * @private
  6682. * @name clear
  6683. * @memberOf MapCache
  6684. */
  6685. function mapCacheClear() {
  6686. this.size = 0;
  6687. this.__data__ = {
  6688. 'hash': new Hash,
  6689. 'map': new (Map$1 || ListCache),
  6690. 'string': new Hash
  6691. };
  6692. }
  6693. /**
  6694. * Checks if `value` is suitable for use as unique object key.
  6695. *
  6696. * @private
  6697. * @param {*} value The value to check.
  6698. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  6699. */
  6700. function isKeyable(value) {
  6701. var type = typeof value;
  6702. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  6703. ? (value !== '__proto__')
  6704. : (value === null);
  6705. }
  6706. /**
  6707. * Gets the data for `map`.
  6708. *
  6709. * @private
  6710. * @param {Object} map The map to query.
  6711. * @param {string} key The reference key.
  6712. * @returns {*} Returns the map data.
  6713. */
  6714. function getMapData(map, key) {
  6715. var data = map.__data__;
  6716. return isKeyable(key)
  6717. ? data[typeof key == 'string' ? 'string' : 'hash']
  6718. : data.map;
  6719. }
  6720. /**
  6721. * Removes `key` and its value from the map.
  6722. *
  6723. * @private
  6724. * @name delete
  6725. * @memberOf MapCache
  6726. * @param {string} key The key of the value to remove.
  6727. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  6728. */
  6729. function mapCacheDelete(key) {
  6730. var result = getMapData(this, key)['delete'](key);
  6731. this.size -= result ? 1 : 0;
  6732. return result;
  6733. }
  6734. /**
  6735. * Gets the map value for `key`.
  6736. *
  6737. * @private
  6738. * @name get
  6739. * @memberOf MapCache
  6740. * @param {string} key The key of the value to get.
  6741. * @returns {*} Returns the entry value.
  6742. */
  6743. function mapCacheGet(key) {
  6744. return getMapData(this, key).get(key);
  6745. }
  6746. /**
  6747. * Checks if a map value for `key` exists.
  6748. *
  6749. * @private
  6750. * @name has
  6751. * @memberOf MapCache
  6752. * @param {string} key The key of the entry to check.
  6753. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6754. */
  6755. function mapCacheHas(key) {
  6756. return getMapData(this, key).has(key);
  6757. }
  6758. /**
  6759. * Sets the map `key` to `value`.
  6760. *
  6761. * @private
  6762. * @name set
  6763. * @memberOf MapCache
  6764. * @param {string} key The key of the value to set.
  6765. * @param {*} value The value to set.
  6766. * @returns {Object} Returns the map cache instance.
  6767. */
  6768. function mapCacheSet(key, value) {
  6769. var data = getMapData(this, key),
  6770. size = data.size;
  6771. data.set(key, value);
  6772. this.size += data.size == size ? 0 : 1;
  6773. return this;
  6774. }
  6775. /**
  6776. * Creates a map cache object to store key-value pairs.
  6777. *
  6778. * @private
  6779. * @constructor
  6780. * @param {Array} [entries] The key-value pairs to cache.
  6781. */
  6782. function MapCache(entries) {
  6783. var index = -1,
  6784. length = entries == null ? 0 : entries.length;
  6785. this.clear();
  6786. while (++index < length) {
  6787. var entry = entries[index];
  6788. this.set(entry[0], entry[1]);
  6789. }
  6790. }
  6791. // Add methods to `MapCache`.
  6792. MapCache.prototype.clear = mapCacheClear;
  6793. MapCache.prototype['delete'] = mapCacheDelete;
  6794. MapCache.prototype.get = mapCacheGet;
  6795. MapCache.prototype.has = mapCacheHas;
  6796. MapCache.prototype.set = mapCacheSet;
  6797. /** Used as the size to enable large array optimizations. */
  6798. var LARGE_ARRAY_SIZE = 200;
  6799. /**
  6800. * Sets the stack `key` to `value`.
  6801. *
  6802. * @private
  6803. * @name set
  6804. * @memberOf Stack
  6805. * @param {string} key The key of the value to set.
  6806. * @param {*} value The value to set.
  6807. * @returns {Object} Returns the stack cache instance.
  6808. */
  6809. function stackSet(key, value) {
  6810. var data = this.__data__;
  6811. if (data instanceof ListCache) {
  6812. var pairs = data.__data__;
  6813. if (!Map$1 || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
  6814. pairs.push([key, value]);
  6815. this.size = ++data.size;
  6816. return this;
  6817. }
  6818. data = this.__data__ = new MapCache(pairs);
  6819. }
  6820. data.set(key, value);
  6821. this.size = data.size;
  6822. return this;
  6823. }
  6824. /**
  6825. * Creates a stack cache object to store key-value pairs.
  6826. *
  6827. * @private
  6828. * @constructor
  6829. * @param {Array} [entries] The key-value pairs to cache.
  6830. */
  6831. function Stack(entries) {
  6832. var data = this.__data__ = new ListCache(entries);
  6833. this.size = data.size;
  6834. }
  6835. // Add methods to `Stack`.
  6836. Stack.prototype.clear = stackClear;
  6837. Stack.prototype['delete'] = stackDelete;
  6838. Stack.prototype.get = stackGet;
  6839. Stack.prototype.has = stackHas;
  6840. Stack.prototype.set = stackSet;
  6841. /** Used to stand-in for `undefined` hash values. */
  6842. var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
  6843. /**
  6844. * Adds `value` to the array cache.
  6845. *
  6846. * @private
  6847. * @name add
  6848. * @memberOf SetCache
  6849. * @alias push
  6850. * @param {*} value The value to cache.
  6851. * @returns {Object} Returns the cache instance.
  6852. */
  6853. function setCacheAdd(value) {
  6854. this.__data__.set(value, HASH_UNDEFINED$2);
  6855. return this;
  6856. }
  6857. /**
  6858. * Checks if `value` is in the array cache.
  6859. *
  6860. * @private
  6861. * @name has
  6862. * @memberOf SetCache
  6863. * @param {*} value The value to search for.
  6864. * @returns {number} Returns `true` if `value` is found, else `false`.
  6865. */
  6866. function setCacheHas(value) {
  6867. return this.__data__.has(value);
  6868. }
  6869. /**
  6870. *
  6871. * Creates an array cache object to store unique values.
  6872. *
  6873. * @private
  6874. * @constructor
  6875. * @param {Array} [values] The values to cache.
  6876. */
  6877. function SetCache(values) {
  6878. var index = -1,
  6879. length = values == null ? 0 : values.length;
  6880. this.__data__ = new MapCache;
  6881. while (++index < length) {
  6882. this.add(values[index]);
  6883. }
  6884. }
  6885. // Add methods to `SetCache`.
  6886. SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
  6887. SetCache.prototype.has = setCacheHas;
  6888. /**
  6889. * A specialized version of `_.some` for arrays without support for iteratee
  6890. * shorthands.
  6891. *
  6892. * @private
  6893. * @param {Array} [array] The array to iterate over.
  6894. * @param {Function} predicate The function invoked per iteration.
  6895. * @returns {boolean} Returns `true` if any element passes the predicate check,
  6896. * else `false`.
  6897. */
  6898. function arraySome(array, predicate) {
  6899. var index = -1,
  6900. length = array == null ? 0 : array.length;
  6901. while (++index < length) {
  6902. if (predicate(array[index], index, array)) {
  6903. return true;
  6904. }
  6905. }
  6906. return false;
  6907. }
  6908. /**
  6909. * Checks if a `cache` value for `key` exists.
  6910. *
  6911. * @private
  6912. * @param {Object} cache The cache to query.
  6913. * @param {string} key The key of the entry to check.
  6914. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  6915. */
  6916. function cacheHas(cache, key) {
  6917. return cache.has(key);
  6918. }
  6919. /** Used to compose bitmasks for value comparisons. */
  6920. var COMPARE_PARTIAL_FLAG = 1,
  6921. COMPARE_UNORDERED_FLAG = 2;
  6922. /**
  6923. * A specialized version of `baseIsEqualDeep` for arrays with support for
  6924. * partial deep comparisons.
  6925. *
  6926. * @private
  6927. * @param {Array} array The array to compare.
  6928. * @param {Array} other The other array to compare.
  6929. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  6930. * @param {Function} customizer The function to customize comparisons.
  6931. * @param {Function} equalFunc The function to determine equivalents of values.
  6932. * @param {Object} stack Tracks traversed `array` and `other` objects.
  6933. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
  6934. */
  6935. function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
  6936. var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
  6937. arrLength = array.length,
  6938. othLength = other.length;
  6939. if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
  6940. return false;
  6941. }
  6942. // Assume cyclic values are equal.
  6943. var stacked = stack.get(array);
  6944. if (stacked && stack.get(other)) {
  6945. return stacked == other;
  6946. }
  6947. var index = -1,
  6948. result = true,
  6949. seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
  6950. stack.set(array, other);
  6951. stack.set(other, array);
  6952. // Ignore non-index properties.
  6953. while (++index < arrLength) {
  6954. var arrValue = array[index],
  6955. othValue = other[index];
  6956. if (customizer) {
  6957. var compared = isPartial
  6958. ? customizer(othValue, arrValue, index, other, array, stack)
  6959. : customizer(arrValue, othValue, index, array, other, stack);
  6960. }
  6961. if (compared !== undefined) {
  6962. if (compared) {
  6963. continue;
  6964. }
  6965. result = false;
  6966. break;
  6967. }
  6968. // Recursively compare arrays (susceptible to call stack limits).
  6969. if (seen) {
  6970. if (!arraySome(other, function(othValue, othIndex) {
  6971. if (!cacheHas(seen, othIndex) &&
  6972. (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
  6973. return seen.push(othIndex);
  6974. }
  6975. })) {
  6976. result = false;
  6977. break;
  6978. }
  6979. } else if (!(
  6980. arrValue === othValue ||
  6981. equalFunc(arrValue, othValue, bitmask, customizer, stack)
  6982. )) {
  6983. result = false;
  6984. break;
  6985. }
  6986. }
  6987. stack['delete'](array);
  6988. stack['delete'](other);
  6989. return result;
  6990. }
  6991. /** Built-in value references. */
  6992. var Uint8Array = root.Uint8Array;
  6993. /**
  6994. * Converts `map` to its key-value pairs.
  6995. *
  6996. * @private
  6997. * @param {Object} map The map to convert.
  6998. * @returns {Array} Returns the key-value pairs.
  6999. */
  7000. function mapToArray(map) {
  7001. var index = -1,
  7002. result = Array(map.size);
  7003. map.forEach(function(value, key) {
  7004. result[++index] = [key, value];
  7005. });
  7006. return result;
  7007. }
  7008. /**
  7009. * Converts `set` to an array of its values.
  7010. *
  7011. * @private
  7012. * @param {Object} set The set to convert.
  7013. * @returns {Array} Returns the values.
  7014. */
  7015. function setToArray(set) {
  7016. var index = -1,
  7017. result = Array(set.size);
  7018. set.forEach(function(value) {
  7019. result[++index] = value;
  7020. });
  7021. return result;
  7022. }
  7023. /** Used to compose bitmasks for value comparisons. */
  7024. var COMPARE_PARTIAL_FLAG$1 = 1,
  7025. COMPARE_UNORDERED_FLAG$1 = 2;
  7026. /** `Object#toString` result references. */
  7027. var boolTag = '[object Boolean]',
  7028. dateTag = '[object Date]',
  7029. errorTag = '[object Error]',
  7030. mapTag = '[object Map]',
  7031. numberTag = '[object Number]',
  7032. regexpTag = '[object RegExp]',
  7033. setTag = '[object Set]',
  7034. stringTag = '[object String]',
  7035. symbolTag$1 = '[object Symbol]';
  7036. var arrayBufferTag = '[object ArrayBuffer]',
  7037. dataViewTag = '[object DataView]';
  7038. /** Used to convert symbols to primitives and strings. */
  7039. var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined,
  7040. symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
  7041. /**
  7042. * A specialized version of `baseIsEqualDeep` for comparing objects of
  7043. * the same `toStringTag`.
  7044. *
  7045. * **Note:** This function only supports comparing values with tags of
  7046. * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
  7047. *
  7048. * @private
  7049. * @param {Object} object The object to compare.
  7050. * @param {Object} other The other object to compare.
  7051. * @param {string} tag The `toStringTag` of the objects to compare.
  7052. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  7053. * @param {Function} customizer The function to customize comparisons.
  7054. * @param {Function} equalFunc The function to determine equivalents of values.
  7055. * @param {Object} stack Tracks traversed `object` and `other` objects.
  7056. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  7057. */
  7058. function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
  7059. switch (tag) {
  7060. case dataViewTag:
  7061. if ((object.byteLength != other.byteLength) ||
  7062. (object.byteOffset != other.byteOffset)) {
  7063. return false;
  7064. }
  7065. object = object.buffer;
  7066. other = other.buffer;
  7067. case arrayBufferTag:
  7068. if ((object.byteLength != other.byteLength) ||
  7069. !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
  7070. return false;
  7071. }
  7072. return true;
  7073. case boolTag:
  7074. case dateTag:
  7075. case numberTag:
  7076. // Coerce booleans to `1` or `0` and dates to milliseconds.
  7077. // Invalid dates are coerced to `NaN`.
  7078. return eq$1(+object, +other);
  7079. case errorTag:
  7080. return object.name == other.name && object.message == other.message;
  7081. case regexpTag:
  7082. case stringTag:
  7083. // Coerce regexes to strings and treat strings, primitives and objects,
  7084. // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
  7085. // for more details.
  7086. return object == (other + '');
  7087. case mapTag:
  7088. var convert = mapToArray;
  7089. case setTag:
  7090. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$1;
  7091. convert || (convert = setToArray);
  7092. if (object.size != other.size && !isPartial) {
  7093. return false;
  7094. }
  7095. // Assume cyclic values are equal.
  7096. var stacked = stack.get(object);
  7097. if (stacked) {
  7098. return stacked == other;
  7099. }
  7100. bitmask |= COMPARE_UNORDERED_FLAG$1;
  7101. // Recursively compare objects (susceptible to call stack limits).
  7102. stack.set(object, other);
  7103. var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
  7104. stack['delete'](object);
  7105. return result;
  7106. case symbolTag$1:
  7107. if (symbolValueOf) {
  7108. return symbolValueOf.call(object) == symbolValueOf.call(other);
  7109. }
  7110. }
  7111. return false;
  7112. }
  7113. /**
  7114. * Appends the elements of `values` to `array`.
  7115. *
  7116. * @private
  7117. * @param {Array} array The array to modify.
  7118. * @param {Array} values The values to append.
  7119. * @returns {Array} Returns `array`.
  7120. */
  7121. function arrayPush(array, values) {
  7122. var index = -1,
  7123. length = values.length,
  7124. offset = array.length;
  7125. while (++index < length) {
  7126. array[offset + index] = values[index];
  7127. }
  7128. return array;
  7129. }
  7130. /**
  7131. * Checks if `value` is classified as an `Array` object.
  7132. *
  7133. * @static
  7134. * @memberOf _
  7135. * @since 0.1.0
  7136. * @category Lang
  7137. * @param {*} value The value to check.
  7138. * @returns {boolean} Returns `true` if `value` is an array, else `false`.
  7139. * @example
  7140. *
  7141. * _.isArray([1, 2, 3]);
  7142. * // => true
  7143. *
  7144. * _.isArray(document.body.children);
  7145. * // => false
  7146. *
  7147. * _.isArray('abc');
  7148. * // => false
  7149. *
  7150. * _.isArray(_.noop);
  7151. * // => false
  7152. */
  7153. var isArray = Array.isArray;
  7154. /**
  7155. * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
  7156. * `keysFunc` and `symbolsFunc` to get the enumerable property names and
  7157. * symbols of `object`.
  7158. *
  7159. * @private
  7160. * @param {Object} object The object to query.
  7161. * @param {Function} keysFunc The function to get the keys of `object`.
  7162. * @param {Function} symbolsFunc The function to get the symbols of `object`.
  7163. * @returns {Array} Returns the array of property names and symbols.
  7164. */
  7165. function baseGetAllKeys(object, keysFunc, symbolsFunc) {
  7166. var result = keysFunc(object);
  7167. return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
  7168. }
  7169. /**
  7170. * A specialized version of `_.filter` for arrays without support for
  7171. * iteratee shorthands.
  7172. *
  7173. * @private
  7174. * @param {Array} [array] The array to iterate over.
  7175. * @param {Function} predicate The function invoked per iteration.
  7176. * @returns {Array} Returns the new filtered array.
  7177. */
  7178. function arrayFilter(array, predicate) {
  7179. var index = -1,
  7180. length = array == null ? 0 : array.length,
  7181. resIndex = 0,
  7182. result = [];
  7183. while (++index < length) {
  7184. var value = array[index];
  7185. if (predicate(value, index, array)) {
  7186. result[resIndex++] = value;
  7187. }
  7188. }
  7189. return result;
  7190. }
  7191. /**
  7192. * This method returns a new empty array.
  7193. *
  7194. * @static
  7195. * @memberOf _
  7196. * @since 4.13.0
  7197. * @category Util
  7198. * @returns {Array} Returns the new empty array.
  7199. * @example
  7200. *
  7201. * var arrays = _.times(2, _.stubArray);
  7202. *
  7203. * console.log(arrays);
  7204. * // => [[], []]
  7205. *
  7206. * console.log(arrays[0] === arrays[1]);
  7207. * // => false
  7208. */
  7209. function stubArray() {
  7210. return [];
  7211. }
  7212. /** Used for built-in method references. */
  7213. var objectProto$5 = Object.prototype;
  7214. /** Built-in value references. */
  7215. var propertyIsEnumerable = objectProto$5.propertyIsEnumerable;
  7216. /* Built-in method references for those with the same name as other `lodash` methods. */
  7217. var nativeGetSymbols = Object.getOwnPropertySymbols;
  7218. /**
  7219. * Creates an array of the own enumerable symbols of `object`.
  7220. *
  7221. * @private
  7222. * @param {Object} object The object to query.
  7223. * @returns {Array} Returns the array of symbols.
  7224. */
  7225. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  7226. if (object == null) {
  7227. return [];
  7228. }
  7229. object = Object(object);
  7230. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  7231. return propertyIsEnumerable.call(object, symbol);
  7232. });
  7233. };
  7234. /**
  7235. * The base implementation of `_.times` without support for iteratee shorthands
  7236. * or max array length checks.
  7237. *
  7238. * @private
  7239. * @param {number} n The number of times to invoke `iteratee`.
  7240. * @param {Function} iteratee The function invoked per iteration.
  7241. * @returns {Array} Returns the array of results.
  7242. */
  7243. function baseTimes(n, iteratee) {
  7244. var index = -1,
  7245. result = Array(n);
  7246. while (++index < n) {
  7247. result[index] = iteratee(index);
  7248. }
  7249. return result;
  7250. }
  7251. /** `Object#toString` result references. */
  7252. var argsTag = '[object Arguments]';
  7253. /**
  7254. * The base implementation of `_.isArguments`.
  7255. *
  7256. * @private
  7257. * @param {*} value The value to check.
  7258. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  7259. */
  7260. function baseIsArguments(value) {
  7261. return isObjectLike(value) && baseGetTag(value) == argsTag;
  7262. }
  7263. /** Used for built-in method references. */
  7264. var objectProto$6 = Object.prototype;
  7265. /** Used to check objects for own properties. */
  7266. var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
  7267. /** Built-in value references. */
  7268. var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
  7269. /**
  7270. * Checks if `value` is likely an `arguments` object.
  7271. *
  7272. * @static
  7273. * @memberOf _
  7274. * @since 0.1.0
  7275. * @category Lang
  7276. * @param {*} value The value to check.
  7277. * @returns {boolean} Returns `true` if `value` is an `arguments` object,
  7278. * else `false`.
  7279. * @example
  7280. *
  7281. * _.isArguments(function() { return arguments; }());
  7282. * // => true
  7283. *
  7284. * _.isArguments([1, 2, 3]);
  7285. * // => false
  7286. */
  7287. var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
  7288. return isObjectLike(value) && hasOwnProperty$5.call(value, 'callee') &&
  7289. !propertyIsEnumerable$1.call(value, 'callee');
  7290. };
  7291. /**
  7292. * This method returns `false`.
  7293. *
  7294. * @static
  7295. * @memberOf _
  7296. * @since 4.13.0
  7297. * @category Util
  7298. * @returns {boolean} Returns `false`.
  7299. * @example
  7300. *
  7301. * _.times(2, _.stubFalse);
  7302. * // => [false, false]
  7303. */
  7304. function stubFalse() {
  7305. return false;
  7306. }
  7307. /** Detect free variable `exports`. */
  7308. var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
  7309. /** Detect free variable `module`. */
  7310. var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
  7311. /** Detect the popular CommonJS extension `module.exports`. */
  7312. var moduleExports = freeModule && freeModule.exports === freeExports;
  7313. /** Built-in value references. */
  7314. var Buffer = moduleExports ? root.Buffer : undefined;
  7315. /* Built-in method references for those with the same name as other `lodash` methods. */
  7316. var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
  7317. /**
  7318. * Checks if `value` is a buffer.
  7319. *
  7320. * @static
  7321. * @memberOf _
  7322. * @since 4.3.0
  7323. * @category Lang
  7324. * @param {*} value The value to check.
  7325. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
  7326. * @example
  7327. *
  7328. * _.isBuffer(new Buffer(2));
  7329. * // => true
  7330. *
  7331. * _.isBuffer(new Uint8Array(2));
  7332. * // => false
  7333. */
  7334. var isBuffer = nativeIsBuffer || stubFalse;
  7335. /** `Object#toString` result references. */
  7336. var argsTag$1 = '[object Arguments]',
  7337. arrayTag = '[object Array]',
  7338. boolTag$1 = '[object Boolean]',
  7339. dateTag$1 = '[object Date]',
  7340. errorTag$1 = '[object Error]',
  7341. funcTag$1 = '[object Function]',
  7342. mapTag$1 = '[object Map]',
  7343. numberTag$1 = '[object Number]',
  7344. objectTag = '[object Object]',
  7345. regexpTag$1 = '[object RegExp]',
  7346. setTag$1 = '[object Set]',
  7347. stringTag$1 = '[object String]',
  7348. weakMapTag = '[object WeakMap]';
  7349. var arrayBufferTag$1 = '[object ArrayBuffer]',
  7350. dataViewTag$1 = '[object DataView]',
  7351. float32Tag = '[object Float32Array]',
  7352. float64Tag = '[object Float64Array]',
  7353. int8Tag = '[object Int8Array]',
  7354. int16Tag = '[object Int16Array]',
  7355. int32Tag = '[object Int32Array]',
  7356. uint8Tag = '[object Uint8Array]',
  7357. uint8ClampedTag = '[object Uint8ClampedArray]',
  7358. uint16Tag = '[object Uint16Array]',
  7359. uint32Tag = '[object Uint32Array]';
  7360. /** Used to identify `toStringTag` values of typed arrays. */
  7361. var typedArrayTags = {};
  7362. typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
  7363. typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
  7364. typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
  7365. typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
  7366. typedArrayTags[uint32Tag] = true;
  7367. typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
  7368. typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] =
  7369. typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag$1] =
  7370. typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] =
  7371. typedArrayTags[mapTag$1] = typedArrayTags[numberTag$1] =
  7372. typedArrayTags[objectTag] = typedArrayTags[regexpTag$1] =
  7373. typedArrayTags[setTag$1] = typedArrayTags[stringTag$1] =
  7374. typedArrayTags[weakMapTag] = false;
  7375. /**
  7376. * The base implementation of `_.isTypedArray` without Node.js optimizations.
  7377. *
  7378. * @private
  7379. * @param {*} value The value to check.
  7380. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  7381. */
  7382. function baseIsTypedArray(value) {
  7383. return isObjectLike(value) &&
  7384. isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
  7385. }
  7386. /**
  7387. * The base implementation of `_.unary` without support for storing metadata.
  7388. *
  7389. * @private
  7390. * @param {Function} func The function to cap arguments for.
  7391. * @returns {Function} Returns the new capped function.
  7392. */
  7393. function baseUnary(func) {
  7394. return function(value) {
  7395. return func(value);
  7396. };
  7397. }
  7398. /** Detect free variable `exports`. */
  7399. var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
  7400. /** Detect free variable `module`. */
  7401. var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
  7402. /** Detect the popular CommonJS extension `module.exports`. */
  7403. var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
  7404. /** Detect free variable `process` from Node.js. */
  7405. var freeProcess = moduleExports$1 && freeGlobal.process;
  7406. /** Used to access faster Node.js helpers. */
  7407. var nodeUtil = (function() {
  7408. try {
  7409. // Use `util.types` for Node.js 10+.
  7410. var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types;
  7411. if (types) {
  7412. return types;
  7413. }
  7414. // Legacy `process.binding('util')` for Node.js < 10.
  7415. return freeProcess && freeProcess.binding && freeProcess.binding('util');
  7416. } catch (e) {}
  7417. }());
  7418. /* Node.js helper references. */
  7419. var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
  7420. /**
  7421. * Checks if `value` is classified as a typed array.
  7422. *
  7423. * @static
  7424. * @memberOf _
  7425. * @since 3.0.0
  7426. * @category Lang
  7427. * @param {*} value The value to check.
  7428. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
  7429. * @example
  7430. *
  7431. * _.isTypedArray(new Uint8Array);
  7432. * // => true
  7433. *
  7434. * _.isTypedArray([]);
  7435. * // => false
  7436. */
  7437. var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
  7438. /** Used for built-in method references. */
  7439. var objectProto$7 = Object.prototype;
  7440. /** Used to check objects for own properties. */
  7441. var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
  7442. /**
  7443. * Creates an array of the enumerable property names of the array-like `value`.
  7444. *
  7445. * @private
  7446. * @param {*} value The value to query.
  7447. * @param {boolean} inherited Specify returning inherited property names.
  7448. * @returns {Array} Returns the array of property names.
  7449. */
  7450. function arrayLikeKeys(value, inherited) {
  7451. var isArr = isArray(value),
  7452. isArg = !isArr && isArguments(value),
  7453. isBuff = !isArr && !isArg && isBuffer(value),
  7454. isType = !isArr && !isArg && !isBuff && isTypedArray(value),
  7455. skipIndexes = isArr || isArg || isBuff || isType,
  7456. result = skipIndexes ? baseTimes(value.length, String) : [],
  7457. length = result.length;
  7458. for (var key in value) {
  7459. if ((inherited || hasOwnProperty$6.call(value, key)) &&
  7460. !(skipIndexes && (
  7461. // Safari 9 has enumerable `arguments.length` in strict mode.
  7462. key == 'length' ||
  7463. // Node.js 0.10 has enumerable non-index properties on buffers.
  7464. (isBuff && (key == 'offset' || key == 'parent')) ||
  7465. // PhantomJS 2 has enumerable non-index properties on typed arrays.
  7466. (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
  7467. // Skip index properties.
  7468. isIndex(key, length)
  7469. ))) {
  7470. result.push(key);
  7471. }
  7472. }
  7473. return result;
  7474. }
  7475. /** Used for built-in method references. */
  7476. var objectProto$8 = Object.prototype;
  7477. /**
  7478. * Checks if `value` is likely a prototype object.
  7479. *
  7480. * @private
  7481. * @param {*} value The value to check.
  7482. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
  7483. */
  7484. function isPrototype(value) {
  7485. var Ctor = value && value.constructor,
  7486. proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
  7487. return value === proto;
  7488. }
  7489. /**
  7490. * Creates a unary function that invokes `func` with its argument transformed.
  7491. *
  7492. * @private
  7493. * @param {Function} func The function to wrap.
  7494. * @param {Function} transform The argument transform.
  7495. * @returns {Function} Returns the new function.
  7496. */
  7497. function overArg(func, transform) {
  7498. return function(arg) {
  7499. return func(transform(arg));
  7500. };
  7501. }
  7502. /* Built-in method references for those with the same name as other `lodash` methods. */
  7503. var nativeKeys = overArg(Object.keys, Object);
  7504. /** Used for built-in method references. */
  7505. var objectProto$9 = Object.prototype;
  7506. /** Used to check objects for own properties. */
  7507. var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
  7508. /**
  7509. * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
  7510. *
  7511. * @private
  7512. * @param {Object} object The object to query.
  7513. * @returns {Array} Returns the array of property names.
  7514. */
  7515. function baseKeys(object) {
  7516. if (!isPrototype(object)) {
  7517. return nativeKeys(object);
  7518. }
  7519. var result = [];
  7520. for (var key in Object(object)) {
  7521. if (hasOwnProperty$7.call(object, key) && key != 'constructor') {
  7522. result.push(key);
  7523. }
  7524. }
  7525. return result;
  7526. }
  7527. /**
  7528. * Creates an array of the own enumerable property names of `object`.
  7529. *
  7530. * **Note:** Non-object values are coerced to objects. See the
  7531. * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  7532. * for more details.
  7533. *
  7534. * @static
  7535. * @since 0.1.0
  7536. * @memberOf _
  7537. * @category Object
  7538. * @param {Object} object The object to query.
  7539. * @returns {Array} Returns the array of property names.
  7540. * @example
  7541. *
  7542. * function Foo() {
  7543. * this.a = 1;
  7544. * this.b = 2;
  7545. * }
  7546. *
  7547. * Foo.prototype.c = 3;
  7548. *
  7549. * _.keys(new Foo);
  7550. * // => ['a', 'b'] (iteration order is not guaranteed)
  7551. *
  7552. * _.keys('hi');
  7553. * // => ['0', '1']
  7554. */
  7555. function keys(object) {
  7556. return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
  7557. }
  7558. /**
  7559. * Creates an array of own enumerable property names and symbols of `object`.
  7560. *
  7561. * @private
  7562. * @param {Object} object The object to query.
  7563. * @returns {Array} Returns the array of property names and symbols.
  7564. */
  7565. function getAllKeys(object) {
  7566. return baseGetAllKeys(object, keys, getSymbols);
  7567. }
  7568. /** Used to compose bitmasks for value comparisons. */
  7569. var COMPARE_PARTIAL_FLAG$2 = 1;
  7570. /** Used for built-in method references. */
  7571. var objectProto$a = Object.prototype;
  7572. /** Used to check objects for own properties. */
  7573. var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
  7574. /**
  7575. * A specialized version of `baseIsEqualDeep` for objects with support for
  7576. * partial deep comparisons.
  7577. *
  7578. * @private
  7579. * @param {Object} object The object to compare.
  7580. * @param {Object} other The other object to compare.
  7581. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  7582. * @param {Function} customizer The function to customize comparisons.
  7583. * @param {Function} equalFunc The function to determine equivalents of values.
  7584. * @param {Object} stack Tracks traversed `object` and `other` objects.
  7585. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  7586. */
  7587. function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
  7588. var isPartial = bitmask & COMPARE_PARTIAL_FLAG$2,
  7589. objProps = getAllKeys(object),
  7590. objLength = objProps.length,
  7591. othProps = getAllKeys(other),
  7592. othLength = othProps.length;
  7593. if (objLength != othLength && !isPartial) {
  7594. return false;
  7595. }
  7596. var index = objLength;
  7597. while (index--) {
  7598. var key = objProps[index];
  7599. if (!(isPartial ? key in other : hasOwnProperty$8.call(other, key))) {
  7600. return false;
  7601. }
  7602. }
  7603. // Assume cyclic values are equal.
  7604. var stacked = stack.get(object);
  7605. if (stacked && stack.get(other)) {
  7606. return stacked == other;
  7607. }
  7608. var result = true;
  7609. stack.set(object, other);
  7610. stack.set(other, object);
  7611. var skipCtor = isPartial;
  7612. while (++index < objLength) {
  7613. key = objProps[index];
  7614. var objValue = object[key],
  7615. othValue = other[key];
  7616. if (customizer) {
  7617. var compared = isPartial
  7618. ? customizer(othValue, objValue, key, other, object, stack)
  7619. : customizer(objValue, othValue, key, object, other, stack);
  7620. }
  7621. // Recursively compare objects (susceptible to call stack limits).
  7622. if (!(compared === undefined
  7623. ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
  7624. : compared
  7625. )) {
  7626. result = false;
  7627. break;
  7628. }
  7629. skipCtor || (skipCtor = key == 'constructor');
  7630. }
  7631. if (result && !skipCtor) {
  7632. var objCtor = object.constructor,
  7633. othCtor = other.constructor;
  7634. // Non `Object` object instances with different constructors are not equal.
  7635. if (objCtor != othCtor &&
  7636. ('constructor' in object && 'constructor' in other) &&
  7637. !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
  7638. typeof othCtor == 'function' && othCtor instanceof othCtor)) {
  7639. result = false;
  7640. }
  7641. }
  7642. stack['delete'](object);
  7643. stack['delete'](other);
  7644. return result;
  7645. }
  7646. /* Built-in method references that are verified to be native. */
  7647. var DataView = getNative(root, 'DataView');
  7648. /* Built-in method references that are verified to be native. */
  7649. var Promise = getNative(root, 'Promise');
  7650. /* Built-in method references that are verified to be native. */
  7651. var Set = getNative(root, 'Set');
  7652. /* Built-in method references that are verified to be native. */
  7653. var WeakMap = getNative(root, 'WeakMap');
  7654. /** `Object#toString` result references. */
  7655. var mapTag$2 = '[object Map]',
  7656. objectTag$1 = '[object Object]',
  7657. promiseTag = '[object Promise]',
  7658. setTag$2 = '[object Set]',
  7659. weakMapTag$1 = '[object WeakMap]';
  7660. var dataViewTag$2 = '[object DataView]';
  7661. /** Used to detect maps, sets, and weakmaps. */
  7662. var dataViewCtorString = toSource(DataView),
  7663. mapCtorString = toSource(Map$1),
  7664. promiseCtorString = toSource(Promise),
  7665. setCtorString = toSource(Set),
  7666. weakMapCtorString = toSource(WeakMap);
  7667. /**
  7668. * Gets the `toStringTag` of `value`.
  7669. *
  7670. * @private
  7671. * @param {*} value The value to query.
  7672. * @returns {string} Returns the `toStringTag`.
  7673. */
  7674. var getTag = baseGetTag;
  7675. // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
  7676. if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag$2) ||
  7677. (Map$1 && getTag(new Map$1) != mapTag$2) ||
  7678. (Promise && getTag(Promise.resolve()) != promiseTag) ||
  7679. (Set && getTag(new Set) != setTag$2) ||
  7680. (WeakMap && getTag(new WeakMap) != weakMapTag$1)) {
  7681. getTag = function(value) {
  7682. var result = baseGetTag(value),
  7683. Ctor = result == objectTag$1 ? value.constructor : undefined,
  7684. ctorString = Ctor ? toSource(Ctor) : '';
  7685. if (ctorString) {
  7686. switch (ctorString) {
  7687. case dataViewCtorString: return dataViewTag$2;
  7688. case mapCtorString: return mapTag$2;
  7689. case promiseCtorString: return promiseTag;
  7690. case setCtorString: return setTag$2;
  7691. case weakMapCtorString: return weakMapTag$1;
  7692. }
  7693. }
  7694. return result;
  7695. };
  7696. }
  7697. var getTag$1 = getTag;
  7698. /** Used to compose bitmasks for value comparisons. */
  7699. var COMPARE_PARTIAL_FLAG$3 = 1;
  7700. /** `Object#toString` result references. */
  7701. var argsTag$2 = '[object Arguments]',
  7702. arrayTag$1 = '[object Array]',
  7703. objectTag$2 = '[object Object]';
  7704. /** Used for built-in method references. */
  7705. var objectProto$b = Object.prototype;
  7706. /** Used to check objects for own properties. */
  7707. var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
  7708. /**
  7709. * A specialized version of `baseIsEqual` for arrays and objects which performs
  7710. * deep comparisons and tracks traversed objects enabling objects with circular
  7711. * references to be compared.
  7712. *
  7713. * @private
  7714. * @param {Object} object The object to compare.
  7715. * @param {Object} other The other object to compare.
  7716. * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
  7717. * @param {Function} customizer The function to customize comparisons.
  7718. * @param {Function} equalFunc The function to determine equivalents of values.
  7719. * @param {Object} [stack] Tracks traversed `object` and `other` objects.
  7720. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
  7721. */
  7722. function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
  7723. var objIsArr = isArray(object),
  7724. othIsArr = isArray(other),
  7725. objTag = objIsArr ? arrayTag$1 : getTag$1(object),
  7726. othTag = othIsArr ? arrayTag$1 : getTag$1(other);
  7727. objTag = objTag == argsTag$2 ? objectTag$2 : objTag;
  7728. othTag = othTag == argsTag$2 ? objectTag$2 : othTag;
  7729. var objIsObj = objTag == objectTag$2,
  7730. othIsObj = othTag == objectTag$2,
  7731. isSameTag = objTag == othTag;
  7732. if (isSameTag && isBuffer(object)) {
  7733. if (!isBuffer(other)) {
  7734. return false;
  7735. }
  7736. objIsArr = true;
  7737. objIsObj = false;
  7738. }
  7739. if (isSameTag && !objIsObj) {
  7740. stack || (stack = new Stack);
  7741. return (objIsArr || isTypedArray(object))
  7742. ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
  7743. : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
  7744. }
  7745. if (!(bitmask & COMPARE_PARTIAL_FLAG$3)) {
  7746. var objIsWrapped = objIsObj && hasOwnProperty$9.call(object, '__wrapped__'),
  7747. othIsWrapped = othIsObj && hasOwnProperty$9.call(other, '__wrapped__');
  7748. if (objIsWrapped || othIsWrapped) {
  7749. var objUnwrapped = objIsWrapped ? object.value() : object,
  7750. othUnwrapped = othIsWrapped ? other.value() : other;
  7751. stack || (stack = new Stack);
  7752. return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
  7753. }
  7754. }
  7755. if (!isSameTag) {
  7756. return false;
  7757. }
  7758. stack || (stack = new Stack);
  7759. return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
  7760. }
  7761. /**
  7762. * The base implementation of `_.isEqual` which supports partial comparisons
  7763. * and tracks traversed objects.
  7764. *
  7765. * @private
  7766. * @param {*} value The value to compare.
  7767. * @param {*} other The other value to compare.
  7768. * @param {boolean} bitmask The bitmask flags.
  7769. * 1 - Unordered comparison
  7770. * 2 - Partial comparison
  7771. * @param {Function} [customizer] The function to customize comparisons.
  7772. * @param {Object} [stack] Tracks traversed `value` and `other` objects.
  7773. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  7774. */
  7775. function baseIsEqual(value, other, bitmask, customizer, stack) {
  7776. if (value === other) {
  7777. return true;
  7778. }
  7779. if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
  7780. return value !== value && other !== other;
  7781. }
  7782. return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
  7783. }
  7784. /** Used to compose bitmasks for value comparisons. */
  7785. var COMPARE_PARTIAL_FLAG$4 = 1,
  7786. COMPARE_UNORDERED_FLAG$2 = 2;
  7787. /**
  7788. * The base implementation of `_.isMatch` without support for iteratee shorthands.
  7789. *
  7790. * @private
  7791. * @param {Object} object The object to inspect.
  7792. * @param {Object} source The object of property values to match.
  7793. * @param {Array} matchData The property names, values, and compare flags to match.
  7794. * @param {Function} [customizer] The function to customize comparisons.
  7795. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
  7796. */
  7797. function baseIsMatch(object, source, matchData, customizer) {
  7798. var index = matchData.length,
  7799. length = index,
  7800. noCustomizer = !customizer;
  7801. if (object == null) {
  7802. return !length;
  7803. }
  7804. object = Object(object);
  7805. while (index--) {
  7806. var data = matchData[index];
  7807. if ((noCustomizer && data[2])
  7808. ? data[1] !== object[data[0]]
  7809. : !(data[0] in object)
  7810. ) {
  7811. return false;
  7812. }
  7813. }
  7814. while (++index < length) {
  7815. data = matchData[index];
  7816. var key = data[0],
  7817. objValue = object[key],
  7818. srcValue = data[1];
  7819. if (noCustomizer && data[2]) {
  7820. if (objValue === undefined && !(key in object)) {
  7821. return false;
  7822. }
  7823. } else {
  7824. var stack = new Stack;
  7825. if (customizer) {
  7826. var result = customizer(objValue, srcValue, key, object, source, stack);
  7827. }
  7828. if (!(result === undefined
  7829. ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$4 | COMPARE_UNORDERED_FLAG$2, customizer, stack)
  7830. : result
  7831. )) {
  7832. return false;
  7833. }
  7834. }
  7835. }
  7836. return true;
  7837. }
  7838. /**
  7839. * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
  7840. *
  7841. * @private
  7842. * @param {*} value The value to check.
  7843. * @returns {boolean} Returns `true` if `value` if suitable for strict
  7844. * equality comparisons, else `false`.
  7845. */
  7846. function isStrictComparable(value) {
  7847. return value === value && !isObject(value);
  7848. }
  7849. /**
  7850. * Gets the property names, values, and compare flags of `object`.
  7851. *
  7852. * @private
  7853. * @param {Object} object The object to query.
  7854. * @returns {Array} Returns the match data of `object`.
  7855. */
  7856. function getMatchData(object) {
  7857. var result = keys(object),
  7858. length = result.length;
  7859. while (length--) {
  7860. var key = result[length],
  7861. value = object[key];
  7862. result[length] = [key, value, isStrictComparable(value)];
  7863. }
  7864. return result;
  7865. }
  7866. /**
  7867. * A specialized version of `matchesProperty` for source values suitable
  7868. * for strict equality comparisons, i.e. `===`.
  7869. *
  7870. * @private
  7871. * @param {string} key The key of the property to get.
  7872. * @param {*} srcValue The value to match.
  7873. * @returns {Function} Returns the new spec function.
  7874. */
  7875. function matchesStrictComparable(key, srcValue) {
  7876. return function(object) {
  7877. if (object == null) {
  7878. return false;
  7879. }
  7880. return object[key] === srcValue &&
  7881. (srcValue !== undefined || (key in Object(object)));
  7882. };
  7883. }
  7884. /**
  7885. * The base implementation of `_.matches` which doesn't clone `source`.
  7886. *
  7887. * @private
  7888. * @param {Object} source The object of property values to match.
  7889. * @returns {Function} Returns the new spec function.
  7890. */
  7891. function baseMatches(source) {
  7892. var matchData = getMatchData(source);
  7893. if (matchData.length == 1 && matchData[0][2]) {
  7894. return matchesStrictComparable(matchData[0][0], matchData[0][1]);
  7895. }
  7896. return function(object) {
  7897. return object === source || baseIsMatch(object, source, matchData);
  7898. };
  7899. }
  7900. /** Used to match property names within property paths. */
  7901. var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
  7902. reIsPlainProp = /^\w*$/;
  7903. /**
  7904. * Checks if `value` is a property name and not a property path.
  7905. *
  7906. * @private
  7907. * @param {*} value The value to check.
  7908. * @param {Object} [object] The object to query keys on.
  7909. * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
  7910. */
  7911. function isKey(value, object) {
  7912. if (isArray(value)) {
  7913. return false;
  7914. }
  7915. var type = typeof value;
  7916. if (type == 'number' || type == 'symbol' || type == 'boolean' ||
  7917. value == null || isSymbol(value)) {
  7918. return true;
  7919. }
  7920. return reIsPlainProp.test(value) || !reIsDeepProp.test(value) ||
  7921. (object != null && value in Object(object));
  7922. }
  7923. /** Error message constants. */
  7924. var FUNC_ERROR_TEXT = 'Expected a function';
  7925. /**
  7926. * Creates a function that memoizes the result of `func`. If `resolver` is
  7927. * provided, it determines the cache key for storing the result based on the
  7928. * arguments provided to the memoized function. By default, the first argument
  7929. * provided to the memoized function is used as the map cache key. The `func`
  7930. * is invoked with the `this` binding of the memoized function.
  7931. *
  7932. * **Note:** The cache is exposed as the `cache` property on the memoized
  7933. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  7934. * constructor with one whose instances implement the
  7935. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  7936. * method interface of `clear`, `delete`, `get`, `has`, and `set`.
  7937. *
  7938. * @static
  7939. * @memberOf _
  7940. * @since 0.1.0
  7941. * @category Function
  7942. * @param {Function} func The function to have its output memoized.
  7943. * @param {Function} [resolver] The function to resolve the cache key.
  7944. * @returns {Function} Returns the new memoized function.
  7945. * @example
  7946. *
  7947. * var object = { 'a': 1, 'b': 2 };
  7948. * var other = { 'c': 3, 'd': 4 };
  7949. *
  7950. * var values = _.memoize(_.values);
  7951. * values(object);
  7952. * // => [1, 2]
  7953. *
  7954. * values(other);
  7955. * // => [3, 4]
  7956. *
  7957. * object.a = 2;
  7958. * values(object);
  7959. * // => [1, 2]
  7960. *
  7961. * // Modify the result cache.
  7962. * values.cache.set(object, ['a', 'b']);
  7963. * values(object);
  7964. * // => ['a', 'b']
  7965. *
  7966. * // Replace `_.memoize.Cache`.
  7967. * _.memoize.Cache = WeakMap;
  7968. */
  7969. function memoize(func, resolver) {
  7970. if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
  7971. throw new TypeError(FUNC_ERROR_TEXT);
  7972. }
  7973. var memoized = function() {
  7974. var args = arguments,
  7975. key = resolver ? resolver.apply(this, args) : args[0],
  7976. cache = memoized.cache;
  7977. if (cache.has(key)) {
  7978. return cache.get(key);
  7979. }
  7980. var result = func.apply(this, args);
  7981. memoized.cache = cache.set(key, result) || cache;
  7982. return result;
  7983. };
  7984. memoized.cache = new (memoize.Cache || MapCache);
  7985. return memoized;
  7986. }
  7987. // Expose `MapCache`.
  7988. memoize.Cache = MapCache;
  7989. /** Used as the maximum memoize cache size. */
  7990. var MAX_MEMOIZE_SIZE = 500;
  7991. /**
  7992. * A specialized version of `_.memoize` which clears the memoized function's
  7993. * cache when it exceeds `MAX_MEMOIZE_SIZE`.
  7994. *
  7995. * @private
  7996. * @param {Function} func The function to have its output memoized.
  7997. * @returns {Function} Returns the new memoized function.
  7998. */
  7999. function memoizeCapped(func) {
  8000. var result = memoize(func, function(key) {
  8001. if (cache.size === MAX_MEMOIZE_SIZE) {
  8002. cache.clear();
  8003. }
  8004. return key;
  8005. });
  8006. var cache = result.cache;
  8007. return result;
  8008. }
  8009. /** Used to match property names within property paths. */
  8010. var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
  8011. /** Used to match backslashes in property paths. */
  8012. var reEscapeChar = /\\(\\)?/g;
  8013. /**
  8014. * Converts `string` to a property path array.
  8015. *
  8016. * @private
  8017. * @param {string} string The string to convert.
  8018. * @returns {Array} Returns the property path array.
  8019. */
  8020. var stringToPath = memoizeCapped(function(string) {
  8021. var result = [];
  8022. if (string.charCodeAt(0) === 46 /* . */) {
  8023. result.push('');
  8024. }
  8025. string.replace(rePropName, function(match, number, quote, subString) {
  8026. result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
  8027. });
  8028. return result;
  8029. });
  8030. /**
  8031. * A specialized version of `_.map` for arrays without support for iteratee
  8032. * shorthands.
  8033. *
  8034. * @private
  8035. * @param {Array} [array] The array to iterate over.
  8036. * @param {Function} iteratee The function invoked per iteration.
  8037. * @returns {Array} Returns the new mapped array.
  8038. */
  8039. function arrayMap(array, iteratee) {
  8040. var index = -1,
  8041. length = array == null ? 0 : array.length,
  8042. result = Array(length);
  8043. while (++index < length) {
  8044. result[index] = iteratee(array[index], index, array);
  8045. }
  8046. return result;
  8047. }
  8048. /** Used as references for various `Number` constants. */
  8049. var INFINITY$1 = 1 / 0;
  8050. /** Used to convert symbols to primitives and strings. */
  8051. var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : undefined,
  8052. symbolToString = symbolProto$1 ? symbolProto$1.toString : undefined;
  8053. /**
  8054. * The base implementation of `_.toString` which doesn't convert nullish
  8055. * values to empty strings.
  8056. *
  8057. * @private
  8058. * @param {*} value The value to process.
  8059. * @returns {string} Returns the string.
  8060. */
  8061. function baseToString(value) {
  8062. // Exit early for strings to avoid a performance hit in some environments.
  8063. if (typeof value == 'string') {
  8064. return value;
  8065. }
  8066. if (isArray(value)) {
  8067. // Recursively convert values (susceptible to call stack limits).
  8068. return arrayMap(value, baseToString) + '';
  8069. }
  8070. if (isSymbol(value)) {
  8071. return symbolToString ? symbolToString.call(value) : '';
  8072. }
  8073. var result = (value + '');
  8074. return (result == '0' && (1 / value) == -INFINITY$1) ? '-0' : result;
  8075. }
  8076. /**
  8077. * Converts `value` to a string. An empty string is returned for `null`
  8078. * and `undefined` values. The sign of `-0` is preserved.
  8079. *
  8080. * @static
  8081. * @memberOf _
  8082. * @since 4.0.0
  8083. * @category Lang
  8084. * @param {*} value The value to convert.
  8085. * @returns {string} Returns the converted string.
  8086. * @example
  8087. *
  8088. * _.toString(null);
  8089. * // => ''
  8090. *
  8091. * _.toString(-0);
  8092. * // => '-0'
  8093. *
  8094. * _.toString([1, 2, 3]);
  8095. * // => '1,2,3'
  8096. */
  8097. function toString(value) {
  8098. return value == null ? '' : baseToString(value);
  8099. }
  8100. /**
  8101. * Casts `value` to a path array if it's not one.
  8102. *
  8103. * @private
  8104. * @param {*} value The value to inspect.
  8105. * @param {Object} [object] The object to query keys on.
  8106. * @returns {Array} Returns the cast property path array.
  8107. */
  8108. function castPath(value, object) {
  8109. if (isArray(value)) {
  8110. return value;
  8111. }
  8112. return isKey(value, object) ? [value] : stringToPath(toString(value));
  8113. }
  8114. /** Used as references for various `Number` constants. */
  8115. var INFINITY$2 = 1 / 0;
  8116. /**
  8117. * Converts `value` to a string key if it's not a string or symbol.
  8118. *
  8119. * @private
  8120. * @param {*} value The value to inspect.
  8121. * @returns {string|symbol} Returns the key.
  8122. */
  8123. function toKey(value) {
  8124. if (typeof value == 'string' || isSymbol(value)) {
  8125. return value;
  8126. }
  8127. var result = (value + '');
  8128. return (result == '0' && (1 / value) == -INFINITY$2) ? '-0' : result;
  8129. }
  8130. /**
  8131. * The base implementation of `_.get` without support for default values.
  8132. *
  8133. * @private
  8134. * @param {Object} object The object to query.
  8135. * @param {Array|string} path The path of the property to get.
  8136. * @returns {*} Returns the resolved value.
  8137. */
  8138. function baseGet(object, path) {
  8139. path = castPath(path, object);
  8140. var index = 0,
  8141. length = path.length;
  8142. while (object != null && index < length) {
  8143. object = object[toKey(path[index++])];
  8144. }
  8145. return (index && index == length) ? object : undefined;
  8146. }
  8147. /**
  8148. * Gets the value at `path` of `object`. If the resolved value is
  8149. * `undefined`, the `defaultValue` is returned in its place.
  8150. *
  8151. * @static
  8152. * @memberOf _
  8153. * @since 3.7.0
  8154. * @category Object
  8155. * @param {Object} object The object to query.
  8156. * @param {Array|string} path The path of the property to get.
  8157. * @param {*} [defaultValue] The value returned for `undefined` resolved values.
  8158. * @returns {*} Returns the resolved value.
  8159. * @example
  8160. *
  8161. * var object = { 'a': [{ 'b': { 'c': 3 } }] };
  8162. *
  8163. * _.get(object, 'a[0].b.c');
  8164. * // => 3
  8165. *
  8166. * _.get(object, ['a', '0', 'b', 'c']);
  8167. * // => 3
  8168. *
  8169. * _.get(object, 'a.b.c', 'default');
  8170. * // => 'default'
  8171. */
  8172. function get(object, path, defaultValue) {
  8173. var result = object == null ? undefined : baseGet(object, path);
  8174. return result === undefined ? defaultValue : result;
  8175. }
  8176. /**
  8177. * The base implementation of `_.hasIn` without support for deep paths.
  8178. *
  8179. * @private
  8180. * @param {Object} [object] The object to query.
  8181. * @param {Array|string} key The key to check.
  8182. * @returns {boolean} Returns `true` if `key` exists, else `false`.
  8183. */
  8184. function baseHasIn(object, key) {
  8185. return object != null && key in Object(object);
  8186. }
  8187. /**
  8188. * Checks if `path` exists on `object`.
  8189. *
  8190. * @private
  8191. * @param {Object} object The object to query.
  8192. * @param {Array|string} path The path to check.
  8193. * @param {Function} hasFunc The function to check properties.
  8194. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  8195. */
  8196. function hasPath(object, path, hasFunc) {
  8197. path = castPath(path, object);
  8198. var index = -1,
  8199. length = path.length,
  8200. result = false;
  8201. while (++index < length) {
  8202. var key = toKey(path[index]);
  8203. if (!(result = object != null && hasFunc(object, key))) {
  8204. break;
  8205. }
  8206. object = object[key];
  8207. }
  8208. if (result || ++index != length) {
  8209. return result;
  8210. }
  8211. length = object == null ? 0 : object.length;
  8212. return !!length && isLength(length) && isIndex(key, length) &&
  8213. (isArray(object) || isArguments(object));
  8214. }
  8215. /**
  8216. * Checks if `path` is a direct or inherited property of `object`.
  8217. *
  8218. * @static
  8219. * @memberOf _
  8220. * @since 4.0.0
  8221. * @category Object
  8222. * @param {Object} object The object to query.
  8223. * @param {Array|string} path The path to check.
  8224. * @returns {boolean} Returns `true` if `path` exists, else `false`.
  8225. * @example
  8226. *
  8227. * var object = _.create({ 'a': _.create({ 'b': 2 }) });
  8228. *
  8229. * _.hasIn(object, 'a');
  8230. * // => true
  8231. *
  8232. * _.hasIn(object, 'a.b');
  8233. * // => true
  8234. *
  8235. * _.hasIn(object, ['a', 'b']);
  8236. * // => true
  8237. *
  8238. * _.hasIn(object, 'b');
  8239. * // => false
  8240. */
  8241. function hasIn(object, path) {
  8242. return object != null && hasPath(object, path, baseHasIn);
  8243. }
  8244. /** Used to compose bitmasks for value comparisons. */
  8245. var COMPARE_PARTIAL_FLAG$5 = 1,
  8246. COMPARE_UNORDERED_FLAG$3 = 2;
  8247. /**
  8248. * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`.
  8249. *
  8250. * @private
  8251. * @param {string} path The path of the property to get.
  8252. * @param {*} srcValue The value to match.
  8253. * @returns {Function} Returns the new spec function.
  8254. */
  8255. function baseMatchesProperty(path, srcValue) {
  8256. if (isKey(path) && isStrictComparable(srcValue)) {
  8257. return matchesStrictComparable(toKey(path), srcValue);
  8258. }
  8259. return function(object) {
  8260. var objValue = get(object, path);
  8261. return (objValue === undefined && objValue === srcValue)
  8262. ? hasIn(object, path)
  8263. : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$5 | COMPARE_UNORDERED_FLAG$3);
  8264. };
  8265. }
  8266. /**
  8267. * This method returns the first argument it receives.
  8268. *
  8269. * @static
  8270. * @since 0.1.0
  8271. * @memberOf _
  8272. * @category Util
  8273. * @param {*} value Any value.
  8274. * @returns {*} Returns `value`.
  8275. * @example
  8276. *
  8277. * var object = { 'a': 1 };
  8278. *
  8279. * console.log(_.identity(object) === object);
  8280. * // => true
  8281. */
  8282. function identity(value) {
  8283. return value;
  8284. }
  8285. /**
  8286. * The base implementation of `_.property` without support for deep paths.
  8287. *
  8288. * @private
  8289. * @param {string} key The key of the property to get.
  8290. * @returns {Function} Returns the new accessor function.
  8291. */
  8292. function baseProperty(key) {
  8293. return function(object) {
  8294. return object == null ? undefined : object[key];
  8295. };
  8296. }
  8297. /**
  8298. * A specialized version of `baseProperty` which supports deep paths.
  8299. *
  8300. * @private
  8301. * @param {Array|string} path The path of the property to get.
  8302. * @returns {Function} Returns the new accessor function.
  8303. */
  8304. function basePropertyDeep(path) {
  8305. return function(object) {
  8306. return baseGet(object, path);
  8307. };
  8308. }
  8309. /**
  8310. * Creates a function that returns the value at `path` of a given object.
  8311. *
  8312. * @static
  8313. * @memberOf _
  8314. * @since 2.4.0
  8315. * @category Util
  8316. * @param {Array|string} path The path of the property to get.
  8317. * @returns {Function} Returns the new accessor function.
  8318. * @example
  8319. *
  8320. * var objects = [
  8321. * { 'a': { 'b': 2 } },
  8322. * { 'a': { 'b': 1 } }
  8323. * ];
  8324. *
  8325. * _.map(objects, _.property('a.b'));
  8326. * // => [2, 1]
  8327. *
  8328. * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b');
  8329. * // => [1, 2]
  8330. */
  8331. function property(path) {
  8332. return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
  8333. }
  8334. /**
  8335. * The base implementation of `_.iteratee`.
  8336. *
  8337. * @private
  8338. * @param {*} [value=_.identity] The value to convert to an iteratee.
  8339. * @returns {Function} Returns the iteratee.
  8340. */
  8341. function baseIteratee(value) {
  8342. // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9.
  8343. // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
  8344. if (typeof value == 'function') {
  8345. return value;
  8346. }
  8347. if (value == null) {
  8348. return identity;
  8349. }
  8350. if (typeof value == 'object') {
  8351. return isArray(value)
  8352. ? baseMatchesProperty(value[0], value[1])
  8353. : baseMatches(value);
  8354. }
  8355. return property(value);
  8356. }
  8357. /* Built-in method references for those with the same name as other `lodash` methods. */
  8358. var nativeMax$1 = Math.max;
  8359. /**
  8360. * This method is like `_.find` except that it returns the index of the first
  8361. * element `predicate` returns truthy for instead of the element itself.
  8362. *
  8363. * @static
  8364. * @memberOf _
  8365. * @since 1.1.0
  8366. * @category Array
  8367. * @param {Array} array The array to inspect.
  8368. * @param {Function} [predicate=_.identity] The function invoked per iteration.
  8369. * @param {number} [fromIndex=0] The index to search from.
  8370. * @returns {number} Returns the index of the found element, else `-1`.
  8371. * @example
  8372. *
  8373. * var users = [
  8374. * { 'user': 'barney', 'active': false },
  8375. * { 'user': 'fred', 'active': false },
  8376. * { 'user': 'pebbles', 'active': true }
  8377. * ];
  8378. *
  8379. * _.findIndex(users, function(o) { return o.user == 'barney'; });
  8380. * // => 0
  8381. *
  8382. * // The `_.matches` iteratee shorthand.
  8383. * _.findIndex(users, { 'user': 'fred', 'active': false });
  8384. * // => 1
  8385. *
  8386. * // The `_.matchesProperty` iteratee shorthand.
  8387. * _.findIndex(users, ['active', false]);
  8388. * // => 0
  8389. *
  8390. * // The `_.property` iteratee shorthand.
  8391. * _.findIndex(users, 'active');
  8392. * // => 2
  8393. */
  8394. function findIndex$1(array, predicate, fromIndex) {
  8395. var length = array == null ? 0 : array.length;
  8396. if (!length) {
  8397. return -1;
  8398. }
  8399. var index = fromIndex == null ? 0 : toInteger(fromIndex);
  8400. if (index < 0) {
  8401. index = nativeMax$1(length + index, 0);
  8402. }
  8403. return baseFindIndex(array, baseIteratee(predicate, 3), index);
  8404. }
  8405. function endOfRange(dateRange, unit) {
  8406. if (unit === void 0) {
  8407. unit = 'day';
  8408. }
  8409. return {
  8410. first: dateRange[0],
  8411. last: add(dateRange[dateRange.length - 1], 1, unit)
  8412. };
  8413. }
  8414. function eventSegments(event, range, accessors) {
  8415. var _endOfRange = endOfRange(range),
  8416. first = _endOfRange.first,
  8417. last = _endOfRange.last;
  8418. var slots = diff(first, last, 'day');
  8419. var start = max(startOf(accessors.start(event), 'day'), first);
  8420. var end = min(ceil(accessors.end(event), 'day'), last);
  8421. var padding = findIndex$1(range, function (x) {
  8422. return eq(x, start, 'day');
  8423. });
  8424. var span = diff(start, end, 'day');
  8425. span = Math.min(span, slots);
  8426. span = Math.max(span, 1);
  8427. return {
  8428. event: event,
  8429. span: span,
  8430. left: padding + 1,
  8431. right: Math.max(padding + span, 1)
  8432. };
  8433. }
  8434. function eventLevels(rowSegments, limit) {
  8435. if (limit === void 0) {
  8436. limit = Infinity;
  8437. }
  8438. var i,
  8439. j,
  8440. seg,
  8441. levels = [],
  8442. extra = [];
  8443. for (i = 0; i < rowSegments.length; i++) {
  8444. seg = rowSegments[i];
  8445. for (j = 0; j < levels.length; j++) {
  8446. if (!segsOverlap(seg, levels[j])) break;
  8447. }
  8448. if (j >= limit) {
  8449. extra.push(seg);
  8450. } else {
  8451. (levels[j] || (levels[j] = [])).push(seg);
  8452. }
  8453. }
  8454. for (i = 0; i < levels.length; i++) {
  8455. levels[i].sort(function (a, b) {
  8456. return a.left - b.left;
  8457. }); //eslint-disable-line
  8458. }
  8459. return {
  8460. levels: levels,
  8461. extra: extra
  8462. };
  8463. }
  8464. function inRange$1(e, start, end, accessors) {
  8465. var eStart = startOf(accessors.start(e), 'day');
  8466. var eEnd = accessors.end(e);
  8467. var startsBeforeEnd = lte(eStart, end, 'day'); // when the event is zero duration we need to handle a bit differently
  8468. var endsAfterStart = !eq(eStart, eEnd, 'minutes') ? gt(eEnd, start, 'minutes') : gte(eEnd, start, 'minutes');
  8469. return startsBeforeEnd && endsAfterStart;
  8470. }
  8471. function segsOverlap(seg, otherSegs) {
  8472. return otherSegs.some(function (otherSeg) {
  8473. return otherSeg.left <= seg.right && otherSeg.right >= seg.left;
  8474. });
  8475. }
  8476. function sortEvents(evtA, evtB, accessors) {
  8477. var startSort = +startOf(accessors.start(evtA), 'day') - +startOf(accessors.start(evtB), 'day');
  8478. var durA = diff(accessors.start(evtA), ceil(accessors.end(evtA), 'day'), 'day');
  8479. var durB = diff(accessors.start(evtB), ceil(accessors.end(evtB), 'day'), 'day');
  8480. return startSort || // sort by start Day first
  8481. Math.max(durB, 1) - Math.max(durA, 1) || // events spanning multiple days go first
  8482. !!accessors.allDay(evtB) - !!accessors.allDay(evtA) || // then allDay single day events
  8483. +accessors.start(evtA) - +accessors.start(evtB); // then sort by start time
  8484. }
  8485. /* Built-in method references for those with the same name as other `lodash` methods. */
  8486. var nativeCeil$1 = Math.ceil,
  8487. nativeMax$2 = Math.max;
  8488. /**
  8489. * The base implementation of `_.range` and `_.rangeRight` which doesn't
  8490. * coerce arguments.
  8491. *
  8492. * @private
  8493. * @param {number} start The start of the range.
  8494. * @param {number} end The end of the range.
  8495. * @param {number} step The value to increment or decrement by.
  8496. * @param {boolean} [fromRight] Specify iterating from right to left.
  8497. * @returns {Array} Returns the range of numbers.
  8498. */
  8499. function baseRange(start, end, step, fromRight) {
  8500. var index = -1,
  8501. length = nativeMax$2(nativeCeil$1((end - start) / (step || 1)), 0),
  8502. result = Array(length);
  8503. while (length--) {
  8504. result[fromRight ? length : ++index] = start;
  8505. start += step;
  8506. }
  8507. return result;
  8508. }
  8509. /**
  8510. * Creates a `_.range` or `_.rangeRight` function.
  8511. *
  8512. * @private
  8513. * @param {boolean} [fromRight] Specify iterating from right to left.
  8514. * @returns {Function} Returns the new range function.
  8515. */
  8516. function createRange(fromRight) {
  8517. return function(start, end, step) {
  8518. if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
  8519. end = step = undefined;
  8520. }
  8521. // Ensure the sign of `-0` is preserved.
  8522. start = toFinite(start);
  8523. if (end === undefined) {
  8524. end = start;
  8525. start = 0;
  8526. } else {
  8527. end = toFinite(end);
  8528. }
  8529. step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
  8530. return baseRange(start, end, step, fromRight);
  8531. };
  8532. }
  8533. /**
  8534. * Creates an array of numbers (positive and/or negative) progressing from
  8535. * `start` up to, but not including, `end`. A step of `-1` is used if a negative
  8536. * `start` is specified without an `end` or `step`. If `end` is not specified,
  8537. * it's set to `start` with `start` then set to `0`.
  8538. *
  8539. * **Note:** JavaScript follows the IEEE-754 standard for resolving
  8540. * floating-point values which can produce unexpected results.
  8541. *
  8542. * @static
  8543. * @since 0.1.0
  8544. * @memberOf _
  8545. * @category Util
  8546. * @param {number} [start=0] The start of the range.
  8547. * @param {number} end The end of the range.
  8548. * @param {number} [step=1] The value to increment or decrement by.
  8549. * @returns {Array} Returns the range of numbers.
  8550. * @see _.inRange, _.rangeRight
  8551. * @example
  8552. *
  8553. * _.range(4);
  8554. * // => [0, 1, 2, 3]
  8555. *
  8556. * _.range(-4);
  8557. * // => [0, -1, -2, -3]
  8558. *
  8559. * _.range(1, 5);
  8560. * // => [1, 2, 3, 4]
  8561. *
  8562. * _.range(0, 20, 5);
  8563. * // => [0, 5, 10, 15]
  8564. *
  8565. * _.range(0, -4, -1);
  8566. * // => [0, -1, -2, -3]
  8567. *
  8568. * _.range(1, 4, 0);
  8569. * // => [1, 1, 1]
  8570. *
  8571. * _.range(0);
  8572. * // => []
  8573. */
  8574. var range$1 = createRange();
  8575. var isSegmentInSlot = function isSegmentInSlot(seg, slot) {
  8576. return seg.left <= slot && seg.right >= slot;
  8577. };
  8578. var eventsInSlot = function eventsInSlot(segments, slot) {
  8579. return segments.filter(function (seg) {
  8580. return isSegmentInSlot(seg, slot);
  8581. }).length;
  8582. };
  8583. var EventEndingRow =
  8584. /*#__PURE__*/
  8585. function (_React$Component) {
  8586. _inheritsLoose(EventEndingRow, _React$Component);
  8587. function EventEndingRow() {
  8588. return _React$Component.apply(this, arguments) || this;
  8589. }
  8590. var _proto = EventEndingRow.prototype;
  8591. _proto.render = function render() {
  8592. var _this$props = this.props,
  8593. segments = _this$props.segments,
  8594. slots = _this$props.slotMetrics.slots;
  8595. var rowSegments = eventLevels(segments).levels[0];
  8596. var current = 1,
  8597. lastEnd = 1,
  8598. row = [];
  8599. while (current <= slots) {
  8600. var key = '_lvl_' + current;
  8601. var _ref = rowSegments.filter(function (seg) {
  8602. return isSegmentInSlot(seg, current);
  8603. })[0] || {},
  8604. event = _ref.event,
  8605. left = _ref.left,
  8606. right = _ref.right,
  8607. span = _ref.span; //eslint-disable-line
  8608. if (!event) {
  8609. current++;
  8610. continue;
  8611. }
  8612. var gap = Math.max(0, left - lastEnd);
  8613. if (this.canRenderSlotEvent(left, span)) {
  8614. var content = EventRowMixin.renderEvent(this.props, event);
  8615. if (gap) {
  8616. row.push(EventRowMixin.renderSpan(slots, gap, key + '_gap'));
  8617. }
  8618. row.push(EventRowMixin.renderSpan(slots, span, key, content));
  8619. lastEnd = current = right + 1;
  8620. } else {
  8621. if (gap) {
  8622. row.push(EventRowMixin.renderSpan(slots, gap, key + '_gap'));
  8623. }
  8624. row.push(EventRowMixin.renderSpan(slots, 1, key, this.renderShowMore(segments, current)));
  8625. lastEnd = current = current + 1;
  8626. }
  8627. }
  8628. return React__default.createElement("div", {
  8629. className: "rbc-row"
  8630. }, row);
  8631. };
  8632. _proto.canRenderSlotEvent = function canRenderSlotEvent(slot, span) {
  8633. var segments = this.props.segments;
  8634. return range$1(slot, slot + span).every(function (s) {
  8635. var count = eventsInSlot(segments, s);
  8636. return count === 1;
  8637. });
  8638. };
  8639. _proto.renderShowMore = function renderShowMore(segments, slot) {
  8640. var _this = this;
  8641. var localizer = this.props.localizer;
  8642. var count = eventsInSlot(segments, slot);
  8643. return count ? React__default.createElement("a", {
  8644. key: 'sm_' + slot,
  8645. href: "#",
  8646. className: 'rbc-show-more',
  8647. onClick: function onClick(e) {
  8648. return _this.showMore(slot, e);
  8649. }
  8650. }, localizer.messages.showMore(count)) : false;
  8651. };
  8652. _proto.showMore = function showMore(slot, e) {
  8653. e.preventDefault();
  8654. this.props.onShowMore(slot, e.target);
  8655. };
  8656. return EventEndingRow;
  8657. }(React__default.Component);
  8658. EventEndingRow.propTypes = _extends({
  8659. segments: propTypes.array,
  8660. slots: propTypes.number,
  8661. onShowMore: propTypes.func
  8662. }, EventRowMixin.propTypes);
  8663. EventEndingRow.defaultProps = _extends({}, EventRowMixin.defaultProps);
  8664. var simpleIsEqual = function simpleIsEqual(a, b) {
  8665. return a === b;
  8666. };
  8667. function index (resultFn, isEqual) {
  8668. if (isEqual === void 0) {
  8669. isEqual = simpleIsEqual;
  8670. }
  8671. var lastThis;
  8672. var lastArgs = [];
  8673. var lastResult;
  8674. var calledOnce = false;
  8675. var isNewArgEqualToLast = function isNewArgEqualToLast(newArg, index) {
  8676. return isEqual(newArg, lastArgs[index], index);
  8677. };
  8678. var result = function result() {
  8679. for (var _len = arguments.length, newArgs = new Array(_len), _key = 0; _key < _len; _key++) {
  8680. newArgs[_key] = arguments[_key];
  8681. }
  8682. if (calledOnce && lastThis === this && newArgs.length === lastArgs.length && newArgs.every(isNewArgEqualToLast)) {
  8683. return lastResult;
  8684. }
  8685. lastResult = resultFn.apply(this, newArgs);
  8686. calledOnce = true;
  8687. lastThis = this;
  8688. lastArgs = newArgs;
  8689. return lastResult;
  8690. };
  8691. return result;
  8692. }
  8693. var isSegmentInSlot$1 = function isSegmentInSlot(seg, slot) {
  8694. return seg.left <= slot && seg.right >= slot;
  8695. };
  8696. var isEqual = function isEqual(a, b) {
  8697. return a.range === b.range && a.events === b.events;
  8698. };
  8699. function getSlotMetrics() {
  8700. return index(function (options) {
  8701. var range = options.range,
  8702. events = options.events,
  8703. maxRows = options.maxRows,
  8704. minRows = options.minRows,
  8705. accessors = options.accessors;
  8706. var _endOfRange = endOfRange(range),
  8707. first = _endOfRange.first,
  8708. last = _endOfRange.last;
  8709. var segments = events.map(function (evt) {
  8710. return eventSegments(evt, range, accessors);
  8711. });
  8712. var _eventLevels = eventLevels(segments, Math.max(maxRows - 1, 1)),
  8713. levels = _eventLevels.levels,
  8714. extra = _eventLevels.extra;
  8715. while (levels.length < minRows) {
  8716. levels.push([]);
  8717. }
  8718. return {
  8719. first: first,
  8720. last: last,
  8721. levels: levels,
  8722. extra: extra,
  8723. range: range,
  8724. slots: range.length,
  8725. clone: function clone(args) {
  8726. var metrics = getSlotMetrics();
  8727. return metrics(_extends({}, options, args));
  8728. },
  8729. getDateForSlot: function getDateForSlot(slotNumber) {
  8730. return range[slotNumber];
  8731. },
  8732. getSlotForDate: function getSlotForDate(date) {
  8733. return range.find(function (r) {
  8734. return eq(r, date, 'day');
  8735. });
  8736. },
  8737. getEventsForSlot: function getEventsForSlot(slot) {
  8738. return segments.filter(function (seg) {
  8739. return isSegmentInSlot$1(seg, slot);
  8740. }).map(function (seg) {
  8741. return seg.event;
  8742. });
  8743. },
  8744. continuesPrior: function continuesPrior(event) {
  8745. return lt(accessors.start(event), first, 'day');
  8746. },
  8747. continuesAfter: function continuesAfter(event) {
  8748. var eventEnd = accessors.end(event);
  8749. var singleDayDuration = eq(accessors.start(event), eventEnd, 'minutes');
  8750. return singleDayDuration ? gte(eventEnd, last, 'minutes') : gt(eventEnd, last, 'minutes');
  8751. }
  8752. };
  8753. }, isEqual);
  8754. }
  8755. var DateContentRow =
  8756. /*#__PURE__*/
  8757. function (_React$Component) {
  8758. _inheritsLoose(DateContentRow, _React$Component);
  8759. function DateContentRow() {
  8760. var _this;
  8761. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  8762. args[_key] = arguments[_key];
  8763. }
  8764. _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
  8765. _this.handleSelectSlot = function (slot) {
  8766. var _this$props = _this.props,
  8767. range = _this$props.range,
  8768. onSelectSlot = _this$props.onSelectSlot;
  8769. onSelectSlot(range.slice(slot.start, slot.end + 1), slot);
  8770. };
  8771. _this.handleShowMore = function (slot, target) {
  8772. var _this$props2 = _this.props,
  8773. range = _this$props2.range,
  8774. onShowMore = _this$props2.onShowMore;
  8775. var metrics = _this.slotMetrics(_this.props);
  8776. var row = qsa(ReactDOM.findDOMNode(_assertThisInitialized(_this)), '.rbc-row-bg')[0];
  8777. var cell;
  8778. if (row) cell = row.children[slot - 1];
  8779. var events = metrics.getEventsForSlot(slot);
  8780. onShowMore(events, range[slot - 1], cell, slot, target);
  8781. };
  8782. _this.createHeadingRef = function (r) {
  8783. _this.headingRow = r;
  8784. };
  8785. _this.createEventRef = function (r) {
  8786. _this.eventRow = r;
  8787. };
  8788. _this.getContainer = function () {
  8789. var container = _this.props.container;
  8790. return container ? container() : ReactDOM.findDOMNode(_assertThisInitialized(_this));
  8791. };
  8792. _this.renderHeadingCell = function (date, index) {
  8793. var _this$props3 = _this.props,
  8794. renderHeader = _this$props3.renderHeader,
  8795. getNow = _this$props3.getNow;
  8796. return renderHeader({
  8797. date: date,
  8798. key: "header_" + index,
  8799. className: clsx('rbc-date-cell', eq(date, getNow(), 'day') && 'rbc-now')
  8800. });
  8801. };
  8802. _this.renderDummy = function () {
  8803. var _this$props4 = _this.props,
  8804. className = _this$props4.className,
  8805. range = _this$props4.range,
  8806. renderHeader = _this$props4.renderHeader;
  8807. return React__default.createElement("div", {
  8808. className: className
  8809. }, React__default.createElement("div", {
  8810. className: "rbc-row-content"
  8811. }, renderHeader && React__default.createElement("div", {
  8812. className: "rbc-row",
  8813. ref: _this.createHeadingRef
  8814. }, range.map(_this.renderHeadingCell)), React__default.createElement("div", {
  8815. className: "rbc-row",
  8816. ref: _this.createEventRef
  8817. }, React__default.createElement("div", {
  8818. className: "rbc-row-segment"
  8819. }, React__default.createElement("div", {
  8820. className: "rbc-event"
  8821. }, React__default.createElement("div", {
  8822. className: "rbc-event-content"
  8823. }, "\xA0"))))));
  8824. };
  8825. _this.slotMetrics = getSlotMetrics();
  8826. return _this;
  8827. }
  8828. var _proto = DateContentRow.prototype;
  8829. _proto.getRowLimit = function getRowLimit() {
  8830. var eventHeight = height(this.eventRow);
  8831. var headingHeight = this.headingRow ? height(this.headingRow) : 0;
  8832. var eventSpace = height(ReactDOM.findDOMNode(this)) - headingHeight;
  8833. return Math.max(Math.floor(eventSpace / eventHeight), 1);
  8834. };
  8835. _proto.render = function render() {
  8836. var _this$props5 = this.props,
  8837. date = _this$props5.date,
  8838. rtl = _this$props5.rtl,
  8839. range = _this$props5.range,
  8840. className = _this$props5.className,
  8841. selected = _this$props5.selected,
  8842. selectable = _this$props5.selectable,
  8843. renderForMeasure = _this$props5.renderForMeasure,
  8844. accessors = _this$props5.accessors,
  8845. getters = _this$props5.getters,
  8846. components = _this$props5.components,
  8847. getNow = _this$props5.getNow,
  8848. renderHeader = _this$props5.renderHeader,
  8849. onSelect = _this$props5.onSelect,
  8850. localizer = _this$props5.localizer,
  8851. onSelectStart = _this$props5.onSelectStart,
  8852. onSelectEnd = _this$props5.onSelectEnd,
  8853. onDoubleClick = _this$props5.onDoubleClick,
  8854. resourceId = _this$props5.resourceId,
  8855. longPressThreshold = _this$props5.longPressThreshold,
  8856. isAllDay = _this$props5.isAllDay;
  8857. if (renderForMeasure) return this.renderDummy();
  8858. var metrics = this.slotMetrics(this.props);
  8859. var levels = metrics.levels,
  8860. extra = metrics.extra;
  8861. var WeekWrapper = components.weekWrapper;
  8862. var eventRowProps = {
  8863. selected: selected,
  8864. accessors: accessors,
  8865. getters: getters,
  8866. localizer: localizer,
  8867. components: components,
  8868. onSelect: onSelect,
  8869. onDoubleClick: onDoubleClick,
  8870. resourceId: resourceId,
  8871. slotMetrics: metrics
  8872. };
  8873. return React__default.createElement("div", {
  8874. className: className
  8875. }, React__default.createElement(BackgroundCells, {
  8876. date: date,
  8877. getNow: getNow,
  8878. rtl: rtl,
  8879. range: range,
  8880. selectable: selectable,
  8881. container: this.getContainer,
  8882. getters: getters,
  8883. onSelectStart: onSelectStart,
  8884. onSelectEnd: onSelectEnd,
  8885. onSelectSlot: this.handleSelectSlot,
  8886. components: components,
  8887. longPressThreshold: longPressThreshold
  8888. }), React__default.createElement("div", {
  8889. className: "rbc-row-content"
  8890. }, renderHeader && React__default.createElement("div", {
  8891. className: "rbc-row ",
  8892. ref: this.createHeadingRef
  8893. }, range.map(this.renderHeadingCell)), React__default.createElement(WeekWrapper, _extends({
  8894. isAllDay: isAllDay
  8895. }, eventRowProps), levels.map(function (segs, idx) {
  8896. return React__default.createElement(EventRow, _extends({
  8897. key: idx,
  8898. segments: segs
  8899. }, eventRowProps));
  8900. }), !!extra.length && React__default.createElement(EventEndingRow, _extends({
  8901. segments: extra,
  8902. onShowMore: this.handleShowMore
  8903. }, eventRowProps)))));
  8904. };
  8905. return DateContentRow;
  8906. }(React__default.Component);
  8907. DateContentRow.propTypes = {
  8908. date: propTypes.instanceOf(Date),
  8909. events: propTypes.array.isRequired,
  8910. range: propTypes.array.isRequired,
  8911. rtl: propTypes.bool,
  8912. resourceId: propTypes.any,
  8913. renderForMeasure: propTypes.bool,
  8914. renderHeader: propTypes.func,
  8915. container: propTypes.func,
  8916. selected: propTypes.object,
  8917. selectable: propTypes.oneOf([true, false, 'ignoreEvents']),
  8918. longPressThreshold: propTypes.number,
  8919. onShowMore: propTypes.func,
  8920. onSelectSlot: propTypes.func,
  8921. onSelect: propTypes.func,
  8922. onSelectEnd: propTypes.func,
  8923. onSelectStart: propTypes.func,
  8924. onDoubleClick: propTypes.func,
  8925. dayPropGetter: propTypes.func,
  8926. getNow: propTypes.func.isRequired,
  8927. isAllDay: propTypes.bool,
  8928. accessors: propTypes.object.isRequired,
  8929. components: propTypes.object.isRequired,
  8930. getters: propTypes.object.isRequired,
  8931. localizer: propTypes.object.isRequired,
  8932. minRows: propTypes.number.isRequired,
  8933. maxRows: propTypes.number.isRequired
  8934. };
  8935. DateContentRow.defaultProps = {
  8936. minRows: 0,
  8937. maxRows: Infinity
  8938. };
  8939. var Header = function Header(_ref) {
  8940. var label = _ref.label;
  8941. return React__default.createElement("span", null, label);
  8942. };
  8943. Header.propTypes = {
  8944. label: propTypes.node
  8945. };
  8946. var DateHeader = function DateHeader(_ref) {
  8947. var label = _ref.label,
  8948. drilldownView = _ref.drilldownView,
  8949. onDrillDown = _ref.onDrillDown;
  8950. if (!drilldownView) {
  8951. return React__default.createElement("span", null, label);
  8952. }
  8953. return React__default.createElement("a", {
  8954. href: "#",
  8955. onClick: onDrillDown
  8956. }, label);
  8957. };
  8958. DateHeader.propTypes = {
  8959. label: propTypes.node,
  8960. date: propTypes.instanceOf(Date),
  8961. drilldownView: propTypes.string,
  8962. onDrillDown: propTypes.func,
  8963. isOffRange: propTypes.bool
  8964. };
  8965. var eventsForWeek = function eventsForWeek(evts, start, end, accessors) {
  8966. return evts.filter(function (e) {
  8967. return inRange$1(e, start, end, accessors);
  8968. });
  8969. };
  8970. var MonthView =
  8971. /*#__PURE__*/
  8972. function (_React$Component) {
  8973. _inheritsLoose(MonthView, _React$Component);
  8974. function MonthView() {
  8975. var _this;
  8976. for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
  8977. _args[_key] = arguments[_key];
  8978. }
  8979. _this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;
  8980. _this.getContainer = function () {
  8981. return ReactDOM.findDOMNode(_assertThisInitialized(_this));
  8982. };
  8983. _this.renderWeek = function (week, weekIdx) {
  8984. var _this$props = _this.props,
  8985. events = _this$props.events,
  8986. components = _this$props.components,
  8987. selectable = _this$props.selectable,
  8988. getNow = _this$props.getNow,
  8989. selected = _this$props.selected,
  8990. date = _this$props.date,
  8991. localizer = _this$props.localizer,
  8992. longPressThreshold = _this$props.longPressThreshold,
  8993. accessors = _this$props.accessors,
  8994. getters = _this$props.getters;
  8995. var _this$state = _this.state,
  8996. needLimitMeasure = _this$state.needLimitMeasure,
  8997. rowLimit = _this$state.rowLimit;
  8998. events = eventsForWeek(events, week[0], week[week.length - 1], accessors);
  8999. events.sort(function (a, b) {
  9000. return sortEvents(a, b, accessors);
  9001. });
  9002. return React__default.createElement(DateContentRow, {
  9003. key: weekIdx,
  9004. ref: weekIdx === 0 ? _this.slotRowRef : undefined,
  9005. container: _this.getContainer,
  9006. className: "rbc-month-row",
  9007. getNow: getNow,
  9008. date: date,
  9009. range: week,
  9010. events: events,
  9011. maxRows: rowLimit,
  9012. selected: selected,
  9013. selectable: selectable,
  9014. components: components,
  9015. accessors: accessors,
  9016. getters: getters,
  9017. localizer: localizer,
  9018. renderHeader: _this.readerDateHeading,
  9019. renderForMeasure: needLimitMeasure,
  9020. onShowMore: _this.handleShowMore,
  9021. onSelect: _this.handleSelectEvent,
  9022. onDoubleClick: _this.handleDoubleClickEvent,
  9023. onSelectSlot: _this.handleSelectSlot,
  9024. longPressThreshold: longPressThreshold,
  9025. rtl: _this.props.rtl
  9026. });
  9027. };
  9028. _this.readerDateHeading = function (_ref) {
  9029. var date = _ref.date,
  9030. className = _ref.className,
  9031. props = _objectWithoutPropertiesLoose(_ref, ["date", "className"]);
  9032. var _this$props2 = _this.props,
  9033. currentDate = _this$props2.date,
  9034. getDrilldownView = _this$props2.getDrilldownView,
  9035. localizer = _this$props2.localizer;
  9036. var isOffRange = month(date) !== month(currentDate);
  9037. var isCurrent = eq(date, currentDate, 'day');
  9038. var drilldownView = getDrilldownView(date);
  9039. var label = localizer.format(date, 'dateFormat');
  9040. var DateHeaderComponent = _this.props.components.dateHeader || DateHeader;
  9041. return React__default.createElement("div", _extends({}, props, {
  9042. className: clsx(className, isOffRange && 'rbc-off-range', isCurrent && 'rbc-current')
  9043. }), React__default.createElement(DateHeaderComponent, {
  9044. label: label,
  9045. date: date,
  9046. drilldownView: drilldownView,
  9047. isOffRange: isOffRange,
  9048. onDrillDown: function onDrillDown(e) {
  9049. return _this.handleHeadingClick(date, drilldownView, e);
  9050. }
  9051. }));
  9052. };
  9053. _this.handleSelectSlot = function (range, slotInfo) {
  9054. _this._pendingSelection = _this._pendingSelection.concat(range);
  9055. clearTimeout(_this._selectTimer);
  9056. _this._selectTimer = setTimeout(function () {
  9057. return _this.selectDates(slotInfo);
  9058. });
  9059. };
  9060. _this.handleHeadingClick = function (date, view, e) {
  9061. e.preventDefault();
  9062. _this.clearSelection();
  9063. notify(_this.props.onDrillDown, [date, view]);
  9064. };
  9065. _this.handleSelectEvent = function () {
  9066. _this.clearSelection();
  9067. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  9068. args[_key2] = arguments[_key2];
  9069. }
  9070. notify(_this.props.onSelectEvent, args);
  9071. };
  9072. _this.handleDoubleClickEvent = function () {
  9073. _this.clearSelection();
  9074. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  9075. args[_key3] = arguments[_key3];
  9076. }
  9077. notify(_this.props.onDoubleClickEvent, args);
  9078. };
  9079. _this.handleShowMore = function (events, date, cell, slot, target) {
  9080. var _this$props3 = _this.props,
  9081. popup = _this$props3.popup,
  9082. onDrillDown = _this$props3.onDrillDown,
  9083. onShowMore = _this$props3.onShowMore,
  9084. getDrilldownView = _this$props3.getDrilldownView; //cancel any pending selections so only the event click goes through.
  9085. _this.clearSelection();
  9086. if (popup) {
  9087. var position$1 = position(cell, ReactDOM.findDOMNode(_assertThisInitialized(_this)));
  9088. _this.setState({
  9089. overlay: {
  9090. date: date,
  9091. events: events,
  9092. position: position$1,
  9093. target: target
  9094. }
  9095. });
  9096. } else {
  9097. notify(onDrillDown, [date, getDrilldownView(date) || views.DAY]);
  9098. }
  9099. notify(onShowMore, [events, date, slot]);
  9100. };
  9101. _this._bgRows = [];
  9102. _this._pendingSelection = [];
  9103. _this.slotRowRef = React__default.createRef();
  9104. _this.state = {
  9105. rowLimit: 5,
  9106. needLimitMeasure: true
  9107. };
  9108. return _this;
  9109. }
  9110. var _proto = MonthView.prototype;
  9111. _proto.componentWillReceiveProps = function componentWillReceiveProps(_ref2) {
  9112. var date = _ref2.date;
  9113. this.setState({
  9114. needLimitMeasure: !eq(date, this.props.date, 'month')
  9115. });
  9116. };
  9117. _proto.componentDidMount = function componentDidMount() {
  9118. var _this2 = this;
  9119. var running;
  9120. if (this.state.needLimitMeasure) this.measureRowLimit(this.props);
  9121. window.addEventListener('resize', this._resizeListener = function () {
  9122. if (!running) {
  9123. request(function () {
  9124. running = false;
  9125. _this2.setState({
  9126. needLimitMeasure: true
  9127. }); //eslint-disable-line
  9128. });
  9129. }
  9130. }, false);
  9131. };
  9132. _proto.componentDidUpdate = function componentDidUpdate() {
  9133. if (this.state.needLimitMeasure) this.measureRowLimit(this.props);
  9134. };
  9135. _proto.componentWillUnmount = function componentWillUnmount() {
  9136. window.removeEventListener('resize', this._resizeListener, false);
  9137. };
  9138. _proto.render = function render() {
  9139. var _this$props4 = this.props,
  9140. date = _this$props4.date,
  9141. localizer = _this$props4.localizer,
  9142. className = _this$props4.className,
  9143. month = visibleDays(date, localizer),
  9144. weeks = chunk(month, 7);
  9145. this._weekCount = weeks.length;
  9146. return React__default.createElement("div", {
  9147. className: clsx('rbc-month-view', className)
  9148. }, React__default.createElement("div", {
  9149. className: "rbc-row rbc-month-header"
  9150. }, this.renderHeaders(weeks[0])), weeks.map(this.renderWeek), this.props.popup && this.renderOverlay());
  9151. };
  9152. _proto.renderHeaders = function renderHeaders(row) {
  9153. var _this$props5 = this.props,
  9154. localizer = _this$props5.localizer,
  9155. components = _this$props5.components;
  9156. var first = row[0];
  9157. var last = row[row.length - 1];
  9158. var HeaderComponent = components.header || Header;
  9159. return range(first, last, 'day').map(function (day, idx) {
  9160. return React__default.createElement("div", {
  9161. key: 'header_' + idx,
  9162. className: "rbc-header"
  9163. }, React__default.createElement(HeaderComponent, {
  9164. date: day,
  9165. localizer: localizer,
  9166. label: localizer.format(day, 'weekdayFormat')
  9167. }));
  9168. });
  9169. };
  9170. _proto.renderOverlay = function renderOverlay() {
  9171. var _this3 = this;
  9172. var overlay = this.state && this.state.overlay || {};
  9173. var _this$props6 = this.props,
  9174. accessors = _this$props6.accessors,
  9175. localizer = _this$props6.localizer,
  9176. components = _this$props6.components,
  9177. getters = _this$props6.getters,
  9178. selected = _this$props6.selected,
  9179. popupOffset = _this$props6.popupOffset;
  9180. return React__default.createElement(Overlay, {
  9181. rootClose: true,
  9182. placement: "bottom",
  9183. show: !!overlay.position,
  9184. onHide: function onHide() {
  9185. return _this3.setState({
  9186. overlay: null
  9187. });
  9188. },
  9189. target: function target() {
  9190. return overlay.target;
  9191. }
  9192. }, function (_ref3) {
  9193. var props = _ref3.props;
  9194. return React__default.createElement(Popup$1, _extends({}, props, {
  9195. popupOffset: popupOffset,
  9196. accessors: accessors,
  9197. getters: getters,
  9198. selected: selected,
  9199. components: components,
  9200. localizer: localizer,
  9201. position: overlay.position,
  9202. events: overlay.events,
  9203. slotStart: overlay.date,
  9204. slotEnd: overlay.end,
  9205. onSelect: _this3.handleSelectEvent,
  9206. onDoubleClick: _this3.handleDoubleClickEvent
  9207. }));
  9208. });
  9209. };
  9210. _proto.measureRowLimit = function measureRowLimit() {
  9211. this.setState({
  9212. needLimitMeasure: false,
  9213. rowLimit: this.slotRowRef.current.getRowLimit()
  9214. });
  9215. };
  9216. _proto.selectDates = function selectDates(slotInfo) {
  9217. var slots = this._pendingSelection.slice();
  9218. this._pendingSelection = [];
  9219. slots.sort(function (a, b) {
  9220. return +a - +b;
  9221. });
  9222. notify(this.props.onSelectSlot, {
  9223. slots: slots,
  9224. start: slots[0],
  9225. end: slots[slots.length - 1],
  9226. action: slotInfo.action,
  9227. bounds: slotInfo.bounds,
  9228. box: slotInfo.box
  9229. });
  9230. };
  9231. _proto.clearSelection = function clearSelection() {
  9232. clearTimeout(this._selectTimer);
  9233. this._pendingSelection = [];
  9234. };
  9235. return MonthView;
  9236. }(React__default.Component);
  9237. MonthView.propTypes = {
  9238. events: propTypes.array.isRequired,
  9239. date: propTypes.instanceOf(Date),
  9240. min: propTypes.instanceOf(Date),
  9241. max: propTypes.instanceOf(Date),
  9242. step: propTypes.number,
  9243. getNow: propTypes.func.isRequired,
  9244. scrollToTime: propTypes.instanceOf(Date),
  9245. rtl: propTypes.bool,
  9246. width: propTypes.number,
  9247. accessors: propTypes.object.isRequired,
  9248. components: propTypes.object.isRequired,
  9249. getters: propTypes.object.isRequired,
  9250. localizer: propTypes.object.isRequired,
  9251. selected: propTypes.object,
  9252. selectable: propTypes.oneOf([true, false, 'ignoreEvents']),
  9253. longPressThreshold: propTypes.number,
  9254. onNavigate: propTypes.func,
  9255. onSelectSlot: propTypes.func,
  9256. onSelectEvent: propTypes.func,
  9257. onDoubleClickEvent: propTypes.func,
  9258. onShowMore: propTypes.func,
  9259. onDrillDown: propTypes.func,
  9260. getDrilldownView: propTypes.func.isRequired,
  9261. popup: propTypes.bool,
  9262. popupOffset: propTypes.oneOfType([propTypes.number, propTypes.shape({
  9263. x: propTypes.number,
  9264. y: propTypes.number
  9265. })])
  9266. };
  9267. MonthView.range = function (date, _ref4) {
  9268. var localizer = _ref4.localizer;
  9269. var start = firstVisibleDay(date, localizer);
  9270. var end = lastVisibleDay(date, localizer);
  9271. return {
  9272. start: start,
  9273. end: end
  9274. };
  9275. };
  9276. MonthView.navigate = function (date, action) {
  9277. switch (action) {
  9278. case navigate.PREVIOUS:
  9279. return add(date, -1, 'month');
  9280. case navigate.NEXT:
  9281. return add(date, 1, 'month');
  9282. default:
  9283. return date;
  9284. }
  9285. };
  9286. MonthView.title = function (date, _ref5) {
  9287. var localizer = _ref5.localizer;
  9288. return localizer.format(date, 'monthHeaderFormat');
  9289. };
  9290. var getDstOffset = function getDstOffset(start, end) {
  9291. return start.getTimezoneOffset() - end.getTimezoneOffset();
  9292. };
  9293. var getKey$1 = function getKey(min, max, step, slots) {
  9294. return "" + +startOf(min, 'minutes') + ("" + +startOf(max, 'minutes')) + (step + "-" + slots);
  9295. };
  9296. function getSlotMetrics$1(_ref) {
  9297. var start = _ref.min,
  9298. end = _ref.max,
  9299. step = _ref.step,
  9300. timeslots = _ref.timeslots;
  9301. var key = getKey$1(start, end, step, timeslots); // if the start is on a DST-changing day but *after* the moment of DST
  9302. // transition we need to add those extra minutes to our minutesFromMidnight
  9303. var daystart = startOf(start, 'day');
  9304. var daystartdstoffset = getDstOffset(daystart, start);
  9305. var totalMin = 1 + diff(start, end, 'minutes') + getDstOffset(start, end);
  9306. var minutesFromMidnight = diff(daystart, start, 'minutes') + daystartdstoffset;
  9307. var numGroups = Math.ceil(totalMin / (step * timeslots));
  9308. var numSlots = numGroups * timeslots;
  9309. var groups = new Array(numGroups);
  9310. var slots = new Array(numSlots); // Each slot date is created from "zero", instead of adding `step` to
  9311. // the previous one, in order to avoid DST oddities
  9312. for (var grp = 0; grp < numGroups; grp++) {
  9313. groups[grp] = new Array(timeslots);
  9314. for (var slot = 0; slot < timeslots; slot++) {
  9315. var slotIdx = grp * timeslots + slot;
  9316. var minFromStart = slotIdx * step; // A date with total minutes calculated from the start of the day
  9317. slots[slotIdx] = groups[grp][slot] = new Date(start.getFullYear(), start.getMonth(), start.getDate(), 0, minutesFromMidnight + minFromStart, 0, 0);
  9318. }
  9319. } // Necessary to be able to select up until the last timeslot in a day
  9320. var lastSlotMinFromStart = slots.length * step;
  9321. slots.push(new Date(start.getFullYear(), start.getMonth(), start.getDate(), 0, minutesFromMidnight + lastSlotMinFromStart, 0, 0));
  9322. function positionFromDate(date) {
  9323. var diff$1 = diff(start, date, 'minutes') + getDstOffset(start, date);
  9324. return Math.min(diff$1, totalMin);
  9325. }
  9326. return {
  9327. groups: groups,
  9328. update: function update(args) {
  9329. if (getKey$1(args) !== key) return getSlotMetrics$1(args);
  9330. return this;
  9331. },
  9332. dateIsInGroup: function dateIsInGroup(date, groupIndex) {
  9333. var nextGroup = groups[groupIndex + 1];
  9334. return inRange(date, groups[groupIndex][0], nextGroup ? nextGroup[0] : end, 'minutes');
  9335. },
  9336. nextSlot: function nextSlot(slot) {
  9337. var next = slots[Math.min(slots.indexOf(slot) + 1, slots.length - 1)]; // in the case of the last slot we won't a long enough range so manually get it
  9338. if (next === slot) next = add(slot, step, 'minutes');
  9339. return next;
  9340. },
  9341. closestSlotToPosition: function closestSlotToPosition(percent) {
  9342. var slot = Math.min(slots.length - 1, Math.max(0, Math.floor(percent * numSlots)));
  9343. return slots[slot];
  9344. },
  9345. closestSlotFromPoint: function closestSlotFromPoint(point, boundaryRect) {
  9346. var range = Math.abs(boundaryRect.top - boundaryRect.bottom);
  9347. return this.closestSlotToPosition((point.y - boundaryRect.top) / range);
  9348. },
  9349. closestSlotFromDate: function closestSlotFromDate(date, offset) {
  9350. if (offset === void 0) {
  9351. offset = 0;
  9352. }
  9353. if (lt(date, start, 'minutes')) return slots[0];
  9354. var diffMins = diff(start, date, 'minutes');
  9355. return slots[(diffMins - diffMins % step) / step + offset];
  9356. },
  9357. startsBeforeDay: function startsBeforeDay(date) {
  9358. return lt(date, start, 'day');
  9359. },
  9360. startsAfterDay: function startsAfterDay(date) {
  9361. return gt(date, end, 'day');
  9362. },
  9363. startsBefore: function startsBefore(date) {
  9364. return lt(merge(start, date), start, 'minutes');
  9365. },
  9366. startsAfter: function startsAfter(date) {
  9367. return gt(merge(end, date), end, 'minutes');
  9368. },
  9369. getRange: function getRange(rangeStart, rangeEnd, ignoreMin, ignoreMax) {
  9370. if (!ignoreMin) rangeStart = min(end, max(start, rangeStart));
  9371. if (!ignoreMax) rangeEnd = min(end, max(start, rangeEnd));
  9372. var rangeStartMin = positionFromDate(rangeStart);
  9373. var rangeEndMin = positionFromDate(rangeEnd);
  9374. var top = rangeEndMin - rangeStartMin < step && !eq(end, rangeEnd) ? (rangeStartMin - step) / (step * numSlots) * 100 : rangeStartMin / (step * numSlots) * 100;
  9375. return {
  9376. top: top,
  9377. height: rangeEndMin / (step * numSlots) * 100 - top,
  9378. start: positionFromDate(rangeStart),
  9379. startDate: rangeStart,
  9380. end: positionFromDate(rangeEnd),
  9381. endDate: rangeEnd
  9382. };
  9383. },
  9384. getCurrentTimePosition: function getCurrentTimePosition(rangeStart) {
  9385. var rangeStartMin = positionFromDate(rangeStart);
  9386. var top = rangeStartMin / (step * numSlots) * 100;
  9387. return top;
  9388. }
  9389. };
  9390. }
  9391. function _defineProperties(target, props) {
  9392. for (var i = 0; i < props.length; i++) {
  9393. var descriptor = props[i];
  9394. descriptor.enumerable = descriptor.enumerable || false;
  9395. descriptor.configurable = true;
  9396. if ("value" in descriptor) descriptor.writable = true;
  9397. Object.defineProperty(target, descriptor.key, descriptor);
  9398. }
  9399. }
  9400. function _createClass(Constructor, protoProps, staticProps) {
  9401. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  9402. if (staticProps) _defineProperties(Constructor, staticProps);
  9403. return Constructor;
  9404. }
  9405. /** Built-in value references. */
  9406. var spreadableSymbol = Symbol$1 ? Symbol$1.isConcatSpreadable : undefined;
  9407. /**
  9408. * Checks if `value` is a flattenable `arguments` object or array.
  9409. *
  9410. * @private
  9411. * @param {*} value The value to check.
  9412. * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
  9413. */
  9414. function isFlattenable(value) {
  9415. return isArray(value) || isArguments(value) ||
  9416. !!(spreadableSymbol && value && value[spreadableSymbol]);
  9417. }
  9418. /**
  9419. * The base implementation of `_.flatten` with support for restricting flattening.
  9420. *
  9421. * @private
  9422. * @param {Array} array The array to flatten.
  9423. * @param {number} depth The maximum recursion depth.
  9424. * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
  9425. * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
  9426. * @param {Array} [result=[]] The initial result value.
  9427. * @returns {Array} Returns the new flattened array.
  9428. */
  9429. function baseFlatten(array, depth, predicate, isStrict, result) {
  9430. var index = -1,
  9431. length = array.length;
  9432. predicate || (predicate = isFlattenable);
  9433. result || (result = []);
  9434. while (++index < length) {
  9435. var value = array[index];
  9436. if (depth > 0 && predicate(value)) {
  9437. if (depth > 1) {
  9438. // Recursively flatten arrays (susceptible to call stack limits).
  9439. baseFlatten(value, depth - 1, predicate, isStrict, result);
  9440. } else {
  9441. arrayPush(result, value);
  9442. }
  9443. } else if (!isStrict) {
  9444. result[result.length] = value;
  9445. }
  9446. }
  9447. return result;
  9448. }
  9449. /**
  9450. * Creates a base function for methods like `_.forIn` and `_.forOwn`.
  9451. *
  9452. * @private
  9453. * @param {boolean} [fromRight] Specify iterating from right to left.
  9454. * @returns {Function} Returns the new base function.
  9455. */
  9456. function createBaseFor(fromRight) {
  9457. return function(object, iteratee, keysFunc) {
  9458. var index = -1,
  9459. iterable = Object(object),
  9460. props = keysFunc(object),
  9461. length = props.length;
  9462. while (length--) {
  9463. var key = props[fromRight ? length : ++index];
  9464. if (iteratee(iterable[key], key, iterable) === false) {
  9465. break;
  9466. }
  9467. }
  9468. return object;
  9469. };
  9470. }
  9471. /**
  9472. * The base implementation of `baseForOwn` which iterates over `object`
  9473. * properties returned by `keysFunc` and invokes `iteratee` for each property.
  9474. * Iteratee functions may exit iteration early by explicitly returning `false`.
  9475. *
  9476. * @private
  9477. * @param {Object} object The object to iterate over.
  9478. * @param {Function} iteratee The function invoked per iteration.
  9479. * @param {Function} keysFunc The function to get the keys of `object`.
  9480. * @returns {Object} Returns `object`.
  9481. */
  9482. var baseFor = createBaseFor();
  9483. /**
  9484. * The base implementation of `_.forOwn` without support for iteratee shorthands.
  9485. *
  9486. * @private
  9487. * @param {Object} object The object to iterate over.
  9488. * @param {Function} iteratee The function invoked per iteration.
  9489. * @returns {Object} Returns `object`.
  9490. */
  9491. function baseForOwn(object, iteratee) {
  9492. return object && baseFor(object, iteratee, keys);
  9493. }
  9494. /**
  9495. * Creates a `baseEach` or `baseEachRight` function.
  9496. *
  9497. * @private
  9498. * @param {Function} eachFunc The function to iterate over a collection.
  9499. * @param {boolean} [fromRight] Specify iterating from right to left.
  9500. * @returns {Function} Returns the new base function.
  9501. */
  9502. function createBaseEach(eachFunc, fromRight) {
  9503. return function(collection, iteratee) {
  9504. if (collection == null) {
  9505. return collection;
  9506. }
  9507. if (!isArrayLike(collection)) {
  9508. return eachFunc(collection, iteratee);
  9509. }
  9510. var length = collection.length,
  9511. index = fromRight ? length : -1,
  9512. iterable = Object(collection);
  9513. while ((fromRight ? index-- : ++index < length)) {
  9514. if (iteratee(iterable[index], index, iterable) === false) {
  9515. break;
  9516. }
  9517. }
  9518. return collection;
  9519. };
  9520. }
  9521. /**
  9522. * The base implementation of `_.forEach` without support for iteratee shorthands.
  9523. *
  9524. * @private
  9525. * @param {Array|Object} collection The collection to iterate over.
  9526. * @param {Function} iteratee The function invoked per iteration.
  9527. * @returns {Array|Object} Returns `collection`.
  9528. */
  9529. var baseEach = createBaseEach(baseForOwn);
  9530. /**
  9531. * The base implementation of `_.map` without support for iteratee shorthands.
  9532. *
  9533. * @private
  9534. * @param {Array|Object} collection The collection to iterate over.
  9535. * @param {Function} iteratee The function invoked per iteration.
  9536. * @returns {Array} Returns the new mapped array.
  9537. */
  9538. function baseMap(collection, iteratee) {
  9539. var index = -1,
  9540. result = isArrayLike(collection) ? Array(collection.length) : [];
  9541. baseEach(collection, function(value, key, collection) {
  9542. result[++index] = iteratee(value, key, collection);
  9543. });
  9544. return result;
  9545. }
  9546. /**
  9547. * The base implementation of `_.sortBy` which uses `comparer` to define the
  9548. * sort order of `array` and replaces criteria objects with their corresponding
  9549. * values.
  9550. *
  9551. * @private
  9552. * @param {Array} array The array to sort.
  9553. * @param {Function} comparer The function to define sort order.
  9554. * @returns {Array} Returns `array`.
  9555. */
  9556. function baseSortBy(array, comparer) {
  9557. var length = array.length;
  9558. array.sort(comparer);
  9559. while (length--) {
  9560. array[length] = array[length].value;
  9561. }
  9562. return array;
  9563. }
  9564. /**
  9565. * Compares values to sort them in ascending order.
  9566. *
  9567. * @private
  9568. * @param {*} value The value to compare.
  9569. * @param {*} other The other value to compare.
  9570. * @returns {number} Returns the sort order indicator for `value`.
  9571. */
  9572. function compareAscending(value, other) {
  9573. if (value !== other) {
  9574. var valIsDefined = value !== undefined,
  9575. valIsNull = value === null,
  9576. valIsReflexive = value === value,
  9577. valIsSymbol = isSymbol(value);
  9578. var othIsDefined = other !== undefined,
  9579. othIsNull = other === null,
  9580. othIsReflexive = other === other,
  9581. othIsSymbol = isSymbol(other);
  9582. if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) ||
  9583. (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) ||
  9584. (valIsNull && othIsDefined && othIsReflexive) ||
  9585. (!valIsDefined && othIsReflexive) ||
  9586. !valIsReflexive) {
  9587. return 1;
  9588. }
  9589. if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) ||
  9590. (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) ||
  9591. (othIsNull && valIsDefined && valIsReflexive) ||
  9592. (!othIsDefined && valIsReflexive) ||
  9593. !othIsReflexive) {
  9594. return -1;
  9595. }
  9596. }
  9597. return 0;
  9598. }
  9599. /**
  9600. * Used by `_.orderBy` to compare multiple properties of a value to another
  9601. * and stable sort them.
  9602. *
  9603. * If `orders` is unspecified, all values are sorted in ascending order. Otherwise,
  9604. * specify an order of "desc" for descending or "asc" for ascending sort order
  9605. * of corresponding values.
  9606. *
  9607. * @private
  9608. * @param {Object} object The object to compare.
  9609. * @param {Object} other The other object to compare.
  9610. * @param {boolean[]|string[]} orders The order to sort by for each property.
  9611. * @returns {number} Returns the sort order indicator for `object`.
  9612. */
  9613. function compareMultiple(object, other, orders) {
  9614. var index = -1,
  9615. objCriteria = object.criteria,
  9616. othCriteria = other.criteria,
  9617. length = objCriteria.length,
  9618. ordersLength = orders.length;
  9619. while (++index < length) {
  9620. var result = compareAscending(objCriteria[index], othCriteria[index]);
  9621. if (result) {
  9622. if (index >= ordersLength) {
  9623. return result;
  9624. }
  9625. var order = orders[index];
  9626. return result * (order == 'desc' ? -1 : 1);
  9627. }
  9628. }
  9629. // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
  9630. // that causes it, under certain circumstances, to provide the same value for
  9631. // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247
  9632. // for more details.
  9633. //
  9634. // This also ensures a stable sort in V8 and other engines.
  9635. // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
  9636. return object.index - other.index;
  9637. }
  9638. /**
  9639. * The base implementation of `_.orderBy` without param guards.
  9640. *
  9641. * @private
  9642. * @param {Array|Object} collection The collection to iterate over.
  9643. * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by.
  9644. * @param {string[]} orders The sort orders of `iteratees`.
  9645. * @returns {Array} Returns the new sorted array.
  9646. */
  9647. function baseOrderBy(collection, iteratees, orders) {
  9648. var index = -1;
  9649. iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));
  9650. var result = baseMap(collection, function(value, key, collection) {
  9651. var criteria = arrayMap(iteratees, function(iteratee) {
  9652. return iteratee(value);
  9653. });
  9654. return { 'criteria': criteria, 'index': ++index, 'value': value };
  9655. });
  9656. return baseSortBy(result, function(object, other) {
  9657. return compareMultiple(object, other, orders);
  9658. });
  9659. }
  9660. /**
  9661. * A faster alternative to `Function#apply`, this function invokes `func`
  9662. * with the `this` binding of `thisArg` and the arguments of `args`.
  9663. *
  9664. * @private
  9665. * @param {Function} func The function to invoke.
  9666. * @param {*} thisArg The `this` binding of `func`.
  9667. * @param {Array} args The arguments to invoke `func` with.
  9668. * @returns {*} Returns the result of `func`.
  9669. */
  9670. function apply(func, thisArg, args) {
  9671. switch (args.length) {
  9672. case 0: return func.call(thisArg);
  9673. case 1: return func.call(thisArg, args[0]);
  9674. case 2: return func.call(thisArg, args[0], args[1]);
  9675. case 3: return func.call(thisArg, args[0], args[1], args[2]);
  9676. }
  9677. return func.apply(thisArg, args);
  9678. }
  9679. /* Built-in method references for those with the same name as other `lodash` methods. */
  9680. var nativeMax$3 = Math.max;
  9681. /**
  9682. * A specialized version of `baseRest` which transforms the rest array.
  9683. *
  9684. * @private
  9685. * @param {Function} func The function to apply a rest parameter to.
  9686. * @param {number} [start=func.length-1] The start position of the rest parameter.
  9687. * @param {Function} transform The rest array transform.
  9688. * @returns {Function} Returns the new function.
  9689. */
  9690. function overRest(func, start, transform) {
  9691. start = nativeMax$3(start === undefined ? (func.length - 1) : start, 0);
  9692. return function() {
  9693. var args = arguments,
  9694. index = -1,
  9695. length = nativeMax$3(args.length - start, 0),
  9696. array = Array(length);
  9697. while (++index < length) {
  9698. array[index] = args[start + index];
  9699. }
  9700. index = -1;
  9701. var otherArgs = Array(start + 1);
  9702. while (++index < start) {
  9703. otherArgs[index] = args[index];
  9704. }
  9705. otherArgs[start] = transform(array);
  9706. return apply(func, this, otherArgs);
  9707. };
  9708. }
  9709. /**
  9710. * Creates a function that returns `value`.
  9711. *
  9712. * @static
  9713. * @memberOf _
  9714. * @since 2.4.0
  9715. * @category Util
  9716. * @param {*} value The value to return from the new function.
  9717. * @returns {Function} Returns the new constant function.
  9718. * @example
  9719. *
  9720. * var objects = _.times(2, _.constant({ 'a': 1 }));
  9721. *
  9722. * console.log(objects);
  9723. * // => [{ 'a': 1 }, { 'a': 1 }]
  9724. *
  9725. * console.log(objects[0] === objects[1]);
  9726. * // => true
  9727. */
  9728. function constant(value) {
  9729. return function() {
  9730. return value;
  9731. };
  9732. }
  9733. var defineProperty$1 = (function() {
  9734. try {
  9735. var func = getNative(Object, 'defineProperty');
  9736. func({}, '', {});
  9737. return func;
  9738. } catch (e) {}
  9739. }());
  9740. /**
  9741. * The base implementation of `setToString` without support for hot loop shorting.
  9742. *
  9743. * @private
  9744. * @param {Function} func The function to modify.
  9745. * @param {Function} string The `toString` result.
  9746. * @returns {Function} Returns `func`.
  9747. */
  9748. var baseSetToString = !defineProperty$1 ? identity : function(func, string) {
  9749. return defineProperty$1(func, 'toString', {
  9750. 'configurable': true,
  9751. 'enumerable': false,
  9752. 'value': constant(string),
  9753. 'writable': true
  9754. });
  9755. };
  9756. /** Used to detect hot functions by number of calls within a span of milliseconds. */
  9757. var HOT_COUNT = 800,
  9758. HOT_SPAN = 16;
  9759. /* Built-in method references for those with the same name as other `lodash` methods. */
  9760. var nativeNow = Date.now;
  9761. /**
  9762. * Creates a function that'll short out and invoke `identity` instead
  9763. * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
  9764. * milliseconds.
  9765. *
  9766. * @private
  9767. * @param {Function} func The function to restrict.
  9768. * @returns {Function} Returns the new shortable function.
  9769. */
  9770. function shortOut(func) {
  9771. var count = 0,
  9772. lastCalled = 0;
  9773. return function() {
  9774. var stamp = nativeNow(),
  9775. remaining = HOT_SPAN - (stamp - lastCalled);
  9776. lastCalled = stamp;
  9777. if (remaining > 0) {
  9778. if (++count >= HOT_COUNT) {
  9779. return arguments[0];
  9780. }
  9781. } else {
  9782. count = 0;
  9783. }
  9784. return func.apply(undefined, arguments);
  9785. };
  9786. }
  9787. /**
  9788. * Sets the `toString` method of `func` to return `string`.
  9789. *
  9790. * @private
  9791. * @param {Function} func The function to modify.
  9792. * @param {Function} string The `toString` result.
  9793. * @returns {Function} Returns `func`.
  9794. */
  9795. var setToString = shortOut(baseSetToString);
  9796. /**
  9797. * The base implementation of `_.rest` which doesn't validate or coerce arguments.
  9798. *
  9799. * @private
  9800. * @param {Function} func The function to apply a rest parameter to.
  9801. * @param {number} [start=func.length-1] The start position of the rest parameter.
  9802. * @returns {Function} Returns the new function.
  9803. */
  9804. function baseRest(func, start) {
  9805. return setToString(overRest(func, start, identity), func + '');
  9806. }
  9807. /**
  9808. * Creates an array of elements, sorted in ascending order by the results of
  9809. * running each element in a collection thru each iteratee. This method
  9810. * performs a stable sort, that is, it preserves the original sort order of
  9811. * equal elements. The iteratees are invoked with one argument: (value).
  9812. *
  9813. * @static
  9814. * @memberOf _
  9815. * @since 0.1.0
  9816. * @category Collection
  9817. * @param {Array|Object} collection The collection to iterate over.
  9818. * @param {...(Function|Function[])} [iteratees=[_.identity]]
  9819. * The iteratees to sort by.
  9820. * @returns {Array} Returns the new sorted array.
  9821. * @example
  9822. *
  9823. * var users = [
  9824. * { 'user': 'fred', 'age': 48 },
  9825. * { 'user': 'barney', 'age': 36 },
  9826. * { 'user': 'fred', 'age': 40 },
  9827. * { 'user': 'barney', 'age': 34 }
  9828. * ];
  9829. *
  9830. * _.sortBy(users, [function(o) { return o.user; }]);
  9831. * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
  9832. *
  9833. * _.sortBy(users, ['user', 'age']);
  9834. * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
  9835. */
  9836. var sortBy = baseRest(function(collection, iteratees) {
  9837. if (collection == null) {
  9838. return [];
  9839. }
  9840. var length = iteratees.length;
  9841. if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
  9842. iteratees = [];
  9843. } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
  9844. iteratees = [iteratees[0]];
  9845. }
  9846. return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
  9847. });
  9848. var Event =
  9849. /*#__PURE__*/
  9850. function () {
  9851. function Event(data, _ref) {
  9852. var accessors = _ref.accessors,
  9853. slotMetrics = _ref.slotMetrics;
  9854. var _slotMetrics$getRange = slotMetrics.getRange(accessors.start(data), accessors.end(data)),
  9855. start = _slotMetrics$getRange.start,
  9856. startDate = _slotMetrics$getRange.startDate,
  9857. end = _slotMetrics$getRange.end,
  9858. endDate = _slotMetrics$getRange.endDate,
  9859. top = _slotMetrics$getRange.top,
  9860. height = _slotMetrics$getRange.height;
  9861. this.start = start;
  9862. this.end = end;
  9863. this.startMs = +startDate;
  9864. this.endMs = +endDate;
  9865. this.top = top;
  9866. this.height = height;
  9867. this.data = data;
  9868. }
  9869. /**
  9870. * The event's width without any overlap.
  9871. */
  9872. _createClass(Event, [{
  9873. key: "_width",
  9874. get: function get() {
  9875. // The container event's width is determined by the maximum number of
  9876. // events in any of its rows.
  9877. if (this.rows) {
  9878. var columns = this.rows.reduce(function (max, row) {
  9879. return Math.max(max, row.leaves.length + 1);
  9880. }, // add itself
  9881. 0) + 1; // add the container
  9882. return 100 / columns;
  9883. }
  9884. var availableWidth = 100 - this.container._width; // The row event's width is the space left by the container, divided
  9885. // among itself and its leaves.
  9886. if (this.leaves) {
  9887. return availableWidth / (this.leaves.length + 1);
  9888. } // The leaf event's width is determined by its row's width
  9889. return this.row._width;
  9890. }
  9891. /**
  9892. * The event's calculated width, possibly with extra width added for
  9893. * overlapping effect.
  9894. */
  9895. }, {
  9896. key: "width",
  9897. get: function get() {
  9898. var noOverlap = this._width;
  9899. var overlap = Math.min(100, this._width * 1.7); // Containers can always grow.
  9900. if (this.rows) {
  9901. return overlap;
  9902. } // Rows can grow if they have leaves.
  9903. if (this.leaves) {
  9904. return this.leaves.length > 0 ? overlap : noOverlap;
  9905. } // Leaves can grow unless they're the last item in a row.
  9906. var leaves = this.row.leaves;
  9907. var index = leaves.indexOf(this);
  9908. return index === leaves.length - 1 ? noOverlap : overlap;
  9909. }
  9910. }, {
  9911. key: "xOffset",
  9912. get: function get() {
  9913. // Containers have no offset.
  9914. if (this.rows) return 0; // Rows always start where their container ends.
  9915. if (this.leaves) return this.container._width; // Leaves are spread out evenly on the space left by its row.
  9916. var _this$row = this.row,
  9917. leaves = _this$row.leaves,
  9918. xOffset = _this$row.xOffset,
  9919. _width = _this$row._width;
  9920. var index = leaves.indexOf(this) + 1;
  9921. return xOffset + index * _width;
  9922. }
  9923. }]);
  9924. return Event;
  9925. }();
  9926. /**
  9927. * Return true if event a and b is considered to be on the same row.
  9928. */
  9929. function onSameRow(a, b, minimumStartDifference) {
  9930. return (// Occupies the same start slot.
  9931. Math.abs(b.start - a.start) < minimumStartDifference || // A's start slot overlaps with b's end slot.
  9932. b.start > a.start && b.start < a.end
  9933. );
  9934. }
  9935. function sortByRender(events) {
  9936. var sortedByTime = sortBy(events, ['startMs', function (e) {
  9937. return -e.endMs;
  9938. }]);
  9939. var sorted = [];
  9940. while (sortedByTime.length > 0) {
  9941. var event = sortedByTime.shift();
  9942. sorted.push(event);
  9943. for (var i = 0; i < sortedByTime.length; i++) {
  9944. var test = sortedByTime[i]; // Still inside this event, look for next.
  9945. if (event.endMs > test.startMs) continue; // We've found the first event of the next event group.
  9946. // If that event is not right next to our current event, we have to
  9947. // move it here.
  9948. if (i > 0) {
  9949. var _event = sortedByTime.splice(i, 1)[0];
  9950. sorted.push(_event);
  9951. } // We've already found the next event group, so stop looking.
  9952. break;
  9953. }
  9954. }
  9955. return sorted;
  9956. }
  9957. function getStyledEvents(_ref2) {
  9958. var events = _ref2.events,
  9959. minimumStartDifference = _ref2.minimumStartDifference,
  9960. slotMetrics = _ref2.slotMetrics,
  9961. accessors = _ref2.accessors;
  9962. // Create proxy events and order them so that we don't have
  9963. // to fiddle with z-indexes.
  9964. var proxies = events.map(function (event) {
  9965. return new Event(event, {
  9966. slotMetrics: slotMetrics,
  9967. accessors: accessors
  9968. });
  9969. });
  9970. var eventsInRenderOrder = sortByRender(proxies); // Group overlapping events, while keeping order.
  9971. // Every event is always one of: container, row or leaf.
  9972. // Containers can contain rows, and rows can contain leaves.
  9973. var containerEvents = [];
  9974. var _loop = function _loop(i) {
  9975. var event = eventsInRenderOrder[i]; // Check if this event can go into a container event.
  9976. var container = containerEvents.find(function (c) {
  9977. return c.end > event.start || Math.abs(event.start - c.start) < minimumStartDifference;
  9978. }); // Couldn't find a container — that means this event is a container.
  9979. if (!container) {
  9980. event.rows = [];
  9981. containerEvents.push(event);
  9982. return "continue";
  9983. } // Found a container for the event.
  9984. event.container = container; // Check if the event can be placed in an existing row.
  9985. // Start looking from behind.
  9986. var row = null;
  9987. for (var j = container.rows.length - 1; !row && j >= 0; j--) {
  9988. if (onSameRow(container.rows[j], event, minimumStartDifference)) {
  9989. row = container.rows[j];
  9990. }
  9991. }
  9992. if (row) {
  9993. // Found a row, so add it.
  9994. row.leaves.push(event);
  9995. event.row = row;
  9996. } else {
  9997. // Couldn't find a row – that means this event is a row.
  9998. event.leaves = [];
  9999. container.rows.push(event);
  10000. }
  10001. };
  10002. for (var i = 0; i < eventsInRenderOrder.length; i++) {
  10003. var _ret = _loop(i);
  10004. if (_ret === "continue") continue;
  10005. } // Return the original events, along with their styles.
  10006. return eventsInRenderOrder.map(function (event) {
  10007. return {
  10008. event: event.data,
  10009. style: {
  10010. top: event.top,
  10011. height: event.height,
  10012. width: event.width,
  10013. xOffset: event.xOffset
  10014. }
  10015. };
  10016. });
  10017. }
  10018. var TimeSlotGroup =
  10019. /*#__PURE__*/
  10020. function (_Component) {
  10021. _inheritsLoose(TimeSlotGroup, _Component);
  10022. function TimeSlotGroup() {
  10023. return _Component.apply(this, arguments) || this;
  10024. }
  10025. var _proto = TimeSlotGroup.prototype;
  10026. _proto.render = function render() {
  10027. var _this$props = this.props,
  10028. renderSlot = _this$props.renderSlot,
  10029. resource = _this$props.resource,
  10030. group = _this$props.group,
  10031. getters = _this$props.getters,
  10032. _this$props$component = _this$props.components;
  10033. _this$props$component = _this$props$component === void 0 ? {} : _this$props$component;
  10034. var _this$props$component2 = _this$props$component.timeSlotWrapper,
  10035. Wrapper = _this$props$component2 === void 0 ? NoopWrapper : _this$props$component2;
  10036. return React__default.createElement("div", {
  10037. className: "rbc-timeslot-group"
  10038. }, group.map(function (value, idx) {
  10039. var slotProps = getters ? getters.slotProp(value, resource) : {};
  10040. return React__default.createElement(Wrapper, {
  10041. key: idx,
  10042. value: value,
  10043. resource: resource
  10044. }, React__default.createElement("div", _extends({}, slotProps, {
  10045. className: clsx('rbc-time-slot', slotProps.className)
  10046. }), renderSlot && renderSlot(value, idx)));
  10047. }));
  10048. };
  10049. return TimeSlotGroup;
  10050. }(React.Component);
  10051. TimeSlotGroup.propTypes = {
  10052. renderSlot: propTypes.func,
  10053. group: propTypes.array.isRequired,
  10054. resource: propTypes.any,
  10055. components: propTypes.object,
  10056. getters: propTypes.object
  10057. };
  10058. /* eslint-disable react/prop-types */
  10059. function TimeGridEvent(props) {
  10060. var _extends2;
  10061. var style = props.style,
  10062. className = props.className,
  10063. event = props.event,
  10064. accessors = props.accessors,
  10065. rtl = props.rtl,
  10066. selected = props.selected,
  10067. label = props.label,
  10068. continuesEarlier = props.continuesEarlier,
  10069. continuesLater = props.continuesLater,
  10070. getters = props.getters,
  10071. onClick = props.onClick,
  10072. onDoubleClick = props.onDoubleClick,
  10073. _props$components = props.components,
  10074. Event = _props$components.event,
  10075. EventWrapper = _props$components.eventWrapper;
  10076. var title = accessors.title(event);
  10077. var tooltip = accessors.tooltip(event);
  10078. var end = accessors.end(event);
  10079. var start = accessors.start(event);
  10080. var userProps = getters.eventProp(event, start, end, selected);
  10081. var height = style.height,
  10082. top = style.top,
  10083. width = style.width,
  10084. xOffset = style.xOffset;
  10085. var inner = [React__default.createElement("div", {
  10086. key: "1",
  10087. className: "rbc-event-label"
  10088. }, label), React__default.createElement("div", {
  10089. key: "2",
  10090. className: "rbc-event-content"
  10091. }, Event ? React__default.createElement(Event, {
  10092. event: event,
  10093. title: title
  10094. }) : title)];
  10095. return React__default.createElement(EventWrapper, _extends({
  10096. type: "time"
  10097. }, props), React__default.createElement("div", {
  10098. onClick: onClick,
  10099. onDoubleClick: onDoubleClick,
  10100. style: _extends({}, userProps.style, (_extends2 = {
  10101. top: top + "%",
  10102. height: height + "%"
  10103. }, _extends2[rtl ? 'right' : 'left'] = Math.max(0, xOffset) + "%", _extends2.width = width + "%", _extends2)),
  10104. title: tooltip ? (typeof label === 'string' ? label + ': ' : '') + tooltip : undefined,
  10105. className: clsx('rbc-event', className, userProps.className, {
  10106. 'rbc-selected': selected,
  10107. 'rbc-event-continues-earlier': continuesEarlier,
  10108. 'rbc-event-continues-later': continuesLater
  10109. })
  10110. }, inner));
  10111. }
  10112. var DayColumn =
  10113. /*#__PURE__*/
  10114. function (_React$Component) {
  10115. _inheritsLoose(DayColumn, _React$Component);
  10116. function DayColumn() {
  10117. var _this;
  10118. for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
  10119. _args[_key] = arguments[_key];
  10120. }
  10121. _this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;
  10122. _this.state = {
  10123. selecting: false,
  10124. timeIndicatorPosition: null
  10125. };
  10126. _this.intervalTriggered = false;
  10127. _this.renderEvents = function () {
  10128. var _this$props = _this.props,
  10129. events = _this$props.events,
  10130. rtl = _this$props.rtl,
  10131. selected = _this$props.selected,
  10132. accessors = _this$props.accessors,
  10133. localizer = _this$props.localizer,
  10134. getters = _this$props.getters,
  10135. components = _this$props.components,
  10136. step = _this$props.step,
  10137. timeslots = _this$props.timeslots;
  10138. var _assertThisInitialize = _assertThisInitialized(_this),
  10139. slotMetrics = _assertThisInitialize.slotMetrics;
  10140. var messages = localizer.messages;
  10141. var styledEvents = getStyledEvents({
  10142. events: events,
  10143. accessors: accessors,
  10144. slotMetrics: slotMetrics,
  10145. minimumStartDifference: Math.ceil(step * timeslots / 2)
  10146. });
  10147. return styledEvents.map(function (_ref, idx) {
  10148. var event = _ref.event,
  10149. style = _ref.style;
  10150. var end = accessors.end(event);
  10151. var start = accessors.start(event);
  10152. var format = 'eventTimeRangeFormat';
  10153. var label;
  10154. var startsBeforeDay = slotMetrics.startsBeforeDay(start);
  10155. var startsAfterDay = slotMetrics.startsAfterDay(end);
  10156. if (startsBeforeDay) format = 'eventTimeRangeEndFormat';else if (startsAfterDay) format = 'eventTimeRangeStartFormat';
  10157. if (startsBeforeDay && startsAfterDay) label = messages.allDay;else label = localizer.format({
  10158. start: start,
  10159. end: end
  10160. }, format);
  10161. var continuesEarlier = startsBeforeDay || slotMetrics.startsBefore(start);
  10162. var continuesLater = startsAfterDay || slotMetrics.startsAfter(end);
  10163. return React__default.createElement(TimeGridEvent, {
  10164. style: style,
  10165. event: event,
  10166. label: label,
  10167. key: 'evt_' + idx,
  10168. getters: getters,
  10169. rtl: rtl,
  10170. components: components,
  10171. continuesEarlier: continuesEarlier,
  10172. continuesLater: continuesLater,
  10173. accessors: accessors,
  10174. selected: isSelected(event, selected),
  10175. onClick: function onClick(e) {
  10176. return _this._select(event, e);
  10177. },
  10178. onDoubleClick: function onDoubleClick(e) {
  10179. return _this._doubleClick(event, e);
  10180. }
  10181. });
  10182. });
  10183. };
  10184. _this._selectable = function () {
  10185. var node = ReactDOM.findDOMNode(_assertThisInitialized(_this));
  10186. var selector = _this._selector = new Selection(function () {
  10187. return ReactDOM.findDOMNode(_assertThisInitialized(_this));
  10188. }, {
  10189. longPressThreshold: _this.props.longPressThreshold
  10190. });
  10191. var maybeSelect = function maybeSelect(box) {
  10192. var onSelecting = _this.props.onSelecting;
  10193. var current = _this.state || {};
  10194. var state = selectionState(box);
  10195. var start = state.startDate,
  10196. end = state.endDate;
  10197. if (onSelecting) {
  10198. if (eq(current.startDate, start, 'minutes') && eq(current.endDate, end, 'minutes') || onSelecting({
  10199. start: start,
  10200. end: end
  10201. }) === false) return;
  10202. }
  10203. if (_this.state.start !== state.start || _this.state.end !== state.end || _this.state.selecting !== state.selecting) {
  10204. _this.setState(state);
  10205. }
  10206. };
  10207. var selectionState = function selectionState(point) {
  10208. var currentSlot = _this.slotMetrics.closestSlotFromPoint(point, getBoundsForNode(node));
  10209. if (!_this.state.selecting) {
  10210. _this._initialSlot = currentSlot;
  10211. }
  10212. var initialSlot = _this._initialSlot;
  10213. if (lte(initialSlot, currentSlot)) {
  10214. currentSlot = _this.slotMetrics.nextSlot(currentSlot);
  10215. } else if (gt(initialSlot, currentSlot)) {
  10216. initialSlot = _this.slotMetrics.nextSlot(initialSlot);
  10217. }
  10218. var selectRange = _this.slotMetrics.getRange(min(initialSlot, currentSlot), max(initialSlot, currentSlot));
  10219. return _extends({}, selectRange, {
  10220. selecting: true,
  10221. top: selectRange.top + "%",
  10222. height: selectRange.height + "%"
  10223. });
  10224. };
  10225. var selectorClicksHandler = function selectorClicksHandler(box, actionType) {
  10226. if (!isEvent(ReactDOM.findDOMNode(_assertThisInitialized(_this)), box)) {
  10227. var _selectionState = selectionState(box),
  10228. startDate = _selectionState.startDate,
  10229. endDate = _selectionState.endDate;
  10230. _this._selectSlot({
  10231. startDate: startDate,
  10232. endDate: endDate,
  10233. action: actionType,
  10234. box: box
  10235. });
  10236. }
  10237. _this.setState({
  10238. selecting: false
  10239. });
  10240. };
  10241. selector.on('selecting', maybeSelect);
  10242. selector.on('selectStart', maybeSelect);
  10243. selector.on('beforeSelect', function (box) {
  10244. if (_this.props.selectable !== 'ignoreEvents') return;
  10245. return !isEvent(ReactDOM.findDOMNode(_assertThisInitialized(_this)), box);
  10246. });
  10247. selector.on('click', function (box) {
  10248. return selectorClicksHandler(box, 'click');
  10249. });
  10250. selector.on('doubleClick', function (box) {
  10251. return selectorClicksHandler(box, 'doubleClick');
  10252. });
  10253. selector.on('select', function (bounds) {
  10254. if (_this.state.selecting) {
  10255. _this._selectSlot(_extends({}, _this.state, {
  10256. action: 'select',
  10257. bounds: bounds
  10258. }));
  10259. _this.setState({
  10260. selecting: false
  10261. });
  10262. }
  10263. });
  10264. selector.on('reset', function () {
  10265. if (_this.state.selecting) {
  10266. _this.setState({
  10267. selecting: false
  10268. });
  10269. }
  10270. });
  10271. };
  10272. _this._teardownSelectable = function () {
  10273. if (!_this._selector) return;
  10274. _this._selector.teardown();
  10275. _this._selector = null;
  10276. };
  10277. _this._selectSlot = function (_ref2) {
  10278. var startDate = _ref2.startDate,
  10279. endDate = _ref2.endDate,
  10280. action = _ref2.action,
  10281. bounds = _ref2.bounds,
  10282. box = _ref2.box;
  10283. var current = startDate,
  10284. slots = [];
  10285. while (lte(current, endDate)) {
  10286. slots.push(current);
  10287. current = add(current, _this.props.step, 'minutes');
  10288. }
  10289. notify(_this.props.onSelectSlot, {
  10290. slots: slots,
  10291. start: startDate,
  10292. end: endDate,
  10293. resourceId: _this.props.resource,
  10294. action: action,
  10295. bounds: bounds,
  10296. box: box
  10297. });
  10298. };
  10299. _this._select = function () {
  10300. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  10301. args[_key2] = arguments[_key2];
  10302. }
  10303. notify(_this.props.onSelectEvent, args);
  10304. };
  10305. _this._doubleClick = function () {
  10306. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  10307. args[_key3] = arguments[_key3];
  10308. }
  10309. notify(_this.props.onDoubleClickEvent, args);
  10310. };
  10311. _this.slotMetrics = getSlotMetrics$1(_this.props);
  10312. return _this;
  10313. }
  10314. var _proto = DayColumn.prototype;
  10315. _proto.componentDidMount = function componentDidMount() {
  10316. this.props.selectable && this._selectable();
  10317. if (this.props.isNow) {
  10318. this.setTimeIndicatorPositionUpdateInterval();
  10319. }
  10320. };
  10321. _proto.componentWillUnmount = function componentWillUnmount() {
  10322. this._teardownSelectable();
  10323. this.clearTimeIndicatorInterval();
  10324. };
  10325. _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
  10326. if (nextProps.selectable && !this.props.selectable) this._selectable();
  10327. if (!nextProps.selectable && this.props.selectable) this._teardownSelectable();
  10328. this.slotMetrics = this.slotMetrics.update(nextProps);
  10329. };
  10330. _proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
  10331. var getNowChanged = !eq(prevProps.getNow(), this.props.getNow(), 'minutes');
  10332. if (prevProps.isNow !== this.props.isNow || getNowChanged) {
  10333. this.clearTimeIndicatorInterval();
  10334. if (this.props.isNow) {
  10335. var tail = !getNowChanged && eq(prevProps.date, this.props.date, 'minutes') && prevState.timeIndicatorPosition === this.state.timeIndicatorPosition;
  10336. this.setTimeIndicatorPositionUpdateInterval(tail);
  10337. }
  10338. } else if (this.props.isNow && (!eq(prevProps.min, this.props.min, 'minutes') || !eq(prevProps.max, this.props.max, 'minutes'))) {
  10339. this.positionTimeIndicator();
  10340. }
  10341. };
  10342. /**
  10343. * @param tail {Boolean} - whether `positionTimeIndicator` call should be
  10344. * deferred or called upon setting interval (`true` - if deferred);
  10345. */
  10346. _proto.setTimeIndicatorPositionUpdateInterval = function setTimeIndicatorPositionUpdateInterval(tail) {
  10347. var _this2 = this;
  10348. if (tail === void 0) {
  10349. tail = false;
  10350. }
  10351. if (!this.intervalTriggered && !tail) {
  10352. this.positionTimeIndicator();
  10353. }
  10354. this._timeIndicatorTimeout = window.setTimeout(function () {
  10355. _this2.intervalTriggered = true;
  10356. _this2.positionTimeIndicator();
  10357. _this2.setTimeIndicatorPositionUpdateInterval();
  10358. }, 60000);
  10359. };
  10360. _proto.clearTimeIndicatorInterval = function clearTimeIndicatorInterval() {
  10361. this.intervalTriggered = false;
  10362. window.clearTimeout(this._timeIndicatorTimeout);
  10363. };
  10364. _proto.positionTimeIndicator = function positionTimeIndicator() {
  10365. var _this$props2 = this.props,
  10366. min = _this$props2.min,
  10367. max = _this$props2.max,
  10368. getNow = _this$props2.getNow;
  10369. var current = getNow();
  10370. if (current >= min && current <= max) {
  10371. var top = this.slotMetrics.getCurrentTimePosition(current);
  10372. this.setState({
  10373. timeIndicatorPosition: top
  10374. });
  10375. } else {
  10376. this.clearTimeIndicatorInterval();
  10377. }
  10378. };
  10379. _proto.render = function render() {
  10380. var _this$props3 = this.props,
  10381. max = _this$props3.max,
  10382. rtl = _this$props3.rtl,
  10383. isNow = _this$props3.isNow,
  10384. resource = _this$props3.resource,
  10385. accessors = _this$props3.accessors,
  10386. localizer = _this$props3.localizer,
  10387. _this$props3$getters = _this$props3.getters,
  10388. dayProp = _this$props3$getters.dayProp,
  10389. getters = _objectWithoutPropertiesLoose(_this$props3$getters, ["dayProp"]),
  10390. _this$props3$componen = _this$props3.components,
  10391. EventContainer = _this$props3$componen.eventContainerWrapper,
  10392. components = _objectWithoutPropertiesLoose(_this$props3$componen, ["eventContainerWrapper"]);
  10393. var slotMetrics = this.slotMetrics;
  10394. var _this$state = this.state,
  10395. selecting = _this$state.selecting,
  10396. top = _this$state.top,
  10397. height = _this$state.height,
  10398. startDate = _this$state.startDate,
  10399. endDate = _this$state.endDate;
  10400. var selectDates = {
  10401. start: startDate,
  10402. end: endDate
  10403. };
  10404. var _dayProp = dayProp(max),
  10405. className = _dayProp.className,
  10406. style = _dayProp.style;
  10407. return React__default.createElement("div", {
  10408. style: style,
  10409. className: clsx(className, 'rbc-day-slot', 'rbc-time-column', isNow && 'rbc-now', isNow && 'rbc-today', // WHY
  10410. selecting && 'rbc-slot-selecting')
  10411. }, slotMetrics.groups.map(function (grp, idx) {
  10412. return React__default.createElement(TimeSlotGroup, {
  10413. key: idx,
  10414. group: grp,
  10415. resource: resource,
  10416. getters: getters,
  10417. components: components
  10418. });
  10419. }), React__default.createElement(EventContainer, {
  10420. localizer: localizer,
  10421. resource: resource,
  10422. accessors: accessors,
  10423. getters: getters,
  10424. components: components,
  10425. slotMetrics: slotMetrics
  10426. }, React__default.createElement("div", {
  10427. className: clsx('rbc-events-container', rtl && 'rtl')
  10428. }, this.renderEvents())), selecting && React__default.createElement("div", {
  10429. className: "rbc-slot-selection",
  10430. style: {
  10431. top: top,
  10432. height: height
  10433. }
  10434. }, React__default.createElement("span", null, localizer.format(selectDates, 'selectRangeFormat'))), isNow && React__default.createElement("div", {
  10435. className: "rbc-current-time-indicator",
  10436. style: {
  10437. top: this.state.timeIndicatorPosition + "%"
  10438. }
  10439. }));
  10440. };
  10441. return DayColumn;
  10442. }(React__default.Component);
  10443. DayColumn.propTypes = {
  10444. events: propTypes.array.isRequired,
  10445. step: propTypes.number.isRequired,
  10446. date: propTypes.instanceOf(Date).isRequired,
  10447. min: propTypes.instanceOf(Date).isRequired,
  10448. max: propTypes.instanceOf(Date).isRequired,
  10449. getNow: propTypes.func.isRequired,
  10450. isNow: propTypes.bool,
  10451. rtl: propTypes.bool,
  10452. accessors: propTypes.object.isRequired,
  10453. components: propTypes.object.isRequired,
  10454. getters: propTypes.object.isRequired,
  10455. localizer: propTypes.object.isRequired,
  10456. showMultiDayTimes: propTypes.bool,
  10457. culture: propTypes.string,
  10458. timeslots: propTypes.number,
  10459. selected: propTypes.object,
  10460. selectable: propTypes.oneOf([true, false, 'ignoreEvents']),
  10461. eventOffset: propTypes.number,
  10462. longPressThreshold: propTypes.number,
  10463. onSelecting: propTypes.func,
  10464. onSelectSlot: propTypes.func.isRequired,
  10465. onSelectEvent: propTypes.func.isRequired,
  10466. onDoubleClickEvent: propTypes.func.isRequired,
  10467. className: propTypes.string,
  10468. dragThroughEvents: propTypes.bool,
  10469. resource: propTypes.any
  10470. };
  10471. DayColumn.defaultProps = {
  10472. dragThroughEvents: true,
  10473. timeslots: 2
  10474. };
  10475. var TimeGutter =
  10476. /*#__PURE__*/
  10477. function (_Component) {
  10478. _inheritsLoose(TimeGutter, _Component);
  10479. function TimeGutter() {
  10480. var _this;
  10481. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  10482. args[_key] = arguments[_key];
  10483. }
  10484. _this = _Component.call.apply(_Component, [this].concat(args)) || this;
  10485. _this.renderSlot = function (value, idx) {
  10486. if (idx !== 0) return null;
  10487. var _this$props = _this.props,
  10488. localizer = _this$props.localizer,
  10489. getNow = _this$props.getNow;
  10490. var isNow = _this.slotMetrics.dateIsInGroup(getNow(), idx);
  10491. return React__default.createElement("span", {
  10492. className: clsx('rbc-label', isNow && 'rbc-now')
  10493. }, localizer.format(value, 'timeGutterFormat'));
  10494. };
  10495. var _this$props2 = _this.props,
  10496. min = _this$props2.min,
  10497. max = _this$props2.max,
  10498. timeslots = _this$props2.timeslots,
  10499. step = _this$props2.step;
  10500. _this.slotMetrics = getSlotMetrics$1({
  10501. min: min,
  10502. max: max,
  10503. timeslots: timeslots,
  10504. step: step
  10505. });
  10506. return _this;
  10507. }
  10508. var _proto = TimeGutter.prototype;
  10509. _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
  10510. var min = nextProps.min,
  10511. max = nextProps.max,
  10512. timeslots = nextProps.timeslots,
  10513. step = nextProps.step;
  10514. this.slotMetrics = this.slotMetrics.update({
  10515. min: min,
  10516. max: max,
  10517. timeslots: timeslots,
  10518. step: step
  10519. });
  10520. };
  10521. _proto.render = function render() {
  10522. var _this2 = this;
  10523. var _this$props3 = this.props,
  10524. resource = _this$props3.resource,
  10525. components = _this$props3.components;
  10526. return React__default.createElement("div", {
  10527. className: "rbc-time-gutter rbc-time-column"
  10528. }, this.slotMetrics.groups.map(function (grp, idx) {
  10529. return React__default.createElement(TimeSlotGroup, {
  10530. key: idx,
  10531. group: grp,
  10532. resource: resource,
  10533. components: components,
  10534. renderSlot: _this2.renderSlot
  10535. });
  10536. }));
  10537. };
  10538. return TimeGutter;
  10539. }(React.Component);
  10540. TimeGutter.propTypes = {
  10541. min: propTypes.instanceOf(Date).isRequired,
  10542. max: propTypes.instanceOf(Date).isRequired,
  10543. timeslots: propTypes.number.isRequired,
  10544. step: propTypes.number.isRequired,
  10545. getNow: propTypes.func.isRequired,
  10546. components: propTypes.object.isRequired,
  10547. localizer: propTypes.object.isRequired,
  10548. resource: propTypes.string
  10549. };
  10550. function getWidth(node, client) {
  10551. var win = isWindow(node);
  10552. return win ? win.innerWidth : client ? node.clientWidth : offset(node).width;
  10553. }
  10554. var size;
  10555. function scrollbarSize(recalc) {
  10556. if (!size && size !== 0 || recalc) {
  10557. if (canUseDOM) {
  10558. var scrollDiv = document.createElement('div');
  10559. scrollDiv.style.position = 'absolute';
  10560. scrollDiv.style.top = '-9999px';
  10561. scrollDiv.style.width = '50px';
  10562. scrollDiv.style.height = '50px';
  10563. scrollDiv.style.overflow = 'scroll';
  10564. document.body.appendChild(scrollDiv);
  10565. size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
  10566. document.body.removeChild(scrollDiv);
  10567. }
  10568. }
  10569. return size;
  10570. }
  10571. var ResourceHeader = function ResourceHeader(_ref) {
  10572. var label = _ref.label;
  10573. return React__default.createElement(React__default.Fragment, null, label);
  10574. };
  10575. ResourceHeader.propTypes = {
  10576. label: propTypes.node,
  10577. index: propTypes.number,
  10578. resource: propTypes.object
  10579. };
  10580. var TimeGridHeader =
  10581. /*#__PURE__*/
  10582. function (_React$Component) {
  10583. _inheritsLoose(TimeGridHeader, _React$Component);
  10584. function TimeGridHeader() {
  10585. var _this;
  10586. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  10587. args[_key] = arguments[_key];
  10588. }
  10589. _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
  10590. _this.handleHeaderClick = function (date, view, e) {
  10591. e.preventDefault();
  10592. notify(_this.props.onDrillDown, [date, view]);
  10593. };
  10594. _this.renderRow = function (resource) {
  10595. var _this$props = _this.props,
  10596. events = _this$props.events,
  10597. rtl = _this$props.rtl,
  10598. selectable = _this$props.selectable,
  10599. getNow = _this$props.getNow,
  10600. range = _this$props.range,
  10601. getters = _this$props.getters,
  10602. localizer = _this$props.localizer,
  10603. accessors = _this$props.accessors,
  10604. components = _this$props.components;
  10605. var resourceId = accessors.resourceId(resource);
  10606. var eventsToDisplay = resource ? events.filter(function (event) {
  10607. return accessors.resource(event) === resourceId;
  10608. }) : events;
  10609. return React__default.createElement(DateContentRow, {
  10610. isAllDay: true,
  10611. rtl: rtl,
  10612. getNow: getNow,
  10613. minRows: 2,
  10614. range: range,
  10615. events: eventsToDisplay,
  10616. resourceId: resourceId,
  10617. className: "rbc-allday-cell",
  10618. selectable: selectable,
  10619. selected: _this.props.selected,
  10620. components: components,
  10621. accessors: accessors,
  10622. getters: getters,
  10623. localizer: localizer,
  10624. onSelect: _this.props.onSelectEvent,
  10625. onDoubleClick: _this.props.onDoubleClickEvent,
  10626. onSelectSlot: _this.props.onSelectSlot,
  10627. longPressThreshold: _this.props.longPressThreshold
  10628. });
  10629. };
  10630. return _this;
  10631. }
  10632. var _proto = TimeGridHeader.prototype;
  10633. _proto.renderHeaderCells = function renderHeaderCells(range) {
  10634. var _this2 = this;
  10635. var _this$props2 = this.props,
  10636. localizer = _this$props2.localizer,
  10637. getDrilldownView = _this$props2.getDrilldownView,
  10638. getNow = _this$props2.getNow,
  10639. dayProp = _this$props2.getters.dayProp,
  10640. _this$props2$componen = _this$props2.components.header,
  10641. HeaderComponent = _this$props2$componen === void 0 ? Header : _this$props2$componen;
  10642. var today = getNow();
  10643. return range.map(function (date, i) {
  10644. var drilldownView = getDrilldownView(date);
  10645. var label = localizer.format(date, 'dayFormat');
  10646. var _dayProp = dayProp(date),
  10647. className = _dayProp.className,
  10648. style = _dayProp.style;
  10649. var header = React__default.createElement(HeaderComponent, {
  10650. date: date,
  10651. label: label,
  10652. localizer: localizer
  10653. });
  10654. return React__default.createElement("div", {
  10655. key: i,
  10656. style: style,
  10657. className: clsx('rbc-header', className, eq(date, today, 'day') && 'rbc-today')
  10658. }, drilldownView ? React__default.createElement("a", {
  10659. href: "#",
  10660. onClick: function onClick(e) {
  10661. return _this2.handleHeaderClick(date, drilldownView, e);
  10662. }
  10663. }, header) : React__default.createElement("span", null, header));
  10664. });
  10665. };
  10666. _proto.render = function render() {
  10667. var _this3 = this;
  10668. var _this$props3 = this.props,
  10669. width = _this$props3.width,
  10670. rtl = _this$props3.rtl,
  10671. resources = _this$props3.resources,
  10672. range = _this$props3.range,
  10673. events = _this$props3.events,
  10674. getNow = _this$props3.getNow,
  10675. accessors = _this$props3.accessors,
  10676. selectable = _this$props3.selectable,
  10677. components = _this$props3.components,
  10678. getters = _this$props3.getters,
  10679. scrollRef = _this$props3.scrollRef,
  10680. localizer = _this$props3.localizer,
  10681. isOverflowing = _this$props3.isOverflowing,
  10682. _this$props3$componen = _this$props3.components,
  10683. TimeGutterHeader = _this$props3$componen.timeGutterHeader,
  10684. _this$props3$componen2 = _this$props3$componen.resourceHeader,
  10685. ResourceHeaderComponent = _this$props3$componen2 === void 0 ? ResourceHeader : _this$props3$componen2;
  10686. var style = {};
  10687. if (isOverflowing) {
  10688. style[rtl ? 'marginLeft' : 'marginRight'] = scrollbarSize() + "px";
  10689. }
  10690. var groupedEvents = resources.groupEvents(events);
  10691. return React__default.createElement("div", {
  10692. style: style,
  10693. ref: scrollRef,
  10694. className: clsx('rbc-time-header', isOverflowing && 'rbc-overflowing')
  10695. }, React__default.createElement("div", {
  10696. className: "rbc-label rbc-time-header-gutter",
  10697. style: {
  10698. width: width,
  10699. minWidth: width,
  10700. maxWidth: width
  10701. }
  10702. }, TimeGutterHeader && React__default.createElement(TimeGutterHeader, null)), resources.map(function (_ref, idx) {
  10703. var id = _ref[0],
  10704. resource = _ref[1];
  10705. return React__default.createElement("div", {
  10706. className: "rbc-time-header-content",
  10707. key: id || idx
  10708. }, resource && React__default.createElement("div", {
  10709. className: "rbc-row rbc-row-resource",
  10710. key: "resource_" + idx
  10711. }, React__default.createElement("div", {
  10712. className: "rbc-header"
  10713. }, React__default.createElement(ResourceHeaderComponent, {
  10714. index: idx,
  10715. label: accessors.resourceTitle(resource),
  10716. resource: resource
  10717. }))), React__default.createElement("div", {
  10718. className: "rbc-row rbc-time-header-cell" + (range.length <= 1 ? ' rbc-time-header-cell-single-day' : '')
  10719. }, _this3.renderHeaderCells(range)), React__default.createElement(DateContentRow, {
  10720. isAllDay: true,
  10721. rtl: rtl,
  10722. getNow: getNow,
  10723. minRows: 2,
  10724. range: range,
  10725. events: groupedEvents.get(id) || [],
  10726. resourceId: resource && id,
  10727. className: "rbc-allday-cell",
  10728. selectable: selectable,
  10729. selected: _this3.props.selected,
  10730. components: components,
  10731. accessors: accessors,
  10732. getters: getters,
  10733. localizer: localizer,
  10734. onSelect: _this3.props.onSelectEvent,
  10735. onDoubleClick: _this3.props.onDoubleClickEvent,
  10736. onSelectSlot: _this3.props.onSelectSlot,
  10737. longPressThreshold: _this3.props.longPressThreshold
  10738. }));
  10739. }));
  10740. };
  10741. return TimeGridHeader;
  10742. }(React__default.Component);
  10743. TimeGridHeader.propTypes = {
  10744. range: propTypes.array.isRequired,
  10745. events: propTypes.array.isRequired,
  10746. resources: propTypes.object,
  10747. getNow: propTypes.func.isRequired,
  10748. isOverflowing: propTypes.bool,
  10749. rtl: propTypes.bool,
  10750. width: propTypes.number,
  10751. localizer: propTypes.object.isRequired,
  10752. accessors: propTypes.object.isRequired,
  10753. components: propTypes.object.isRequired,
  10754. getters: propTypes.object.isRequired,
  10755. selected: propTypes.object,
  10756. selectable: propTypes.oneOf([true, false, 'ignoreEvents']),
  10757. longPressThreshold: propTypes.number,
  10758. onSelectSlot: propTypes.func,
  10759. onSelectEvent: propTypes.func,
  10760. onDoubleClickEvent: propTypes.func,
  10761. onDrillDown: propTypes.func,
  10762. getDrilldownView: propTypes.func.isRequired,
  10763. scrollRef: propTypes.any
  10764. };
  10765. var NONE = {};
  10766. function Resources(resources, accessors) {
  10767. return {
  10768. map: function map(fn) {
  10769. if (!resources) return [fn([NONE, null], 0)];
  10770. return resources.map(function (resource, idx) {
  10771. return fn([accessors.resourceId(resource), resource], idx);
  10772. });
  10773. },
  10774. groupEvents: function groupEvents(events) {
  10775. var eventsByResource = new Map();
  10776. if (!resources) {
  10777. // Return all events if resources are not provided
  10778. eventsByResource.set(NONE, events);
  10779. return eventsByResource;
  10780. }
  10781. events.forEach(function (event) {
  10782. var id = accessors.resource(event) || NONE;
  10783. var resourceEvents = eventsByResource.get(id) || [];
  10784. resourceEvents.push(event);
  10785. eventsByResource.set(id, resourceEvents);
  10786. });
  10787. return eventsByResource;
  10788. }
  10789. };
  10790. }
  10791. var TimeGrid =
  10792. /*#__PURE__*/
  10793. function (_Component) {
  10794. _inheritsLoose(TimeGrid, _Component);
  10795. function TimeGrid(props) {
  10796. var _this;
  10797. _this = _Component.call(this, props) || this;
  10798. _this.handleScroll = function (e) {
  10799. if (_this.scrollRef.current) {
  10800. _this.scrollRef.current.scrollLeft = e.target.scrollLeft;
  10801. }
  10802. };
  10803. _this.handleResize = function () {
  10804. cancel(_this.rafHandle);
  10805. _this.rafHandle = request(_this.checkOverflow);
  10806. };
  10807. _this.gutterRef = function (ref) {
  10808. _this.gutter = ref && ReactDOM.findDOMNode(ref);
  10809. };
  10810. _this.handleSelectAlldayEvent = function () {
  10811. //cancel any pending selections so only the event click goes through.
  10812. _this.clearSelection();
  10813. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  10814. args[_key] = arguments[_key];
  10815. }
  10816. notify(_this.props.onSelectEvent, args);
  10817. };
  10818. _this.handleSelectAllDaySlot = function (slots, slotInfo) {
  10819. var onSelectSlot = _this.props.onSelectSlot;
  10820. notify(onSelectSlot, {
  10821. slots: slots,
  10822. start: slots[0],
  10823. end: slots[slots.length - 1],
  10824. action: slotInfo.action
  10825. });
  10826. };
  10827. _this.checkOverflow = function () {
  10828. if (_this._updatingOverflow) return;
  10829. var content = _this.contentRef.current;
  10830. var isOverflowing = content.scrollHeight > content.clientHeight;
  10831. if (_this.state.isOverflowing !== isOverflowing) {
  10832. _this._updatingOverflow = true;
  10833. _this.setState({
  10834. isOverflowing: isOverflowing
  10835. }, function () {
  10836. _this._updatingOverflow = false;
  10837. });
  10838. }
  10839. };
  10840. _this.memoizedResources = index(function (resources, accessors) {
  10841. return Resources(resources, accessors);
  10842. });
  10843. _this.state = {
  10844. gutterWidth: undefined,
  10845. isOverflowing: null
  10846. };
  10847. _this.scrollRef = React__default.createRef();
  10848. _this.contentRef = React__default.createRef();
  10849. return _this;
  10850. }
  10851. var _proto = TimeGrid.prototype;
  10852. _proto.componentWillMount = function componentWillMount() {
  10853. this.calculateScroll();
  10854. };
  10855. _proto.componentDidMount = function componentDidMount() {
  10856. this.checkOverflow();
  10857. if (this.props.width == null) {
  10858. this.measureGutter();
  10859. }
  10860. this.applyScroll();
  10861. window.addEventListener('resize', this.handleResize);
  10862. };
  10863. _proto.componentWillUnmount = function componentWillUnmount() {
  10864. window.removeEventListener('resize', this.handleResize);
  10865. cancel(this.rafHandle);
  10866. if (this.measureGutterAnimationFrameRequest) {
  10867. window.cancelAnimationFrame(this.measureGutterAnimationFrameRequest);
  10868. }
  10869. };
  10870. _proto.componentDidUpdate = function componentDidUpdate() {
  10871. if (this.props.width == null) {
  10872. this.measureGutter();
  10873. }
  10874. this.applyScroll(); //this.checkOverflow()
  10875. };
  10876. _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
  10877. var _this$props = this.props,
  10878. range = _this$props.range,
  10879. scrollToTime = _this$props.scrollToTime; // When paginating, reset scroll
  10880. if (!eq(nextProps.range[0], range[0], 'minute') || !eq(nextProps.scrollToTime, scrollToTime, 'minute')) {
  10881. this.calculateScroll(nextProps);
  10882. }
  10883. };
  10884. _proto.renderEvents = function renderEvents(range, events, now) {
  10885. var _this2 = this;
  10886. var _this$props2 = this.props,
  10887. min = _this$props2.min,
  10888. max = _this$props2.max,
  10889. components = _this$props2.components,
  10890. accessors = _this$props2.accessors,
  10891. localizer = _this$props2.localizer;
  10892. var resources = this.memoizedResources(this.props.resources, accessors);
  10893. var groupedEvents = resources.groupEvents(events);
  10894. return resources.map(function (_ref, i) {
  10895. var id = _ref[0],
  10896. resource = _ref[1];
  10897. return range.map(function (date, jj) {
  10898. var daysEvents = (groupedEvents.get(id) || []).filter(function (event) {
  10899. return inRange(date, accessors.start(event), accessors.end(event), 'day');
  10900. });
  10901. return React__default.createElement(DayColumn, _extends({}, _this2.props, {
  10902. localizer: localizer,
  10903. min: merge(date, min),
  10904. max: merge(date, max),
  10905. resource: resource && id,
  10906. components: components,
  10907. isNow: eq(date, now, 'day'),
  10908. key: i + '-' + jj,
  10909. date: date,
  10910. events: daysEvents
  10911. }));
  10912. });
  10913. });
  10914. };
  10915. _proto.render = function render() {
  10916. var _this$props3 = this.props,
  10917. events = _this$props3.events,
  10918. range = _this$props3.range,
  10919. width = _this$props3.width,
  10920. rtl = _this$props3.rtl,
  10921. selected = _this$props3.selected,
  10922. getNow = _this$props3.getNow,
  10923. resources = _this$props3.resources,
  10924. components = _this$props3.components,
  10925. accessors = _this$props3.accessors,
  10926. getters = _this$props3.getters,
  10927. localizer = _this$props3.localizer,
  10928. min = _this$props3.min,
  10929. max = _this$props3.max,
  10930. showMultiDayTimes = _this$props3.showMultiDayTimes,
  10931. longPressThreshold = _this$props3.longPressThreshold;
  10932. width = width || this.state.gutterWidth;
  10933. var start = range[0],
  10934. end = range[range.length - 1];
  10935. this.slots = range.length;
  10936. var allDayEvents = [],
  10937. rangeEvents = [];
  10938. events.forEach(function (event) {
  10939. if (inRange$1(event, start, end, accessors)) {
  10940. var eStart = accessors.start(event),
  10941. eEnd = accessors.end(event);
  10942. if (accessors.allDay(event) || isJustDate(eStart) && isJustDate(eEnd) || !showMultiDayTimes && !eq(eStart, eEnd, 'day')) {
  10943. allDayEvents.push(event);
  10944. } else {
  10945. rangeEvents.push(event);
  10946. }
  10947. }
  10948. });
  10949. allDayEvents.sort(function (a, b) {
  10950. return sortEvents(a, b, accessors);
  10951. });
  10952. return React__default.createElement("div", {
  10953. className: clsx('rbc-time-view', resources && 'rbc-time-view-resources')
  10954. }, React__default.createElement(TimeGridHeader, {
  10955. range: range,
  10956. events: allDayEvents,
  10957. width: width,
  10958. rtl: rtl,
  10959. getNow: getNow,
  10960. localizer: localizer,
  10961. selected: selected,
  10962. resources: this.memoizedResources(resources, accessors),
  10963. selectable: this.props.selectable,
  10964. accessors: accessors,
  10965. getters: getters,
  10966. components: components,
  10967. scrollRef: this.scrollRef,
  10968. isOverflowing: this.state.isOverflowing,
  10969. longPressThreshold: longPressThreshold,
  10970. onSelectSlot: this.handleSelectAllDaySlot,
  10971. onSelectEvent: this.handleSelectAlldayEvent,
  10972. onDoubleClickEvent: this.props.onDoubleClickEvent,
  10973. onDrillDown: this.props.onDrillDown,
  10974. getDrilldownView: this.props.getDrilldownView
  10975. }), React__default.createElement("div", {
  10976. ref: this.contentRef,
  10977. className: "rbc-time-content",
  10978. onScroll: this.handleScroll
  10979. }, React__default.createElement(TimeGutter, {
  10980. date: start,
  10981. ref: this.gutterRef,
  10982. localizer: localizer,
  10983. min: merge(start, min),
  10984. max: merge(start, max),
  10985. step: this.props.step,
  10986. getNow: this.props.getNow,
  10987. timeslots: this.props.timeslots,
  10988. components: components,
  10989. className: "rbc-time-gutter"
  10990. }), this.renderEvents(range, rangeEvents, getNow())));
  10991. };
  10992. _proto.clearSelection = function clearSelection() {
  10993. clearTimeout(this._selectTimer);
  10994. this._pendingSelection = [];
  10995. };
  10996. _proto.measureGutter = function measureGutter() {
  10997. var _this3 = this;
  10998. if (this.measureGutterAnimationFrameRequest) {
  10999. window.cancelAnimationFrame(this.measureGutterAnimationFrameRequest);
  11000. }
  11001. this.measureGutterAnimationFrameRequest = window.requestAnimationFrame(function () {
  11002. var width = getWidth(_this3.gutter);
  11003. if (width && _this3.state.gutterWidth !== width) {
  11004. _this3.setState({
  11005. gutterWidth: width
  11006. });
  11007. }
  11008. });
  11009. };
  11010. _proto.applyScroll = function applyScroll() {
  11011. if (this._scrollRatio) {
  11012. var content = this.contentRef.current;
  11013. content.scrollTop = content.scrollHeight * this._scrollRatio; // Only do this once
  11014. this._scrollRatio = null;
  11015. }
  11016. };
  11017. _proto.calculateScroll = function calculateScroll(props) {
  11018. if (props === void 0) {
  11019. props = this.props;
  11020. }
  11021. var _props = props,
  11022. min = _props.min,
  11023. max = _props.max,
  11024. scrollToTime = _props.scrollToTime;
  11025. var diffMillis = scrollToTime - startOf(scrollToTime, 'day');
  11026. var totalMillis = diff(max, min);
  11027. this._scrollRatio = diffMillis / totalMillis;
  11028. };
  11029. return TimeGrid;
  11030. }(React.Component);
  11031. TimeGrid.propTypes = {
  11032. events: propTypes.array.isRequired,
  11033. resources: propTypes.array,
  11034. step: propTypes.number,
  11035. timeslots: propTypes.number,
  11036. range: propTypes.arrayOf(propTypes.instanceOf(Date)),
  11037. min: propTypes.instanceOf(Date),
  11038. max: propTypes.instanceOf(Date),
  11039. getNow: propTypes.func.isRequired,
  11040. scrollToTime: propTypes.instanceOf(Date),
  11041. showMultiDayTimes: propTypes.bool,
  11042. rtl: propTypes.bool,
  11043. width: propTypes.number,
  11044. accessors: propTypes.object.isRequired,
  11045. components: propTypes.object.isRequired,
  11046. getters: propTypes.object.isRequired,
  11047. localizer: propTypes.object.isRequired,
  11048. selected: propTypes.object,
  11049. selectable: propTypes.oneOf([true, false, 'ignoreEvents']),
  11050. longPressThreshold: propTypes.number,
  11051. onNavigate: propTypes.func,
  11052. onSelectSlot: propTypes.func,
  11053. onSelectEnd: propTypes.func,
  11054. onSelectStart: propTypes.func,
  11055. onSelectEvent: propTypes.func,
  11056. onDoubleClickEvent: propTypes.func,
  11057. onDrillDown: propTypes.func,
  11058. getDrilldownView: propTypes.func.isRequired
  11059. };
  11060. TimeGrid.defaultProps = {
  11061. step: 30,
  11062. timeslots: 2,
  11063. min: startOf(new Date(), 'day'),
  11064. max: endOf(new Date(), 'day'),
  11065. scrollToTime: startOf(new Date(), 'day')
  11066. };
  11067. var Day =
  11068. /*#__PURE__*/
  11069. function (_React$Component) {
  11070. _inheritsLoose(Day, _React$Component);
  11071. function Day() {
  11072. return _React$Component.apply(this, arguments) || this;
  11073. }
  11074. var _proto = Day.prototype;
  11075. _proto.render = function render() {
  11076. var _this$props = this.props,
  11077. date = _this$props.date,
  11078. props = _objectWithoutPropertiesLoose(_this$props, ["date"]);
  11079. var range = Day.range(date);
  11080. return React__default.createElement(TimeGrid, _extends({}, props, {
  11081. range: range,
  11082. eventOffset: 10
  11083. }));
  11084. };
  11085. return Day;
  11086. }(React__default.Component);
  11087. Day.propTypes = {
  11088. date: propTypes.instanceOf(Date).isRequired
  11089. };
  11090. Day.range = function (date) {
  11091. return [startOf(date, 'day')];
  11092. };
  11093. Day.navigate = function (date, action) {
  11094. switch (action) {
  11095. case navigate.PREVIOUS:
  11096. return add(date, -1, 'day');
  11097. case navigate.NEXT:
  11098. return add(date, 1, 'day');
  11099. default:
  11100. return date;
  11101. }
  11102. };
  11103. Day.title = function (date, _ref) {
  11104. var localizer = _ref.localizer;
  11105. return localizer.format(date, 'dayHeaderFormat');
  11106. };
  11107. var Week =
  11108. /*#__PURE__*/
  11109. function (_React$Component) {
  11110. _inheritsLoose(Week, _React$Component);
  11111. function Week() {
  11112. return _React$Component.apply(this, arguments) || this;
  11113. }
  11114. var _proto = Week.prototype;
  11115. _proto.render = function render() {
  11116. var _this$props = this.props,
  11117. date = _this$props.date,
  11118. props = _objectWithoutPropertiesLoose(_this$props, ["date"]);
  11119. var range = Week.range(date, this.props);
  11120. return React__default.createElement(TimeGrid, _extends({}, props, {
  11121. range: range,
  11122. eventOffset: 15
  11123. }));
  11124. };
  11125. return Week;
  11126. }(React__default.Component);
  11127. Week.propTypes = {
  11128. date: propTypes.instanceOf(Date).isRequired
  11129. };
  11130. Week.defaultProps = TimeGrid.defaultProps;
  11131. Week.navigate = function (date, action) {
  11132. switch (action) {
  11133. case navigate.PREVIOUS:
  11134. return add(date, -1, 'week');
  11135. case navigate.NEXT:
  11136. return add(date, 1, 'week');
  11137. default:
  11138. return date;
  11139. }
  11140. };
  11141. Week.range = function (date, _ref) {
  11142. var localizer = _ref.localizer;
  11143. var firstOfWeek = localizer.startOfWeek();
  11144. var start = startOf(date, 'week', firstOfWeek);
  11145. var end = endOf(date, 'week', firstOfWeek);
  11146. return range(start, end);
  11147. };
  11148. Week.title = function (date, _ref2) {
  11149. var localizer = _ref2.localizer;
  11150. var _Week$range = Week.range(date, {
  11151. localizer: localizer
  11152. }),
  11153. start = _Week$range[0],
  11154. rest = _Week$range.slice(1);
  11155. return localizer.format({
  11156. start: start,
  11157. end: rest.pop()
  11158. }, 'dayRangeHeaderFormat');
  11159. };
  11160. function workWeekRange(date, options) {
  11161. return Week.range(date, options).filter(function (d) {
  11162. return [6, 0].indexOf(d.getDay()) === -1;
  11163. });
  11164. }
  11165. var WorkWeek =
  11166. /*#__PURE__*/
  11167. function (_React$Component) {
  11168. _inheritsLoose(WorkWeek, _React$Component);
  11169. function WorkWeek() {
  11170. return _React$Component.apply(this, arguments) || this;
  11171. }
  11172. var _proto = WorkWeek.prototype;
  11173. _proto.render = function render() {
  11174. var _this$props = this.props,
  11175. date = _this$props.date,
  11176. props = _objectWithoutPropertiesLoose(_this$props, ["date"]);
  11177. var range = workWeekRange(date, this.props);
  11178. return React__default.createElement(TimeGrid, _extends({}, props, {
  11179. range: range,
  11180. eventOffset: 15
  11181. }));
  11182. };
  11183. return WorkWeek;
  11184. }(React__default.Component);
  11185. WorkWeek.propTypes = {
  11186. date: propTypes.instanceOf(Date).isRequired
  11187. };
  11188. WorkWeek.defaultProps = TimeGrid.defaultProps;
  11189. WorkWeek.range = workWeekRange;
  11190. WorkWeek.navigate = Week.navigate;
  11191. WorkWeek.title = function (date, _ref) {
  11192. var localizer = _ref.localizer;
  11193. var _workWeekRange = workWeekRange(date, {
  11194. localizer: localizer
  11195. }),
  11196. start = _workWeekRange[0],
  11197. rest = _workWeekRange.slice(1);
  11198. return localizer.format({
  11199. start: start,
  11200. end: rest.pop()
  11201. }, 'dayRangeHeaderFormat');
  11202. };
  11203. function hasClass(element, className) {
  11204. if (element.classList) return !!className && element.classList.contains(className);
  11205. return (" " + (element.className.baseVal || element.className) + " ").indexOf(" " + className + " ") !== -1;
  11206. }
  11207. function addClass(element, className) {
  11208. if (element.classList) element.classList.add(className);else if (!hasClass(element, className)) if (typeof element.className === 'string') element.className = element.className + " " + className;else element.setAttribute('class', (element.className && element.className.baseVal || '') + " " + className);
  11209. }
  11210. function replaceClassName(origClass, classToRemove) {
  11211. return origClass.replace(new RegExp("(^|\\s)" + classToRemove + "(?:\\s|$)", 'g'), '$1').replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, '');
  11212. }
  11213. function removeClass(element, className) {
  11214. if (element.classList) {
  11215. element.classList.remove(className);
  11216. } else if (typeof element.className === 'string') {
  11217. element.className = replaceClassName(element.className, className);
  11218. } else {
  11219. element.setAttribute('class', replaceClassName(element.className && element.className.baseVal || '', className));
  11220. }
  11221. }
  11222. var Agenda =
  11223. /*#__PURE__*/
  11224. function (_React$Component) {
  11225. _inheritsLoose(Agenda, _React$Component);
  11226. function Agenda(props) {
  11227. var _this;
  11228. _this = _React$Component.call(this, props) || this;
  11229. _this.renderDay = function (day, events, dayKey) {
  11230. var _this$props = _this.props,
  11231. selected = _this$props.selected,
  11232. getters = _this$props.getters,
  11233. accessors = _this$props.accessors,
  11234. localizer = _this$props.localizer,
  11235. _this$props$component = _this$props.components,
  11236. Event = _this$props$component.event,
  11237. AgendaDate = _this$props$component.date;
  11238. events = events.filter(function (e) {
  11239. return inRange$1(e, startOf(day, 'day'), endOf(day, 'day'), accessors);
  11240. });
  11241. return events.map(function (event, idx) {
  11242. var title = accessors.title(event);
  11243. var end = accessors.end(event);
  11244. var start = accessors.start(event);
  11245. var userProps = getters.eventProp(event, start, end, isSelected(event, selected));
  11246. var dateLabel = idx === 0 && localizer.format(day, 'agendaDateFormat');
  11247. var first = idx === 0 ? React__default.createElement("td", {
  11248. rowSpan: events.length,
  11249. className: "rbc-agenda-date-cell"
  11250. }, AgendaDate ? React__default.createElement(AgendaDate, {
  11251. day: day,
  11252. label: dateLabel
  11253. }) : dateLabel) : false;
  11254. return React__default.createElement("tr", {
  11255. key: dayKey + '_' + idx,
  11256. className: userProps.className,
  11257. style: userProps.style
  11258. }, first, React__default.createElement("td", {
  11259. className: "rbc-agenda-time-cell"
  11260. }, _this.timeRangeLabel(day, event)), React__default.createElement("td", {
  11261. className: "rbc-agenda-event-cell"
  11262. }, Event ? React__default.createElement(Event, {
  11263. event: event,
  11264. title: title
  11265. }) : title));
  11266. }, []);
  11267. };
  11268. _this.timeRangeLabel = function (day, event) {
  11269. var _this$props2 = _this.props,
  11270. accessors = _this$props2.accessors,
  11271. localizer = _this$props2.localizer,
  11272. components = _this$props2.components;
  11273. var labelClass = '',
  11274. TimeComponent = components.time,
  11275. label = localizer.messages.allDay;
  11276. var end = accessors.end(event);
  11277. var start = accessors.start(event);
  11278. if (!accessors.allDay(event)) {
  11279. if (eq(start, end)) {
  11280. label = localizer.format(start, 'agendaTimeFormat');
  11281. } else if (eq(start, end, 'day')) {
  11282. label = localizer.format({
  11283. start: start,
  11284. end: end
  11285. }, 'agendaTimeRangeFormat');
  11286. } else if (eq(day, start, 'day')) {
  11287. label = localizer.format(start, 'agendaTimeFormat');
  11288. } else if (eq(day, end, 'day')) {
  11289. label = localizer.format(end, 'agendaTimeFormat');
  11290. }
  11291. }
  11292. if (gt(day, start, 'day')) labelClass = 'rbc-continues-prior';
  11293. if (lt(day, end, 'day')) labelClass += ' rbc-continues-after';
  11294. return React__default.createElement("span", {
  11295. className: labelClass.trim()
  11296. }, TimeComponent ? React__default.createElement(TimeComponent, {
  11297. event: event,
  11298. day: day,
  11299. label: label
  11300. }) : label);
  11301. };
  11302. _this._adjustHeader = function () {
  11303. if (!_this.tbodyRef.current) return;
  11304. var header = _this.headerRef.current;
  11305. var firstRow = _this.tbodyRef.current.firstChild;
  11306. if (!firstRow) return;
  11307. var isOverflowing = _this.contentRef.current.scrollHeight > _this.contentRef.current.clientHeight;
  11308. var widths = _this._widths || [];
  11309. _this._widths = [getWidth(firstRow.children[0]), getWidth(firstRow.children[1])];
  11310. if (widths[0] !== _this._widths[0] || widths[1] !== _this._widths[1]) {
  11311. _this.dateColRef.current.style.width = _this._widths[0] + 'px';
  11312. _this.timeColRef.current.style.width = _this._widths[1] + 'px';
  11313. }
  11314. if (isOverflowing) {
  11315. addClass(header, 'rbc-header-overflowing');
  11316. header.style.marginRight = scrollbarSize() + 'px';
  11317. } else {
  11318. removeClass(header, 'rbc-header-overflowing');
  11319. }
  11320. };
  11321. _this.headerRef = React__default.createRef();
  11322. _this.dateColRef = React__default.createRef();
  11323. _this.timeColRef = React__default.createRef();
  11324. _this.contentRef = React__default.createRef();
  11325. _this.tbodyRef = React__default.createRef();
  11326. return _this;
  11327. }
  11328. var _proto = Agenda.prototype;
  11329. _proto.componentDidMount = function componentDidMount() {
  11330. this._adjustHeader();
  11331. };
  11332. _proto.componentDidUpdate = function componentDidUpdate() {
  11333. this._adjustHeader();
  11334. };
  11335. _proto.render = function render() {
  11336. var _this2 = this;
  11337. var _this$props3 = this.props,
  11338. length = _this$props3.length,
  11339. date = _this$props3.date,
  11340. events = _this$props3.events,
  11341. accessors = _this$props3.accessors,
  11342. localizer = _this$props3.localizer;
  11343. var messages = localizer.messages;
  11344. var end = add(date, length, 'day');
  11345. var range$1 = range(date, end, 'day');
  11346. events = events.filter(function (event) {
  11347. return inRange$1(event, date, end, accessors);
  11348. });
  11349. events.sort(function (a, b) {
  11350. return +accessors.start(a) - +accessors.start(b);
  11351. });
  11352. return React__default.createElement("div", {
  11353. className: "rbc-agenda-view"
  11354. }, events.length !== 0 ? React__default.createElement(React__default.Fragment, null, React__default.createElement("table", {
  11355. ref: this.headerRef,
  11356. className: "rbc-agenda-table"
  11357. }, React__default.createElement("thead", null, React__default.createElement("tr", null, React__default.createElement("th", {
  11358. className: "rbc-header",
  11359. ref: this.dateColRef
  11360. }, messages.date), React__default.createElement("th", {
  11361. className: "rbc-header",
  11362. ref: this.timeColRef
  11363. }, messages.time), React__default.createElement("th", {
  11364. className: "rbc-header"
  11365. }, messages.event)))), React__default.createElement("div", {
  11366. className: "rbc-agenda-content",
  11367. ref: this.contentRef
  11368. }, React__default.createElement("table", {
  11369. className: "rbc-agenda-table"
  11370. }, React__default.createElement("tbody", {
  11371. ref: this.tbodyRef
  11372. }, range$1.map(function (day, idx) {
  11373. return _this2.renderDay(day, events, idx);
  11374. }))))) : React__default.createElement("span", {
  11375. className: "rbc-agenda-empty"
  11376. }, messages.noEventsInRange));
  11377. };
  11378. return Agenda;
  11379. }(React__default.Component);
  11380. Agenda.propTypes = {
  11381. events: propTypes.array,
  11382. date: propTypes.instanceOf(Date),
  11383. length: propTypes.number.isRequired,
  11384. selected: propTypes.object,
  11385. accessors: propTypes.object.isRequired,
  11386. components: propTypes.object.isRequired,
  11387. getters: propTypes.object.isRequired,
  11388. localizer: propTypes.object.isRequired
  11389. };
  11390. Agenda.defaultProps = {
  11391. length: 30
  11392. };
  11393. Agenda.range = function (start, _ref) {
  11394. var _ref$length = _ref.length,
  11395. length = _ref$length === void 0 ? Agenda.defaultProps.length : _ref$length;
  11396. var end = add(start, length, 'day');
  11397. return {
  11398. start: start,
  11399. end: end
  11400. };
  11401. };
  11402. Agenda.navigate = function (date, action, _ref2) {
  11403. var _ref2$length = _ref2.length,
  11404. length = _ref2$length === void 0 ? Agenda.defaultProps.length : _ref2$length;
  11405. switch (action) {
  11406. case navigate.PREVIOUS:
  11407. return add(date, -length, 'day');
  11408. case navigate.NEXT:
  11409. return add(date, length, 'day');
  11410. default:
  11411. return date;
  11412. }
  11413. };
  11414. Agenda.title = function (start, _ref3) {
  11415. var _ref3$length = _ref3.length,
  11416. length = _ref3$length === void 0 ? Agenda.defaultProps.length : _ref3$length,
  11417. localizer = _ref3.localizer;
  11418. var end = add(start, length, 'day');
  11419. return localizer.format({
  11420. start: start,
  11421. end: end
  11422. }, 'agendaHeaderFormat');
  11423. };
  11424. var _VIEWS;
  11425. var VIEWS = (_VIEWS = {}, _VIEWS[views.MONTH] = MonthView, _VIEWS[views.WEEK] = Week, _VIEWS[views.WORK_WEEK] = WorkWeek, _VIEWS[views.DAY] = Day, _VIEWS[views.AGENDA] = Agenda, _VIEWS);
  11426. function moveDate(View, _ref) {
  11427. var action = _ref.action,
  11428. date = _ref.date,
  11429. today = _ref.today,
  11430. props = _objectWithoutPropertiesLoose(_ref, ["action", "date", "today"]);
  11431. View = typeof View === 'string' ? VIEWS[View] : View;
  11432. switch (action) {
  11433. case navigate.TODAY:
  11434. date = today || new Date();
  11435. break;
  11436. case navigate.DATE:
  11437. break;
  11438. default:
  11439. !(View && typeof View.navigate === 'function') ? invariant_1(false, 'Calendar View components must implement a static `.navigate(date, action)` method.s') : void 0;
  11440. date = View.navigate(date, action, props);
  11441. }
  11442. return date;
  11443. }
  11444. var Toolbar =
  11445. /*#__PURE__*/
  11446. function (_React$Component) {
  11447. _inheritsLoose(Toolbar, _React$Component);
  11448. function Toolbar() {
  11449. var _this;
  11450. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  11451. args[_key] = arguments[_key];
  11452. }
  11453. _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
  11454. _this.navigate = function (action) {
  11455. _this.props.onNavigate(action);
  11456. };
  11457. _this.view = function (view) {
  11458. _this.props.onView(view);
  11459. };
  11460. return _this;
  11461. }
  11462. var _proto = Toolbar.prototype;
  11463. _proto.render = function render() {
  11464. var _this$props = this.props,
  11465. messages = _this$props.localizer.messages,
  11466. label = _this$props.label;
  11467. return React__default.createElement("div", {
  11468. className: "rbc-toolbar"
  11469. }, React__default.createElement("span", {
  11470. className: "rbc-btn-group"
  11471. }, React__default.createElement("button", {
  11472. type: "button",
  11473. onClick: this.navigate.bind(null, navigate.TODAY)
  11474. }, messages.today), React__default.createElement("button", {
  11475. type: "button",
  11476. onClick: this.navigate.bind(null, navigate.PREVIOUS)
  11477. }, messages.previous), React__default.createElement("button", {
  11478. type: "button",
  11479. onClick: this.navigate.bind(null, navigate.NEXT)
  11480. }, messages.next)), React__default.createElement("span", {
  11481. className: "rbc-toolbar-label"
  11482. }, label), React__default.createElement("span", {
  11483. className: "rbc-btn-group"
  11484. }, this.viewNamesGroup(messages)));
  11485. };
  11486. _proto.viewNamesGroup = function viewNamesGroup(messages) {
  11487. var _this2 = this;
  11488. var viewNames = this.props.views;
  11489. var view = this.props.view;
  11490. if (viewNames.length > 1) {
  11491. return viewNames.map(function (name) {
  11492. return React__default.createElement("button", {
  11493. type: "button",
  11494. key: name,
  11495. className: clsx({
  11496. 'rbc-active': view === name
  11497. }),
  11498. onClick: _this2.view.bind(null, name)
  11499. }, messages[name]);
  11500. });
  11501. }
  11502. };
  11503. return Toolbar;
  11504. }(React__default.Component);
  11505. Toolbar.propTypes = {
  11506. view: propTypes.string.isRequired,
  11507. views: propTypes.arrayOf(propTypes.string).isRequired,
  11508. label: propTypes.node.isRequired,
  11509. localizer: propTypes.object,
  11510. onNavigate: propTypes.func.isRequired,
  11511. onView: propTypes.func.isRequired
  11512. };
  11513. /**
  11514. * A specialized version of `_.forEach` for arrays without support for
  11515. * iteratee shorthands.
  11516. *
  11517. * @private
  11518. * @param {Array} [array] The array to iterate over.
  11519. * @param {Function} iteratee The function invoked per iteration.
  11520. * @returns {Array} Returns `array`.
  11521. */
  11522. function arrayEach(array, iteratee) {
  11523. var index = -1,
  11524. length = array == null ? 0 : array.length;
  11525. while (++index < length) {
  11526. if (iteratee(array[index], index, array) === false) {
  11527. break;
  11528. }
  11529. }
  11530. return array;
  11531. }
  11532. /**
  11533. * The base implementation of `assignValue` and `assignMergeValue` without
  11534. * value checks.
  11535. *
  11536. * @private
  11537. * @param {Object} object The object to modify.
  11538. * @param {string} key The key of the property to assign.
  11539. * @param {*} value The value to assign.
  11540. */
  11541. function baseAssignValue(object, key, value) {
  11542. if (key == '__proto__' && defineProperty$1) {
  11543. defineProperty$1(object, key, {
  11544. 'configurable': true,
  11545. 'enumerable': true,
  11546. 'value': value,
  11547. 'writable': true
  11548. });
  11549. } else {
  11550. object[key] = value;
  11551. }
  11552. }
  11553. /** Used for built-in method references. */
  11554. var objectProto$c = Object.prototype;
  11555. /** Used to check objects for own properties. */
  11556. var hasOwnProperty$a = objectProto$c.hasOwnProperty;
  11557. /**
  11558. * Assigns `value` to `key` of `object` if the existing value is not equivalent
  11559. * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  11560. * for equality comparisons.
  11561. *
  11562. * @private
  11563. * @param {Object} object The object to modify.
  11564. * @param {string} key The key of the property to assign.
  11565. * @param {*} value The value to assign.
  11566. */
  11567. function assignValue(object, key, value) {
  11568. var objValue = object[key];
  11569. if (!(hasOwnProperty$a.call(object, key) && eq$1(objValue, value)) ||
  11570. (value === undefined && !(key in object))) {
  11571. baseAssignValue(object, key, value);
  11572. }
  11573. }
  11574. /**
  11575. * Copies properties of `source` to `object`.
  11576. *
  11577. * @private
  11578. * @param {Object} source The object to copy properties from.
  11579. * @param {Array} props The property identifiers to copy.
  11580. * @param {Object} [object={}] The object to copy properties to.
  11581. * @param {Function} [customizer] The function to customize copied values.
  11582. * @returns {Object} Returns `object`.
  11583. */
  11584. function copyObject(source, props, object, customizer) {
  11585. var isNew = !object;
  11586. object || (object = {});
  11587. var index = -1,
  11588. length = props.length;
  11589. while (++index < length) {
  11590. var key = props[index];
  11591. var newValue = customizer
  11592. ? customizer(object[key], source[key], key, object, source)
  11593. : undefined;
  11594. if (newValue === undefined) {
  11595. newValue = source[key];
  11596. }
  11597. if (isNew) {
  11598. baseAssignValue(object, key, newValue);
  11599. } else {
  11600. assignValue(object, key, newValue);
  11601. }
  11602. }
  11603. return object;
  11604. }
  11605. /**
  11606. * The base implementation of `_.assign` without support for multiple sources
  11607. * or `customizer` functions.
  11608. *
  11609. * @private
  11610. * @param {Object} object The destination object.
  11611. * @param {Object} source The source object.
  11612. * @returns {Object} Returns `object`.
  11613. */
  11614. function baseAssign(object, source) {
  11615. return object && copyObject(source, keys(source), object);
  11616. }
  11617. /**
  11618. * This function is like
  11619. * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
  11620. * except that it includes inherited enumerable properties.
  11621. *
  11622. * @private
  11623. * @param {Object} object The object to query.
  11624. * @returns {Array} Returns the array of property names.
  11625. */
  11626. function nativeKeysIn(object) {
  11627. var result = [];
  11628. if (object != null) {
  11629. for (var key in Object(object)) {
  11630. result.push(key);
  11631. }
  11632. }
  11633. return result;
  11634. }
  11635. /** Used for built-in method references. */
  11636. var objectProto$d = Object.prototype;
  11637. /** Used to check objects for own properties. */
  11638. var hasOwnProperty$b = objectProto$d.hasOwnProperty;
  11639. /**
  11640. * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
  11641. *
  11642. * @private
  11643. * @param {Object} object The object to query.
  11644. * @returns {Array} Returns the array of property names.
  11645. */
  11646. function baseKeysIn(object) {
  11647. if (!isObject(object)) {
  11648. return nativeKeysIn(object);
  11649. }
  11650. var isProto = isPrototype(object),
  11651. result = [];
  11652. for (var key in object) {
  11653. if (!(key == 'constructor' && (isProto || !hasOwnProperty$b.call(object, key)))) {
  11654. result.push(key);
  11655. }
  11656. }
  11657. return result;
  11658. }
  11659. /**
  11660. * Creates an array of the own and inherited enumerable property names of `object`.
  11661. *
  11662. * **Note:** Non-object values are coerced to objects.
  11663. *
  11664. * @static
  11665. * @memberOf _
  11666. * @since 3.0.0
  11667. * @category Object
  11668. * @param {Object} object The object to query.
  11669. * @returns {Array} Returns the array of property names.
  11670. * @example
  11671. *
  11672. * function Foo() {
  11673. * this.a = 1;
  11674. * this.b = 2;
  11675. * }
  11676. *
  11677. * Foo.prototype.c = 3;
  11678. *
  11679. * _.keysIn(new Foo);
  11680. * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
  11681. */
  11682. function keysIn$1(object) {
  11683. return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
  11684. }
  11685. /**
  11686. * The base implementation of `_.assignIn` without support for multiple sources
  11687. * or `customizer` functions.
  11688. *
  11689. * @private
  11690. * @param {Object} object The destination object.
  11691. * @param {Object} source The source object.
  11692. * @returns {Object} Returns `object`.
  11693. */
  11694. function baseAssignIn(object, source) {
  11695. return object && copyObject(source, keysIn$1(source), object);
  11696. }
  11697. /** Detect free variable `exports`. */
  11698. var freeExports$2 = typeof exports == 'object' && exports && !exports.nodeType && exports;
  11699. /** Detect free variable `module`. */
  11700. var freeModule$2 = freeExports$2 && typeof module == 'object' && module && !module.nodeType && module;
  11701. /** Detect the popular CommonJS extension `module.exports`. */
  11702. var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
  11703. /** Built-in value references. */
  11704. var Buffer$1 = moduleExports$2 ? root.Buffer : undefined,
  11705. allocUnsafe = Buffer$1 ? Buffer$1.allocUnsafe : undefined;
  11706. /**
  11707. * Creates a clone of `buffer`.
  11708. *
  11709. * @private
  11710. * @param {Buffer} buffer The buffer to clone.
  11711. * @param {boolean} [isDeep] Specify a deep clone.
  11712. * @returns {Buffer} Returns the cloned buffer.
  11713. */
  11714. function cloneBuffer(buffer, isDeep) {
  11715. if (isDeep) {
  11716. return buffer.slice();
  11717. }
  11718. var length = buffer.length,
  11719. result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
  11720. buffer.copy(result);
  11721. return result;
  11722. }
  11723. /**
  11724. * Copies the values of `source` to `array`.
  11725. *
  11726. * @private
  11727. * @param {Array} source The array to copy values from.
  11728. * @param {Array} [array=[]] The array to copy values to.
  11729. * @returns {Array} Returns `array`.
  11730. */
  11731. function copyArray(source, array) {
  11732. var index = -1,
  11733. length = source.length;
  11734. array || (array = Array(length));
  11735. while (++index < length) {
  11736. array[index] = source[index];
  11737. }
  11738. return array;
  11739. }
  11740. /**
  11741. * Copies own symbols of `source` to `object`.
  11742. *
  11743. * @private
  11744. * @param {Object} source The object to copy symbols from.
  11745. * @param {Object} [object={}] The object to copy symbols to.
  11746. * @returns {Object} Returns `object`.
  11747. */
  11748. function copySymbols(source, object) {
  11749. return copyObject(source, getSymbols(source), object);
  11750. }
  11751. /** Built-in value references. */
  11752. var getPrototype = overArg(Object.getPrototypeOf, Object);
  11753. /* Built-in method references for those with the same name as other `lodash` methods. */
  11754. var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
  11755. /**
  11756. * Creates an array of the own and inherited enumerable symbols of `object`.
  11757. *
  11758. * @private
  11759. * @param {Object} object The object to query.
  11760. * @returns {Array} Returns the array of symbols.
  11761. */
  11762. var getSymbolsIn = !nativeGetSymbols$1 ? stubArray : function(object) {
  11763. var result = [];
  11764. while (object) {
  11765. arrayPush(result, getSymbols(object));
  11766. object = getPrototype(object);
  11767. }
  11768. return result;
  11769. };
  11770. /**
  11771. * Copies own and inherited symbols of `source` to `object`.
  11772. *
  11773. * @private
  11774. * @param {Object} source The object to copy symbols from.
  11775. * @param {Object} [object={}] The object to copy symbols to.
  11776. * @returns {Object} Returns `object`.
  11777. */
  11778. function copySymbolsIn(source, object) {
  11779. return copyObject(source, getSymbolsIn(source), object);
  11780. }
  11781. /**
  11782. * Creates an array of own and inherited enumerable property names and
  11783. * symbols of `object`.
  11784. *
  11785. * @private
  11786. * @param {Object} object The object to query.
  11787. * @returns {Array} Returns the array of property names and symbols.
  11788. */
  11789. function getAllKeysIn(object) {
  11790. return baseGetAllKeys(object, keysIn$1, getSymbolsIn);
  11791. }
  11792. /** Used for built-in method references. */
  11793. var objectProto$e = Object.prototype;
  11794. /** Used to check objects for own properties. */
  11795. var hasOwnProperty$c = objectProto$e.hasOwnProperty;
  11796. /**
  11797. * Initializes an array clone.
  11798. *
  11799. * @private
  11800. * @param {Array} array The array to clone.
  11801. * @returns {Array} Returns the initialized clone.
  11802. */
  11803. function initCloneArray(array) {
  11804. var length = array.length,
  11805. result = new array.constructor(length);
  11806. // Add properties assigned by `RegExp#exec`.
  11807. if (length && typeof array[0] == 'string' && hasOwnProperty$c.call(array, 'index')) {
  11808. result.index = array.index;
  11809. result.input = array.input;
  11810. }
  11811. return result;
  11812. }
  11813. /**
  11814. * Creates a clone of `arrayBuffer`.
  11815. *
  11816. * @private
  11817. * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
  11818. * @returns {ArrayBuffer} Returns the cloned array buffer.
  11819. */
  11820. function cloneArrayBuffer(arrayBuffer) {
  11821. var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
  11822. new Uint8Array(result).set(new Uint8Array(arrayBuffer));
  11823. return result;
  11824. }
  11825. /**
  11826. * Creates a clone of `dataView`.
  11827. *
  11828. * @private
  11829. * @param {Object} dataView The data view to clone.
  11830. * @param {boolean} [isDeep] Specify a deep clone.
  11831. * @returns {Object} Returns the cloned data view.
  11832. */
  11833. function cloneDataView(dataView, isDeep) {
  11834. var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
  11835. return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
  11836. }
  11837. /** Used to match `RegExp` flags from their coerced string values. */
  11838. var reFlags = /\w*$/;
  11839. /**
  11840. * Creates a clone of `regexp`.
  11841. *
  11842. * @private
  11843. * @param {Object} regexp The regexp to clone.
  11844. * @returns {Object} Returns the cloned regexp.
  11845. */
  11846. function cloneRegExp(regexp) {
  11847. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  11848. result.lastIndex = regexp.lastIndex;
  11849. return result;
  11850. }
  11851. /** Used to convert symbols to primitives and strings. */
  11852. var symbolProto$2 = Symbol$1 ? Symbol$1.prototype : undefined,
  11853. symbolValueOf$1 = symbolProto$2 ? symbolProto$2.valueOf : undefined;
  11854. /**
  11855. * Creates a clone of the `symbol` object.
  11856. *
  11857. * @private
  11858. * @param {Object} symbol The symbol object to clone.
  11859. * @returns {Object} Returns the cloned symbol object.
  11860. */
  11861. function cloneSymbol(symbol) {
  11862. return symbolValueOf$1 ? Object(symbolValueOf$1.call(symbol)) : {};
  11863. }
  11864. /**
  11865. * Creates a clone of `typedArray`.
  11866. *
  11867. * @private
  11868. * @param {Object} typedArray The typed array to clone.
  11869. * @param {boolean} [isDeep] Specify a deep clone.
  11870. * @returns {Object} Returns the cloned typed array.
  11871. */
  11872. function cloneTypedArray(typedArray, isDeep) {
  11873. var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
  11874. return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
  11875. }
  11876. /** `Object#toString` result references. */
  11877. var boolTag$2 = '[object Boolean]',
  11878. dateTag$2 = '[object Date]',
  11879. mapTag$3 = '[object Map]',
  11880. numberTag$2 = '[object Number]',
  11881. regexpTag$2 = '[object RegExp]',
  11882. setTag$3 = '[object Set]',
  11883. stringTag$2 = '[object String]',
  11884. symbolTag$2 = '[object Symbol]';
  11885. var arrayBufferTag$2 = '[object ArrayBuffer]',
  11886. dataViewTag$3 = '[object DataView]',
  11887. float32Tag$1 = '[object Float32Array]',
  11888. float64Tag$1 = '[object Float64Array]',
  11889. int8Tag$1 = '[object Int8Array]',
  11890. int16Tag$1 = '[object Int16Array]',
  11891. int32Tag$1 = '[object Int32Array]',
  11892. uint8Tag$1 = '[object Uint8Array]',
  11893. uint8ClampedTag$1 = '[object Uint8ClampedArray]',
  11894. uint16Tag$1 = '[object Uint16Array]',
  11895. uint32Tag$1 = '[object Uint32Array]';
  11896. /**
  11897. * Initializes an object clone based on its `toStringTag`.
  11898. *
  11899. * **Note:** This function only supports cloning values with tags of
  11900. * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
  11901. *
  11902. * @private
  11903. * @param {Object} object The object to clone.
  11904. * @param {string} tag The `toStringTag` of the object to clone.
  11905. * @param {boolean} [isDeep] Specify a deep clone.
  11906. * @returns {Object} Returns the initialized clone.
  11907. */
  11908. function initCloneByTag(object, tag, isDeep) {
  11909. var Ctor = object.constructor;
  11910. switch (tag) {
  11911. case arrayBufferTag$2:
  11912. return cloneArrayBuffer(object);
  11913. case boolTag$2:
  11914. case dateTag$2:
  11915. return new Ctor(+object);
  11916. case dataViewTag$3:
  11917. return cloneDataView(object, isDeep);
  11918. case float32Tag$1: case float64Tag$1:
  11919. case int8Tag$1: case int16Tag$1: case int32Tag$1:
  11920. case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
  11921. return cloneTypedArray(object, isDeep);
  11922. case mapTag$3:
  11923. return new Ctor;
  11924. case numberTag$2:
  11925. case stringTag$2:
  11926. return new Ctor(object);
  11927. case regexpTag$2:
  11928. return cloneRegExp(object);
  11929. case setTag$3:
  11930. return new Ctor;
  11931. case symbolTag$2:
  11932. return cloneSymbol(object);
  11933. }
  11934. }
  11935. /** Built-in value references. */
  11936. var objectCreate = Object.create;
  11937. /**
  11938. * The base implementation of `_.create` without support for assigning
  11939. * properties to the created object.
  11940. *
  11941. * @private
  11942. * @param {Object} proto The object to inherit from.
  11943. * @returns {Object} Returns the new object.
  11944. */
  11945. var baseCreate = (function() {
  11946. function object() {}
  11947. return function(proto) {
  11948. if (!isObject(proto)) {
  11949. return {};
  11950. }
  11951. if (objectCreate) {
  11952. return objectCreate(proto);
  11953. }
  11954. object.prototype = proto;
  11955. var result = new object;
  11956. object.prototype = undefined;
  11957. return result;
  11958. };
  11959. }());
  11960. /**
  11961. * Initializes an object clone.
  11962. *
  11963. * @private
  11964. * @param {Object} object The object to clone.
  11965. * @returns {Object} Returns the initialized clone.
  11966. */
  11967. function initCloneObject(object) {
  11968. return (typeof object.constructor == 'function' && !isPrototype(object))
  11969. ? baseCreate(getPrototype(object))
  11970. : {};
  11971. }
  11972. /** `Object#toString` result references. */
  11973. var mapTag$4 = '[object Map]';
  11974. /**
  11975. * The base implementation of `_.isMap` without Node.js optimizations.
  11976. *
  11977. * @private
  11978. * @param {*} value The value to check.
  11979. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  11980. */
  11981. function baseIsMap(value) {
  11982. return isObjectLike(value) && getTag$1(value) == mapTag$4;
  11983. }
  11984. /* Node.js helper references. */
  11985. var nodeIsMap = nodeUtil && nodeUtil.isMap;
  11986. /**
  11987. * Checks if `value` is classified as a `Map` object.
  11988. *
  11989. * @static
  11990. * @memberOf _
  11991. * @since 4.3.0
  11992. * @category Lang
  11993. * @param {*} value The value to check.
  11994. * @returns {boolean} Returns `true` if `value` is a map, else `false`.
  11995. * @example
  11996. *
  11997. * _.isMap(new Map);
  11998. * // => true
  11999. *
  12000. * _.isMap(new WeakMap);
  12001. * // => false
  12002. */
  12003. var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
  12004. /** `Object#toString` result references. */
  12005. var setTag$4 = '[object Set]';
  12006. /**
  12007. * The base implementation of `_.isSet` without Node.js optimizations.
  12008. *
  12009. * @private
  12010. * @param {*} value The value to check.
  12011. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  12012. */
  12013. function baseIsSet(value) {
  12014. return isObjectLike(value) && getTag$1(value) == setTag$4;
  12015. }
  12016. /* Node.js helper references. */
  12017. var nodeIsSet = nodeUtil && nodeUtil.isSet;
  12018. /**
  12019. * Checks if `value` is classified as a `Set` object.
  12020. *
  12021. * @static
  12022. * @memberOf _
  12023. * @since 4.3.0
  12024. * @category Lang
  12025. * @param {*} value The value to check.
  12026. * @returns {boolean} Returns `true` if `value` is a set, else `false`.
  12027. * @example
  12028. *
  12029. * _.isSet(new Set);
  12030. * // => true
  12031. *
  12032. * _.isSet(new WeakSet);
  12033. * // => false
  12034. */
  12035. var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
  12036. /** Used to compose bitmasks for cloning. */
  12037. var CLONE_DEEP_FLAG = 1,
  12038. CLONE_FLAT_FLAG = 2,
  12039. CLONE_SYMBOLS_FLAG = 4;
  12040. /** `Object#toString` result references. */
  12041. var argsTag$3 = '[object Arguments]',
  12042. arrayTag$2 = '[object Array]',
  12043. boolTag$3 = '[object Boolean]',
  12044. dateTag$3 = '[object Date]',
  12045. errorTag$2 = '[object Error]',
  12046. funcTag$2 = '[object Function]',
  12047. genTag$1 = '[object GeneratorFunction]',
  12048. mapTag$5 = '[object Map]',
  12049. numberTag$3 = '[object Number]',
  12050. objectTag$3 = '[object Object]',
  12051. regexpTag$3 = '[object RegExp]',
  12052. setTag$5 = '[object Set]',
  12053. stringTag$3 = '[object String]',
  12054. symbolTag$3 = '[object Symbol]',
  12055. weakMapTag$2 = '[object WeakMap]';
  12056. var arrayBufferTag$3 = '[object ArrayBuffer]',
  12057. dataViewTag$4 = '[object DataView]',
  12058. float32Tag$2 = '[object Float32Array]',
  12059. float64Tag$2 = '[object Float64Array]',
  12060. int8Tag$2 = '[object Int8Array]',
  12061. int16Tag$2 = '[object Int16Array]',
  12062. int32Tag$2 = '[object Int32Array]',
  12063. uint8Tag$2 = '[object Uint8Array]',
  12064. uint8ClampedTag$2 = '[object Uint8ClampedArray]',
  12065. uint16Tag$2 = '[object Uint16Array]',
  12066. uint32Tag$2 = '[object Uint32Array]';
  12067. /** Used to identify `toStringTag` values supported by `_.clone`. */
  12068. var cloneableTags = {};
  12069. cloneableTags[argsTag$3] = cloneableTags[arrayTag$2] =
  12070. cloneableTags[arrayBufferTag$3] = cloneableTags[dataViewTag$4] =
  12071. cloneableTags[boolTag$3] = cloneableTags[dateTag$3] =
  12072. cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
  12073. cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
  12074. cloneableTags[int32Tag$2] = cloneableTags[mapTag$5] =
  12075. cloneableTags[numberTag$3] = cloneableTags[objectTag$3] =
  12076. cloneableTags[regexpTag$3] = cloneableTags[setTag$5] =
  12077. cloneableTags[stringTag$3] = cloneableTags[symbolTag$3] =
  12078. cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
  12079. cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
  12080. cloneableTags[errorTag$2] = cloneableTags[funcTag$2] =
  12081. cloneableTags[weakMapTag$2] = false;
  12082. /**
  12083. * The base implementation of `_.clone` and `_.cloneDeep` which tracks
  12084. * traversed objects.
  12085. *
  12086. * @private
  12087. * @param {*} value The value to clone.
  12088. * @param {boolean} bitmask The bitmask flags.
  12089. * 1 - Deep clone
  12090. * 2 - Flatten inherited properties
  12091. * 4 - Clone symbols
  12092. * @param {Function} [customizer] The function to customize cloning.
  12093. * @param {string} [key] The key of `value`.
  12094. * @param {Object} [object] The parent object of `value`.
  12095. * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
  12096. * @returns {*} Returns the cloned value.
  12097. */
  12098. function baseClone(value, bitmask, customizer, key, object, stack) {
  12099. var result,
  12100. isDeep = bitmask & CLONE_DEEP_FLAG,
  12101. isFlat = bitmask & CLONE_FLAT_FLAG,
  12102. isFull = bitmask & CLONE_SYMBOLS_FLAG;
  12103. if (customizer) {
  12104. result = object ? customizer(value, key, object, stack) : customizer(value);
  12105. }
  12106. if (result !== undefined) {
  12107. return result;
  12108. }
  12109. if (!isObject(value)) {
  12110. return value;
  12111. }
  12112. var isArr = isArray(value);
  12113. if (isArr) {
  12114. result = initCloneArray(value);
  12115. if (!isDeep) {
  12116. return copyArray(value, result);
  12117. }
  12118. } else {
  12119. var tag = getTag$1(value),
  12120. isFunc = tag == funcTag$2 || tag == genTag$1;
  12121. if (isBuffer(value)) {
  12122. return cloneBuffer(value, isDeep);
  12123. }
  12124. if (tag == objectTag$3 || tag == argsTag$3 || (isFunc && !object)) {
  12125. result = (isFlat || isFunc) ? {} : initCloneObject(value);
  12126. if (!isDeep) {
  12127. return isFlat
  12128. ? copySymbolsIn(value, baseAssignIn(result, value))
  12129. : copySymbols(value, baseAssign(result, value));
  12130. }
  12131. } else {
  12132. if (!cloneableTags[tag]) {
  12133. return object ? value : {};
  12134. }
  12135. result = initCloneByTag(value, tag, isDeep);
  12136. }
  12137. }
  12138. // Check for circular references and return its corresponding clone.
  12139. stack || (stack = new Stack);
  12140. var stacked = stack.get(value);
  12141. if (stacked) {
  12142. return stacked;
  12143. }
  12144. stack.set(value, result);
  12145. if (isSet(value)) {
  12146. value.forEach(function(subValue) {
  12147. result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
  12148. });
  12149. return result;
  12150. }
  12151. if (isMap(value)) {
  12152. value.forEach(function(subValue, key) {
  12153. result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
  12154. });
  12155. return result;
  12156. }
  12157. var keysFunc = isFull
  12158. ? (isFlat ? getAllKeysIn : getAllKeys)
  12159. : (isFlat ? keysIn : keys);
  12160. var props = isArr ? undefined : keysFunc(value);
  12161. arrayEach(props || value, function(subValue, key) {
  12162. if (props) {
  12163. key = subValue;
  12164. subValue = value[key];
  12165. }
  12166. // Recursively populate clone (susceptible to call stack limits).
  12167. assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
  12168. });
  12169. return result;
  12170. }
  12171. /**
  12172. * Gets the last element of `array`.
  12173. *
  12174. * @static
  12175. * @memberOf _
  12176. * @since 0.1.0
  12177. * @category Array
  12178. * @param {Array} array The array to query.
  12179. * @returns {*} Returns the last element of `array`.
  12180. * @example
  12181. *
  12182. * _.last([1, 2, 3]);
  12183. * // => 3
  12184. */
  12185. function last(array) {
  12186. var length = array == null ? 0 : array.length;
  12187. return length ? array[length - 1] : undefined;
  12188. }
  12189. /**
  12190. * Gets the parent value at `path` of `object`.
  12191. *
  12192. * @private
  12193. * @param {Object} object The object to query.
  12194. * @param {Array} path The path to get the parent value of.
  12195. * @returns {*} Returns the parent value.
  12196. */
  12197. function parent(object, path) {
  12198. return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
  12199. }
  12200. /**
  12201. * The base implementation of `_.unset`.
  12202. *
  12203. * @private
  12204. * @param {Object} object The object to modify.
  12205. * @param {Array|string} path The property path to unset.
  12206. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
  12207. */
  12208. function baseUnset(object, path) {
  12209. path = castPath(path, object);
  12210. object = parent(object, path);
  12211. return object == null || delete object[toKey(last(path))];
  12212. }
  12213. /** `Object#toString` result references. */
  12214. var objectTag$4 = '[object Object]';
  12215. /** Used for built-in method references. */
  12216. var funcProto$2 = Function.prototype,
  12217. objectProto$f = Object.prototype;
  12218. /** Used to resolve the decompiled source of functions. */
  12219. var funcToString$2 = funcProto$2.toString;
  12220. /** Used to check objects for own properties. */
  12221. var hasOwnProperty$d = objectProto$f.hasOwnProperty;
  12222. /** Used to infer the `Object` constructor. */
  12223. var objectCtorString = funcToString$2.call(Object);
  12224. /**
  12225. * Checks if `value` is a plain object, that is, an object created by the
  12226. * `Object` constructor or one with a `[[Prototype]]` of `null`.
  12227. *
  12228. * @static
  12229. * @memberOf _
  12230. * @since 0.8.0
  12231. * @category Lang
  12232. * @param {*} value The value to check.
  12233. * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
  12234. * @example
  12235. *
  12236. * function Foo() {
  12237. * this.a = 1;
  12238. * }
  12239. *
  12240. * _.isPlainObject(new Foo);
  12241. * // => false
  12242. *
  12243. * _.isPlainObject([1, 2, 3]);
  12244. * // => false
  12245. *
  12246. * _.isPlainObject({ 'x': 0, 'y': 0 });
  12247. * // => true
  12248. *
  12249. * _.isPlainObject(Object.create(null));
  12250. * // => true
  12251. */
  12252. function isPlainObject(value) {
  12253. if (!isObjectLike(value) || baseGetTag(value) != objectTag$4) {
  12254. return false;
  12255. }
  12256. var proto = getPrototype(value);
  12257. if (proto === null) {
  12258. return true;
  12259. }
  12260. var Ctor = hasOwnProperty$d.call(proto, 'constructor') && proto.constructor;
  12261. return typeof Ctor == 'function' && Ctor instanceof Ctor &&
  12262. funcToString$2.call(Ctor) == objectCtorString;
  12263. }
  12264. /**
  12265. * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
  12266. * objects.
  12267. *
  12268. * @private
  12269. * @param {*} value The value to inspect.
  12270. * @param {string} key The key of the property to inspect.
  12271. * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
  12272. */
  12273. function customOmitClone(value) {
  12274. return isPlainObject(value) ? undefined : value;
  12275. }
  12276. /**
  12277. * Flattens `array` a single level deep.
  12278. *
  12279. * @static
  12280. * @memberOf _
  12281. * @since 0.1.0
  12282. * @category Array
  12283. * @param {Array} array The array to flatten.
  12284. * @returns {Array} Returns the new flattened array.
  12285. * @example
  12286. *
  12287. * _.flatten([1, [2, [3, [4]], 5]]);
  12288. * // => [1, 2, [3, [4]], 5]
  12289. */
  12290. function flatten(array) {
  12291. var length = array == null ? 0 : array.length;
  12292. return length ? baseFlatten(array, 1) : [];
  12293. }
  12294. /**
  12295. * A specialized version of `baseRest` which flattens the rest array.
  12296. *
  12297. * @private
  12298. * @param {Function} func The function to apply a rest parameter to.
  12299. * @returns {Function} Returns the new function.
  12300. */
  12301. function flatRest(func) {
  12302. return setToString(overRest(func, undefined, flatten), func + '');
  12303. }
  12304. /** Used to compose bitmasks for cloning. */
  12305. var CLONE_DEEP_FLAG$1 = 1,
  12306. CLONE_FLAT_FLAG$1 = 2,
  12307. CLONE_SYMBOLS_FLAG$1 = 4;
  12308. /**
  12309. * The opposite of `_.pick`; this method creates an object composed of the
  12310. * own and inherited enumerable property paths of `object` that are not omitted.
  12311. *
  12312. * **Note:** This method is considerably slower than `_.pick`.
  12313. *
  12314. * @static
  12315. * @since 0.1.0
  12316. * @memberOf _
  12317. * @category Object
  12318. * @param {Object} object The source object.
  12319. * @param {...(string|string[])} [paths] The property paths to omit.
  12320. * @returns {Object} Returns the new object.
  12321. * @example
  12322. *
  12323. * var object = { 'a': 1, 'b': '2', 'c': 3 };
  12324. *
  12325. * _.omit(object, ['a', 'c']);
  12326. * // => { 'b': '2' }
  12327. */
  12328. var omit = flatRest(function(object, paths) {
  12329. var result = {};
  12330. if (object == null) {
  12331. return result;
  12332. }
  12333. var isDeep = false;
  12334. paths = arrayMap(paths, function(path) {
  12335. path = castPath(path, object);
  12336. isDeep || (isDeep = path.length > 1);
  12337. return path;
  12338. });
  12339. copyObject(object, getAllKeysIn(object), result);
  12340. if (isDeep) {
  12341. result = baseClone(result, CLONE_DEEP_FLAG$1 | CLONE_FLAT_FLAG$1 | CLONE_SYMBOLS_FLAG$1, customOmitClone);
  12342. }
  12343. var length = paths.length;
  12344. while (length--) {
  12345. baseUnset(result, paths[length]);
  12346. }
  12347. return result;
  12348. });
  12349. /** Used for built-in method references. */
  12350. var objectProto$g = Object.prototype;
  12351. /** Used to check objects for own properties. */
  12352. var hasOwnProperty$e = objectProto$g.hasOwnProperty;
  12353. /**
  12354. * Assigns own and inherited enumerable string keyed properties of source
  12355. * objects to the destination object for all destination properties that
  12356. * resolve to `undefined`. Source objects are applied from left to right.
  12357. * Once a property is set, additional values of the same property are ignored.
  12358. *
  12359. * **Note:** This method mutates `object`.
  12360. *
  12361. * @static
  12362. * @since 0.1.0
  12363. * @memberOf _
  12364. * @category Object
  12365. * @param {Object} object The destination object.
  12366. * @param {...Object} [sources] The source objects.
  12367. * @returns {Object} Returns `object`.
  12368. * @see _.defaultsDeep
  12369. * @example
  12370. *
  12371. * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
  12372. * // => { 'a': 1, 'b': 2 }
  12373. */
  12374. var defaults = baseRest(function(object, sources) {
  12375. object = Object(object);
  12376. var index = -1;
  12377. var length = sources.length;
  12378. var guard = length > 2 ? sources[2] : undefined;
  12379. if (guard && isIterateeCall(sources[0], sources[1], guard)) {
  12380. length = 1;
  12381. }
  12382. while (++index < length) {
  12383. var source = sources[index];
  12384. var props = keysIn$1(source);
  12385. var propsIndex = -1;
  12386. var propsLength = props.length;
  12387. while (++propsIndex < propsLength) {
  12388. var key = props[propsIndex];
  12389. var value = object[key];
  12390. if (value === undefined ||
  12391. (eq$1(value, objectProto$g[key]) && !hasOwnProperty$e.call(object, key))) {
  12392. object[key] = source[key];
  12393. }
  12394. }
  12395. }
  12396. return object;
  12397. });
  12398. /**
  12399. * An alternative to `_.reduce`; this method transforms `object` to a new
  12400. * `accumulator` object which is the result of running each of its own
  12401. * enumerable string keyed properties thru `iteratee`, with each invocation
  12402. * potentially mutating the `accumulator` object. If `accumulator` is not
  12403. * provided, a new object with the same `[[Prototype]]` will be used. The
  12404. * iteratee is invoked with four arguments: (accumulator, value, key, object).
  12405. * Iteratee functions may exit iteration early by explicitly returning `false`.
  12406. *
  12407. * @static
  12408. * @memberOf _
  12409. * @since 1.3.0
  12410. * @category Object
  12411. * @param {Object} object The object to iterate over.
  12412. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  12413. * @param {*} [accumulator] The custom accumulator value.
  12414. * @returns {*} Returns the accumulated value.
  12415. * @example
  12416. *
  12417. * _.transform([2, 3, 4], function(result, n) {
  12418. * result.push(n *= n);
  12419. * return n % 2 == 0;
  12420. * }, []);
  12421. * // => [4, 9]
  12422. *
  12423. * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
  12424. * (result[value] || (result[value] = [])).push(key);
  12425. * }, {});
  12426. * // => { '1': ['a', 'c'], '2': ['b'] }
  12427. */
  12428. function transform(object, iteratee, accumulator) {
  12429. var isArr = isArray(object),
  12430. isArrLike = isArr || isBuffer(object) || isTypedArray(object);
  12431. iteratee = baseIteratee(iteratee, 4);
  12432. if (accumulator == null) {
  12433. var Ctor = object && object.constructor;
  12434. if (isArrLike) {
  12435. accumulator = isArr ? new Ctor : [];
  12436. }
  12437. else if (isObject(object)) {
  12438. accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
  12439. }
  12440. else {
  12441. accumulator = {};
  12442. }
  12443. }
  12444. (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
  12445. return iteratee(accumulator, value, index, object);
  12446. });
  12447. return accumulator;
  12448. }
  12449. /**
  12450. * Creates an object with the same keys as `object` and values generated
  12451. * by running each own enumerable string keyed property of `object` thru
  12452. * `iteratee`. The iteratee is invoked with three arguments:
  12453. * (value, key, object).
  12454. *
  12455. * @static
  12456. * @memberOf _
  12457. * @since 2.4.0
  12458. * @category Object
  12459. * @param {Object} object The object to iterate over.
  12460. * @param {Function} [iteratee=_.identity] The function invoked per iteration.
  12461. * @returns {Object} Returns the new mapped object.
  12462. * @see _.mapKeys
  12463. * @example
  12464. *
  12465. * var users = {
  12466. * 'fred': { 'user': 'fred', 'age': 40 },
  12467. * 'pebbles': { 'user': 'pebbles', 'age': 1 }
  12468. * };
  12469. *
  12470. * _.mapValues(users, function(o) { return o.age; });
  12471. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  12472. *
  12473. * // The `_.property` iteratee shorthand.
  12474. * _.mapValues(users, 'age');
  12475. * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
  12476. */
  12477. function mapValues(object, iteratee) {
  12478. var result = {};
  12479. iteratee = baseIteratee(iteratee, 3);
  12480. baseForOwn(object, function(value, key, object) {
  12481. baseAssignValue(result, key, iteratee(value, key, object));
  12482. });
  12483. return result;
  12484. }
  12485. /**
  12486. * Retrieve via an accessor-like property
  12487. *
  12488. * accessor(obj, 'name') // => retrieves obj['name']
  12489. * accessor(data, func) // => retrieves func(data)
  12490. * ... otherwise null
  12491. */
  12492. function accessor$1(data, field) {
  12493. var value = null;
  12494. if (typeof field === 'function') value = field(data);else if (typeof field === 'string' && typeof data === 'object' && data != null && field in data) value = data[field];
  12495. return value;
  12496. }
  12497. var wrapAccessor = function wrapAccessor(acc) {
  12498. return function (data) {
  12499. return accessor$1(data, acc);
  12500. };
  12501. };
  12502. function viewNames$1(_views) {
  12503. return !Array.isArray(_views) ? Object.keys(_views) : _views;
  12504. }
  12505. function isValidView(view, _ref) {
  12506. var _views = _ref.views;
  12507. var names = viewNames$1(_views);
  12508. return names.indexOf(view) !== -1;
  12509. }
  12510. /**
  12511. * react-big-calendar is a full featured Calendar component for managing events and dates. It uses
  12512. * modern `flexbox` for layout, making it super responsive and performant. Leaving most of the layout heavy lifting
  12513. * to the browser. __note:__ The default styles use `height: 100%` which means your container must set an explicit
  12514. * height (feel free to adjust the styles to suit your specific needs).
  12515. *
  12516. * Big Calendar is unopiniated about editing and moving events, preferring to let you implement it in a way that makes
  12517. * the most sense to your app. It also tries not to be prescriptive about your event data structures, just tell it
  12518. * how to find the start and end datetimes and you can pass it whatever you want.
  12519. *
  12520. * One thing to note is that, `react-big-calendar` treats event start/end dates as an _exclusive_ range.
  12521. * which means that the event spans up to, but not including, the end date. In the case
  12522. * of displaying events on whole days, end dates are rounded _up_ to the next day. So an
  12523. * event ending on `Apr 8th 12:00:00 am` will not appear on the 8th, whereas one ending
  12524. * on `Apr 8th 12:01:00 am` will. If you want _inclusive_ ranges consider providing a
  12525. * function `endAccessor` that returns the end date + 1 day for those events that end at midnight.
  12526. */
  12527. var Calendar =
  12528. /*#__PURE__*/
  12529. function (_React$Component) {
  12530. _inheritsLoose(Calendar, _React$Component);
  12531. function Calendar() {
  12532. var _this;
  12533. for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
  12534. _args[_key] = arguments[_key];
  12535. }
  12536. _this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;
  12537. _this.getViews = function () {
  12538. var views = _this.props.views;
  12539. if (Array.isArray(views)) {
  12540. return transform(views, function (obj, name) {
  12541. return obj[name] = VIEWS[name];
  12542. }, {});
  12543. }
  12544. if (typeof views === 'object') {
  12545. return mapValues(views, function (value, key) {
  12546. if (value === true) {
  12547. return VIEWS[key];
  12548. }
  12549. return value;
  12550. });
  12551. }
  12552. return VIEWS;
  12553. };
  12554. _this.getView = function () {
  12555. var views = _this.getViews();
  12556. return views[_this.props.view];
  12557. };
  12558. _this.getDrilldownView = function (date) {
  12559. var _this$props = _this.props,
  12560. view = _this$props.view,
  12561. drilldownView = _this$props.drilldownView,
  12562. getDrilldownView = _this$props.getDrilldownView;
  12563. if (!getDrilldownView) return drilldownView;
  12564. return getDrilldownView(date, view, Object.keys(_this.getViews()));
  12565. };
  12566. _this.handleRangeChange = function (date, viewComponent, view) {
  12567. var _this$props2 = _this.props,
  12568. onRangeChange = _this$props2.onRangeChange,
  12569. localizer = _this$props2.localizer;
  12570. if (onRangeChange) {
  12571. if (viewComponent.range) {
  12572. onRangeChange(viewComponent.range(date, {
  12573. localizer: localizer
  12574. }), view);
  12575. } else {
  12576. warning_1(true, 'onRangeChange prop not supported for this view');
  12577. }
  12578. }
  12579. };
  12580. _this.handleNavigate = function (action, newDate) {
  12581. var _this$props3 = _this.props,
  12582. view = _this$props3.view,
  12583. date = _this$props3.date,
  12584. getNow = _this$props3.getNow,
  12585. onNavigate = _this$props3.onNavigate,
  12586. props = _objectWithoutPropertiesLoose(_this$props3, ["view", "date", "getNow", "onNavigate"]);
  12587. var ViewComponent = _this.getView();
  12588. var today = getNow();
  12589. date = moveDate(ViewComponent, _extends({}, props, {
  12590. action: action,
  12591. date: newDate || date || today,
  12592. today: today
  12593. }));
  12594. onNavigate(date, view, action);
  12595. _this.handleRangeChange(date, ViewComponent);
  12596. };
  12597. _this.handleViewChange = function (view) {
  12598. if (view !== _this.props.view && isValidView(view, _this.props)) {
  12599. _this.props.onView(view);
  12600. }
  12601. var views = _this.getViews();
  12602. _this.handleRangeChange(_this.props.date || _this.props.getNow(), views[view], view);
  12603. };
  12604. _this.handleSelectEvent = function () {
  12605. for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  12606. args[_key2] = arguments[_key2];
  12607. }
  12608. notify(_this.props.onSelectEvent, args);
  12609. };
  12610. _this.handleDoubleClickEvent = function () {
  12611. for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  12612. args[_key3] = arguments[_key3];
  12613. }
  12614. notify(_this.props.onDoubleClickEvent, args);
  12615. };
  12616. _this.handleSelectSlot = function (slotInfo) {
  12617. notify(_this.props.onSelectSlot, slotInfo);
  12618. };
  12619. _this.handleDrillDown = function (date, view) {
  12620. var onDrillDown = _this.props.onDrillDown;
  12621. if (onDrillDown) {
  12622. onDrillDown(date, view, _this.drilldownView);
  12623. return;
  12624. }
  12625. if (view) _this.handleViewChange(view);
  12626. _this.handleNavigate(navigate.DATE, date);
  12627. };
  12628. _this.state = {
  12629. context: _this.getContext(_this.props)
  12630. };
  12631. return _this;
  12632. }
  12633. var _proto = Calendar.prototype;
  12634. _proto.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
  12635. this.setState({
  12636. context: this.getContext(nextProps)
  12637. });
  12638. };
  12639. _proto.getContext = function getContext(_ref2) {
  12640. var startAccessor = _ref2.startAccessor,
  12641. endAccessor = _ref2.endAccessor,
  12642. allDayAccessor = _ref2.allDayAccessor,
  12643. tooltipAccessor = _ref2.tooltipAccessor,
  12644. titleAccessor = _ref2.titleAccessor,
  12645. resourceAccessor = _ref2.resourceAccessor,
  12646. resourceIdAccessor = _ref2.resourceIdAccessor,
  12647. resourceTitleAccessor = _ref2.resourceTitleAccessor,
  12648. eventPropGetter = _ref2.eventPropGetter,
  12649. slotPropGetter = _ref2.slotPropGetter,
  12650. dayPropGetter = _ref2.dayPropGetter,
  12651. view = _ref2.view,
  12652. views = _ref2.views,
  12653. localizer = _ref2.localizer,
  12654. culture = _ref2.culture,
  12655. _ref2$messages = _ref2.messages,
  12656. messages$1 = _ref2$messages === void 0 ? {} : _ref2$messages,
  12657. _ref2$components = _ref2.components,
  12658. components = _ref2$components === void 0 ? {} : _ref2$components,
  12659. _ref2$formats = _ref2.formats,
  12660. formats = _ref2$formats === void 0 ? {} : _ref2$formats;
  12661. var names = viewNames$1(views);
  12662. var msgs = messages(messages$1);
  12663. return {
  12664. viewNames: names,
  12665. localizer: mergeWithDefaults(localizer, culture, formats, msgs),
  12666. getters: {
  12667. eventProp: function eventProp() {
  12668. return eventPropGetter && eventPropGetter.apply(void 0, arguments) || {};
  12669. },
  12670. slotProp: function slotProp() {
  12671. return slotPropGetter && slotPropGetter.apply(void 0, arguments) || {};
  12672. },
  12673. dayProp: function dayProp() {
  12674. return dayPropGetter && dayPropGetter.apply(void 0, arguments) || {};
  12675. }
  12676. },
  12677. components: defaults(components[view] || {}, omit(components, names), {
  12678. eventWrapper: NoopWrapper,
  12679. eventContainerWrapper: NoopWrapper,
  12680. dateCellWrapper: NoopWrapper,
  12681. weekWrapper: NoopWrapper,
  12682. timeSlotWrapper: NoopWrapper
  12683. }),
  12684. accessors: {
  12685. start: wrapAccessor(startAccessor),
  12686. end: wrapAccessor(endAccessor),
  12687. allDay: wrapAccessor(allDayAccessor),
  12688. tooltip: wrapAccessor(tooltipAccessor),
  12689. title: wrapAccessor(titleAccessor),
  12690. resource: wrapAccessor(resourceAccessor),
  12691. resourceId: wrapAccessor(resourceIdAccessor),
  12692. resourceTitle: wrapAccessor(resourceTitleAccessor)
  12693. }
  12694. };
  12695. };
  12696. _proto.render = function render() {
  12697. var _this$props4 = this.props,
  12698. view = _this$props4.view,
  12699. toolbar = _this$props4.toolbar,
  12700. events = _this$props4.events,
  12701. style = _this$props4.style,
  12702. className = _this$props4.className,
  12703. elementProps = _this$props4.elementProps,
  12704. current = _this$props4.date,
  12705. getNow = _this$props4.getNow,
  12706. length = _this$props4.length,
  12707. showMultiDayTimes = _this$props4.showMultiDayTimes,
  12708. onShowMore = _this$props4.onShowMore,
  12709. _0 = _this$props4.components,
  12710. _1 = _this$props4.formats,
  12711. _2 = _this$props4.messages,
  12712. _3 = _this$props4.culture,
  12713. props = _objectWithoutPropertiesLoose(_this$props4, ["view", "toolbar", "events", "style", "className", "elementProps", "date", "getNow", "length", "showMultiDayTimes", "onShowMore", "components", "formats", "messages", "culture"]);
  12714. current = current || getNow();
  12715. var View = this.getView();
  12716. var _this$state$context = this.state.context,
  12717. accessors = _this$state$context.accessors,
  12718. components = _this$state$context.components,
  12719. getters = _this$state$context.getters,
  12720. localizer = _this$state$context.localizer,
  12721. viewNames = _this$state$context.viewNames;
  12722. var CalToolbar = components.toolbar || Toolbar;
  12723. var label = View.title(current, {
  12724. localizer: localizer,
  12725. length: length
  12726. });
  12727. return React__default.createElement("div", _extends({}, elementProps, {
  12728. className: clsx(className, 'rbc-calendar', props.rtl && 'rbc-rtl'),
  12729. style: style
  12730. }), toolbar && React__default.createElement(CalToolbar, {
  12731. date: current,
  12732. view: view,
  12733. views: viewNames,
  12734. label: label,
  12735. onView: this.handleViewChange,
  12736. onNavigate: this.handleNavigate,
  12737. localizer: localizer
  12738. }), React__default.createElement(View, _extends({}, props, {
  12739. events: events,
  12740. date: current,
  12741. getNow: getNow,
  12742. length: length,
  12743. localizer: localizer,
  12744. getters: getters,
  12745. components: components,
  12746. accessors: accessors,
  12747. showMultiDayTimes: showMultiDayTimes,
  12748. getDrilldownView: this.getDrilldownView,
  12749. onNavigate: this.handleNavigate,
  12750. onDrillDown: this.handleDrillDown,
  12751. onSelectEvent: this.handleSelectEvent,
  12752. onDoubleClickEvent: this.handleDoubleClickEvent,
  12753. onSelectSlot: this.handleSelectSlot,
  12754. onShowMore: onShowMore
  12755. })));
  12756. }
  12757. /**
  12758. *
  12759. * @param date
  12760. * @param viewComponent
  12761. * @param {'month'|'week'|'work_week'|'day'|'agenda'} [view] - optional
  12762. * parameter. It appears when range change on view changing. It could be handy
  12763. * when you need to have both: range and view type at once, i.e. for manage rbc
  12764. * state via url
  12765. */
  12766. ;
  12767. return Calendar;
  12768. }(React__default.Component);
  12769. Calendar.defaultProps = {
  12770. elementProps: {},
  12771. popup: false,
  12772. toolbar: true,
  12773. view: views.MONTH,
  12774. views: [views.MONTH, views.WEEK, views.DAY, views.AGENDA],
  12775. step: 30,
  12776. length: 30,
  12777. drilldownView: views.DAY,
  12778. titleAccessor: 'title',
  12779. tooltipAccessor: 'title',
  12780. allDayAccessor: 'allDay',
  12781. startAccessor: 'start',
  12782. endAccessor: 'end',
  12783. resourceAccessor: 'resourceId',
  12784. resourceIdAccessor: 'id',
  12785. resourceTitleAccessor: 'title',
  12786. longPressThreshold: 250,
  12787. getNow: function getNow() {
  12788. return new Date();
  12789. }
  12790. };
  12791. Calendar.propTypes = {
  12792. localizer: propTypes.object.isRequired,
  12793. /**
  12794. * Props passed to main calendar `<div>`.
  12795. *
  12796. */
  12797. elementProps: propTypes.object,
  12798. /**
  12799. * The current date value of the calendar. Determines the visible view range.
  12800. * If `date` is omitted then the result of `getNow` is used; otherwise the
  12801. * current date is used.
  12802. *
  12803. * @controllable onNavigate
  12804. */
  12805. date: propTypes.instanceOf(Date),
  12806. /**
  12807. * The current view of the calendar.
  12808. *
  12809. * @default 'month'
  12810. * @controllable onView
  12811. */
  12812. view: propTypes.string,
  12813. /**
  12814. * The initial view set for the Calendar.
  12815. * @type Calendar.Views ('month'|'week'|'work_week'|'day'|'agenda')
  12816. * @default 'month'
  12817. */
  12818. defaultView: propTypes.string,
  12819. /**
  12820. * An array of event objects to display on the calendar. Events objects
  12821. * can be any shape, as long as the Calendar knows how to retrieve the
  12822. * following details of the event:
  12823. *
  12824. * - start time
  12825. * - end time
  12826. * - title
  12827. * - whether its an "all day" event or not
  12828. * - any resource the event may be related to
  12829. *
  12830. * Each of these properties can be customized or generated dynamically by
  12831. * setting the various "accessor" props. Without any configuration the default
  12832. * event should look like:
  12833. *
  12834. * ```js
  12835. * Event {
  12836. * title: string,
  12837. * start: Date,
  12838. * end: Date,
  12839. * allDay?: boolean
  12840. * resource?: any,
  12841. * }
  12842. * ```
  12843. */
  12844. events: propTypes.arrayOf(propTypes.object),
  12845. /**
  12846. * Accessor for the event title, used to display event information. Should
  12847. * resolve to a `renderable` value.
  12848. *
  12849. * ```js
  12850. * string | (event: Object) => string
  12851. * ```
  12852. *
  12853. * @type {(func|string)}
  12854. */
  12855. titleAccessor: accessor,
  12856. /**
  12857. * Accessor for the event tooltip. Should
  12858. * resolve to a `renderable` value. Removes the tooltip if null.
  12859. *
  12860. * ```js
  12861. * string | (event: Object) => string
  12862. * ```
  12863. *
  12864. * @type {(func|string)}
  12865. */
  12866. tooltipAccessor: accessor,
  12867. /**
  12868. * Determines whether the event should be considered an "all day" event and ignore time.
  12869. * Must resolve to a `boolean` value.
  12870. *
  12871. * ```js
  12872. * string | (event: Object) => boolean
  12873. * ```
  12874. *
  12875. * @type {(func|string)}
  12876. */
  12877. allDayAccessor: accessor,
  12878. /**
  12879. * The start date/time of the event. Must resolve to a JavaScript `Date` object.
  12880. *
  12881. * ```js
  12882. * string | (event: Object) => Date
  12883. * ```
  12884. *
  12885. * @type {(func|string)}
  12886. */
  12887. startAccessor: accessor,
  12888. /**
  12889. * The end date/time of the event. Must resolve to a JavaScript `Date` object.
  12890. *
  12891. * ```js
  12892. * string | (event: Object) => Date
  12893. * ```
  12894. *
  12895. * @type {(func|string)}
  12896. */
  12897. endAccessor: accessor,
  12898. /**
  12899. * Returns the id of the `resource` that the event is a member of. This
  12900. * id should match at least one resource in the `resources` array.
  12901. *
  12902. * ```js
  12903. * string | (event: Object) => Date
  12904. * ```
  12905. *
  12906. * @type {(func|string)}
  12907. */
  12908. resourceAccessor: accessor,
  12909. /**
  12910. * An array of resource objects that map events to a specific resource.
  12911. * Resource objects, like events, can be any shape or have any properties,
  12912. * but should be uniquly identifiable via the `resourceIdAccessor`, as
  12913. * well as a "title" or name as provided by the `resourceTitleAccessor` prop.
  12914. */
  12915. resources: propTypes.arrayOf(propTypes.object),
  12916. /**
  12917. * Provides a unique identifier for each resource in the `resources` array
  12918. *
  12919. * ```js
  12920. * string | (resource: Object) => any
  12921. * ```
  12922. *
  12923. * @type {(func|string)}
  12924. */
  12925. resourceIdAccessor: accessor,
  12926. /**
  12927. * Provides a human readable name for the resource object, used in headers.
  12928. *
  12929. * ```js
  12930. * string | (resource: Object) => any
  12931. * ```
  12932. *
  12933. * @type {(func|string)}
  12934. */
  12935. resourceTitleAccessor: accessor,
  12936. /**
  12937. * Determines the current date/time which is highlighted in the views.
  12938. *
  12939. * The value affects which day is shaded and which time is shown as
  12940. * the current time. It also affects the date used by the Today button in
  12941. * the toolbar.
  12942. *
  12943. * Providing a value here can be useful when you are implementing time zones
  12944. * using the `startAccessor` and `endAccessor` properties.
  12945. *
  12946. * @type {func}
  12947. * @default () => new Date()
  12948. */
  12949. getNow: propTypes.func,
  12950. /**
  12951. * Callback fired when the `date` value changes.
  12952. *
  12953. * @controllable date
  12954. */
  12955. onNavigate: propTypes.func,
  12956. /**
  12957. * Callback fired when the `view` value changes.
  12958. *
  12959. * @controllable view
  12960. */
  12961. onView: propTypes.func,
  12962. /**
  12963. * Callback fired when date header, or the truncated events links are clicked
  12964. *
  12965. */
  12966. onDrillDown: propTypes.func,
  12967. /**
  12968. *
  12969. * ```js
  12970. * (dates: Date[] | { start: Date; end: Date }, view?: 'month'|'week'|'work_week'|'day'|'agenda') => void
  12971. * ```
  12972. *
  12973. * Callback fired when the visible date range changes. Returns an Array of dates
  12974. * or an object with start and end dates for BUILTIN views. Optionally new `view`
  12975. * will be returned when callback called after view change.
  12976. *
  12977. * Custom views may return something different.
  12978. */
  12979. onRangeChange: propTypes.func,
  12980. /**
  12981. * A callback fired when a date selection is made. Only fires when `selectable` is `true`.
  12982. *
  12983. * ```js
  12984. * (
  12985. * slotInfo: {
  12986. * start: Date,
  12987. * end: Date,
  12988. * slots: Array<Date>,
  12989. * action: "select" | "click" | "doubleClick",
  12990. * bounds: ?{ // For "select" action
  12991. * x: number,
  12992. * y: number,
  12993. * top: number,
  12994. * right: number,
  12995. * left: number,
  12996. * bottom: number,
  12997. * },
  12998. * box: ?{ // For "click" or "doubleClick" actions
  12999. * clientX: number,
  13000. * clientY: number,
  13001. * x: number,
  13002. * y: number,
  13003. * },
  13004. * }
  13005. * ) => any
  13006. * ```
  13007. */
  13008. onSelectSlot: propTypes.func,
  13009. /**
  13010. * Callback fired when a calendar event is selected.
  13011. *
  13012. * ```js
  13013. * (event: Object, e: SyntheticEvent) => any
  13014. * ```
  13015. *
  13016. * @controllable selected
  13017. */
  13018. onSelectEvent: propTypes.func,
  13019. /**
  13020. * Callback fired when a calendar event is clicked twice.
  13021. *
  13022. * ```js
  13023. * (event: Object, e: SyntheticEvent) => void
  13024. * ```
  13025. */
  13026. onDoubleClickEvent: propTypes.func,
  13027. /**
  13028. * Callback fired when dragging a selection in the Time views.
  13029. *
  13030. * Returning `false` from the handler will prevent a selection.
  13031. *
  13032. * ```js
  13033. * (range: { start: Date, end: Date }) => ?boolean
  13034. * ```
  13035. */
  13036. onSelecting: propTypes.func,
  13037. /**
  13038. * Callback fired when a +{count} more is clicked
  13039. *
  13040. * ```js
  13041. * (events: Object, date: Date) => any
  13042. * ```
  13043. */
  13044. onShowMore: propTypes.func,
  13045. /**
  13046. * The selected event, if any.
  13047. */
  13048. selected: propTypes.object,
  13049. /**
  13050. * An array of built-in view names to allow the calendar to display.
  13051. * accepts either an array of builtin view names,
  13052. *
  13053. * ```jsx
  13054. * views={['month', 'day', 'agenda']}
  13055. * ```
  13056. * or an object hash of the view name and the component (or boolean for builtin).
  13057. *
  13058. * ```jsx
  13059. * views={{
  13060. * month: true,
  13061. * week: false,
  13062. * myweek: WorkWeekViewComponent,
  13063. * }}
  13064. * ```
  13065. *
  13066. * Custom views can be any React component, that implements the following
  13067. * interface:
  13068. *
  13069. * ```js
  13070. * interface View {
  13071. * static title(date: Date, { formats: DateFormat[], culture: string?, ...props }): string
  13072. * static navigate(date: Date, action: 'PREV' | 'NEXT' | 'DATE'): Date
  13073. * }
  13074. * ```
  13075. *
  13076. * @type Views ('month'|'week'|'work_week'|'day'|'agenda')
  13077. * @View
  13078. ['month', 'week', 'day', 'agenda']
  13079. */
  13080. views: views$1,
  13081. /**
  13082. * The string name of the destination view for drill-down actions, such
  13083. * as clicking a date header, or the truncated events links. If
  13084. * `getDrilldownView` is also specified it will be used instead.
  13085. *
  13086. * Set to `null` to disable drill-down actions.
  13087. *
  13088. * ```js
  13089. * <Calendar
  13090. * drilldownView="agenda"
  13091. * />
  13092. * ```
  13093. */
  13094. drilldownView: propTypes.string,
  13095. /**
  13096. * Functionally equivalent to `drilldownView`, but accepts a function
  13097. * that can return a view name. It's useful for customizing the drill-down
  13098. * actions depending on the target date and triggering view.
  13099. *
  13100. * Return `null` to disable drill-down actions.
  13101. *
  13102. * ```js
  13103. * <Calendar
  13104. * getDrilldownView={(targetDate, currentViewName, configuredViewNames) =>
  13105. * if (currentViewName === 'month' && configuredViewNames.includes('week'))
  13106. * return 'week'
  13107. *
  13108. * return null;
  13109. * }}
  13110. * />
  13111. * ```
  13112. */
  13113. getDrilldownView: propTypes.func,
  13114. /**
  13115. * Determines the end date from date prop in the agenda view
  13116. * date prop + length (in number of days) = end date
  13117. */
  13118. length: propTypes.number,
  13119. /**
  13120. * Determines whether the toolbar is displayed
  13121. */
  13122. toolbar: propTypes.bool,
  13123. /**
  13124. * Show truncated events in an overlay when you click the "+_x_ more" link.
  13125. */
  13126. popup: propTypes.bool,
  13127. /**
  13128. * Distance in pixels, from the edges of the viewport, the "show more" overlay should be positioned.
  13129. *
  13130. * ```jsx
  13131. * <Calendar popupOffset={30}/>
  13132. * <Calendar popupOffset={{x: 30, y: 20}}/>
  13133. * ```
  13134. */
  13135. popupOffset: propTypes.oneOfType([propTypes.number, propTypes.shape({
  13136. x: propTypes.number,
  13137. y: propTypes.number
  13138. })]),
  13139. /**
  13140. * Allows mouse selection of ranges of dates/times.
  13141. *
  13142. * The 'ignoreEvents' option prevents selection code from running when a
  13143. * drag begins over an event. Useful when you want custom event click or drag
  13144. * logic
  13145. */
  13146. selectable: propTypes.oneOf([true, false, 'ignoreEvents']),
  13147. /**
  13148. * Specifies the number of miliseconds the user must press and hold on the screen for a touch
  13149. * to be considered a "long press." Long presses are used for time slot selection on touch
  13150. * devices.
  13151. *
  13152. * @type {number}
  13153. * @default 250
  13154. */
  13155. longPressThreshold: propTypes.number,
  13156. /**
  13157. * Determines the selectable time increments in week and day views
  13158. */
  13159. step: propTypes.number,
  13160. /**
  13161. * The number of slots per "section" in the time grid views. Adjust with `step`
  13162. * to change the default of 1 hour long groups, with 30 minute slots.
  13163. */
  13164. timeslots: propTypes.number,
  13165. /**
  13166. *Switch the calendar to a `right-to-left` read direction.
  13167. */
  13168. rtl: propTypes.bool,
  13169. /**
  13170. * Optionally provide a function that returns an object of className or style props
  13171. * to be applied to the the event node.
  13172. *
  13173. * ```js
  13174. * (
  13175. * event: Object,
  13176. * start: Date,
  13177. * end: Date,
  13178. * isSelected: boolean
  13179. * ) => { className?: string, style?: Object }
  13180. * ```
  13181. */
  13182. eventPropGetter: propTypes.func,
  13183. /**
  13184. * Optionally provide a function that returns an object of className or style props
  13185. * to be applied to the the time-slot node. Caution! Styles that change layout or
  13186. * position may break the calendar in unexpected ways.
  13187. *
  13188. * ```js
  13189. * (date: Date, resourceId: (number|string)) => { className?: string, style?: Object }
  13190. * ```
  13191. */
  13192. slotPropGetter: propTypes.func,
  13193. /**
  13194. * Optionally provide a function that returns an object of className or style props
  13195. * to be applied to the the day background. Caution! Styles that change layout or
  13196. * position may break the calendar in unexpected ways.
  13197. *
  13198. * ```js
  13199. * (date: Date) => { className?: string, style?: Object }
  13200. * ```
  13201. */
  13202. dayPropGetter: propTypes.func,
  13203. /**
  13204. * Support to show multi-day events with specific start and end times in the
  13205. * main time grid (rather than in the all day header).
  13206. *
  13207. * **Note: This may cause calendars with several events to look very busy in
  13208. * the week and day views.**
  13209. */
  13210. showMultiDayTimes: propTypes.bool,
  13211. /**
  13212. * Constrains the minimum _time_ of the Day and Week views.
  13213. */
  13214. min: propTypes.instanceOf(Date),
  13215. /**
  13216. * Constrains the maximum _time_ of the Day and Week views.
  13217. */
  13218. max: propTypes.instanceOf(Date),
  13219. /**
  13220. * Determines how far down the scroll pane is initially scrolled down.
  13221. */
  13222. scrollToTime: propTypes.instanceOf(Date),
  13223. /**
  13224. * Specify a specific culture code for the Calendar.
  13225. *
  13226. * **Note: it's generally better to handle this globally via your i18n library.**
  13227. */
  13228. culture: propTypes.string,
  13229. /**
  13230. * Localizer specific formats, tell the Calendar how to format and display dates.
  13231. *
  13232. * `format` types are dependent on the configured localizer; both Moment and Globalize
  13233. * accept strings of tokens according to their own specification, such as: `'DD mm yyyy'`.
  13234. *
  13235. * ```jsx
  13236. * let formats = {
  13237. * dateFormat: 'dd',
  13238. *
  13239. * dayFormat: (date, , localizer) =>
  13240. * localizer.format(date, 'DDD', culture),
  13241. *
  13242. * dayRangeHeaderFormat: ({ start, end }, culture, localizer) =>
  13243. * localizer.format(start, { date: 'short' }, culture) + ' – ' +
  13244. * localizer.format(end, { date: 'short' }, culture)
  13245. * }
  13246. *
  13247. * <Calendar formats={formats} />
  13248. * ```
  13249. *
  13250. * All localizers accept a function of
  13251. * the form `(date: Date, culture: ?string, localizer: Localizer) -> string`
  13252. */
  13253. formats: propTypes.shape({
  13254. /**
  13255. * Format for the day of the month heading in the Month view.
  13256. * e.g. "01", "02", "03", etc
  13257. */
  13258. dateFormat: dateFormat,
  13259. /**
  13260. * A day of the week format for Week and Day headings,
  13261. * e.g. "Wed 01/04"
  13262. *
  13263. */
  13264. dayFormat: dateFormat,
  13265. /**
  13266. * Week day name format for the Month week day headings,
  13267. * e.g: "Sun", "Mon", "Tue", etc
  13268. *
  13269. */
  13270. weekdayFormat: dateFormat,
  13271. /**
  13272. * The timestamp cell formats in Week and Time views, e.g. "4:00 AM"
  13273. */
  13274. timeGutterFormat: dateFormat,
  13275. /**
  13276. * Toolbar header format for the Month view, e.g "2015 April"
  13277. *
  13278. */
  13279. monthHeaderFormat: dateFormat,
  13280. /**
  13281. * Toolbar header format for the Week views, e.g. "Mar 29 - Apr 04"
  13282. */
  13283. dayRangeHeaderFormat: dateRangeFormat,
  13284. /**
  13285. * Toolbar header format for the Day view, e.g. "Wednesday Apr 01"
  13286. */
  13287. dayHeaderFormat: dateFormat,
  13288. /**
  13289. * Toolbar header format for the Agenda view, e.g. "4/1/2015 – 5/1/2015"
  13290. */
  13291. agendaHeaderFormat: dateRangeFormat,
  13292. /**
  13293. * A time range format for selecting time slots, e.g "8:00am – 2:00pm"
  13294. */
  13295. selectRangeFormat: dateRangeFormat,
  13296. agendaDateFormat: dateFormat,
  13297. agendaTimeFormat: dateFormat,
  13298. agendaTimeRangeFormat: dateRangeFormat,
  13299. /**
  13300. * Time range displayed on events.
  13301. */
  13302. eventTimeRangeFormat: dateRangeFormat,
  13303. /**
  13304. * An optional event time range for events that continue onto another day
  13305. */
  13306. eventTimeRangeStartFormat: dateFormat,
  13307. /**
  13308. * An optional event time range for events that continue from another day
  13309. */
  13310. eventTimeRangeEndFormat: dateFormat
  13311. }),
  13312. /**
  13313. * Customize how different sections of the calendar render by providing custom Components.
  13314. * In particular the `Event` component can be specified for the entire calendar, or you can
  13315. * provide an individual component for each view type.
  13316. *
  13317. * ```jsx
  13318. * let components = {
  13319. * event: MyEvent, // used by each view (Month, Day, Week)
  13320. * eventWrapper: MyEventWrapper,
  13321. * eventContainerWrapper: MyEventContainerWrapper,
  13322. * dateCellWrapper: MyDateCellWrapper,
  13323. * timeSlotWrapper: MyTimeSlotWrapper,
  13324. * timeGutterHeader: MyTimeGutterWrapper,
  13325. * toolbar: MyToolbar,
  13326. * agenda: {
  13327. * event: MyAgendaEvent // with the agenda view use a different component to render events
  13328. * time: MyAgendaTime,
  13329. * date: MyAgendaDate,
  13330. * },
  13331. * day: {
  13332. * header: MyDayHeader,
  13333. * event: MyDayEvent,
  13334. * },
  13335. * week: {
  13336. * header: MyWeekHeader,
  13337. * event: MyWeekEvent,
  13338. * },
  13339. * month: {
  13340. * header: MyMonthHeader,
  13341. * dateHeader: MyMonthDateHeader,
  13342. * event: MyMonthEvent,
  13343. * }
  13344. * }
  13345. * <Calendar components={components} />
  13346. * ```
  13347. */
  13348. components: propTypes.shape({
  13349. event: propTypes.elementType,
  13350. eventWrapper: propTypes.elementType,
  13351. eventContainerWrapper: propTypes.elementType,
  13352. dateCellWrapper: propTypes.elementType,
  13353. timeSlotWrapper: propTypes.elementType,
  13354. timeGutterHeader: propTypes.elementType,
  13355. resourceHeader: propTypes.elementType,
  13356. toolbar: propTypes.elementType,
  13357. agenda: propTypes.shape({
  13358. date: propTypes.elementType,
  13359. time: propTypes.elementType,
  13360. event: propTypes.elementType
  13361. }),
  13362. day: propTypes.shape({
  13363. header: propTypes.elementType,
  13364. event: propTypes.elementType
  13365. }),
  13366. week: propTypes.shape({
  13367. header: propTypes.elementType,
  13368. event: propTypes.elementType
  13369. }),
  13370. month: propTypes.shape({
  13371. header: propTypes.elementType,
  13372. dateHeader: propTypes.elementType,
  13373. event: propTypes.elementType
  13374. })
  13375. }),
  13376. /**
  13377. * String messages used throughout the component, override to provide localizations
  13378. */
  13379. messages: propTypes.shape({
  13380. allDay: propTypes.node,
  13381. previous: propTypes.node,
  13382. next: propTypes.node,
  13383. today: propTypes.node,
  13384. month: propTypes.node,
  13385. week: propTypes.node,
  13386. day: propTypes.node,
  13387. agenda: propTypes.node,
  13388. date: propTypes.node,
  13389. time: propTypes.node,
  13390. event: propTypes.node,
  13391. noEventsInRange: propTypes.node,
  13392. showMore: propTypes.func
  13393. })
  13394. };
  13395. var Calendar$1 = uncontrollable(Calendar, {
  13396. view: 'onView',
  13397. date: 'onNavigate',
  13398. selected: 'onSelectEvent'
  13399. });
  13400. var dateRangeFormat$1 = function dateRangeFormat(_ref, culture, local) {
  13401. var start = _ref.start,
  13402. end = _ref.end;
  13403. return local.format(start, 'L', culture) + ' – ' + local.format(end, 'L', culture);
  13404. };
  13405. var timeRangeFormat = function timeRangeFormat(_ref2, culture, local) {
  13406. var start = _ref2.start,
  13407. end = _ref2.end;
  13408. return local.format(start, 'LT', culture) + ' – ' + local.format(end, 'LT', culture);
  13409. };
  13410. var timeRangeStartFormat = function timeRangeStartFormat(_ref3, culture, local) {
  13411. var start = _ref3.start;
  13412. return local.format(start, 'LT', culture) + ' – ';
  13413. };
  13414. var timeRangeEndFormat = function timeRangeEndFormat(_ref4, culture, local) {
  13415. var end = _ref4.end;
  13416. return ' – ' + local.format(end, 'LT', culture);
  13417. };
  13418. var weekRangeFormat = function weekRangeFormat(_ref5, culture, local) {
  13419. var start = _ref5.start,
  13420. end = _ref5.end;
  13421. return local.format(start, 'MMMM DD', culture) + ' – ' + local.format(end, eq(start, end, 'month') ? 'DD' : 'MMMM DD', culture);
  13422. };
  13423. var formats = {
  13424. dateFormat: 'DD',
  13425. dayFormat: 'DD ddd',
  13426. weekdayFormat: 'ddd',
  13427. selectRangeFormat: timeRangeFormat,
  13428. eventTimeRangeFormat: timeRangeFormat,
  13429. eventTimeRangeStartFormat: timeRangeStartFormat,
  13430. eventTimeRangeEndFormat: timeRangeEndFormat,
  13431. timeGutterFormat: 'LT',
  13432. monthHeaderFormat: 'MMMM YYYY',
  13433. dayHeaderFormat: 'dddd MMM DD',
  13434. dayRangeHeaderFormat: weekRangeFormat,
  13435. agendaHeaderFormat: dateRangeFormat$1,
  13436. agendaDateFormat: 'ddd MMM DD',
  13437. agendaTimeFormat: 'LT',
  13438. agendaTimeRangeFormat: timeRangeFormat
  13439. };
  13440. function moment (moment) {
  13441. var locale = function locale(m, c) {
  13442. return c ? m.locale(c) : m;
  13443. };
  13444. return new DateLocalizer({
  13445. formats: formats,
  13446. firstOfWeek: function firstOfWeek(culture) {
  13447. var data = culture ? moment.localeData(culture) : moment.localeData();
  13448. return data ? data.firstDayOfWeek() : 0;
  13449. },
  13450. format: function format(value, _format, culture) {
  13451. return locale(moment(value), culture).format(_format);
  13452. }
  13453. });
  13454. }
  13455. var dateRangeFormat$2 = function dateRangeFormat(_ref, culture, local) {
  13456. var start = _ref.start,
  13457. end = _ref.end;
  13458. return local.format(start, 'd', culture) + ' – ' + local.format(end, 'd', culture);
  13459. };
  13460. var timeRangeFormat$1 = function timeRangeFormat(_ref2, culture, local) {
  13461. var start = _ref2.start,
  13462. end = _ref2.end;
  13463. return local.format(start, 't', culture) + ' – ' + local.format(end, 't', culture);
  13464. };
  13465. var timeRangeStartFormat$1 = function timeRangeStartFormat(_ref3, culture, local) {
  13466. var start = _ref3.start;
  13467. return local.format(start, 't', culture) + ' – ';
  13468. };
  13469. var timeRangeEndFormat$1 = function timeRangeEndFormat(_ref4, culture, local) {
  13470. var end = _ref4.end;
  13471. return ' – ' + local.format(end, 't', culture);
  13472. };
  13473. var weekRangeFormat$1 = function weekRangeFormat(_ref5, culture, local) {
  13474. var start = _ref5.start,
  13475. end = _ref5.end;
  13476. return local.format(start, 'MMM dd', culture) + ' – ' + local.format(end, eq(start, end, 'month') ? 'dd' : 'MMM dd', culture);
  13477. };
  13478. var formats$1 = {
  13479. dateFormat: 'dd',
  13480. dayFormat: 'ddd dd/MM',
  13481. weekdayFormat: 'ddd',
  13482. selectRangeFormat: timeRangeFormat$1,
  13483. eventTimeRangeFormat: timeRangeFormat$1,
  13484. eventTimeRangeStartFormat: timeRangeStartFormat$1,
  13485. eventTimeRangeEndFormat: timeRangeEndFormat$1,
  13486. timeGutterFormat: 't',
  13487. monthHeaderFormat: 'Y',
  13488. dayHeaderFormat: 'dddd MMM dd',
  13489. dayRangeHeaderFormat: weekRangeFormat$1,
  13490. agendaHeaderFormat: dateRangeFormat$2,
  13491. agendaDateFormat: 'ddd MMM dd',
  13492. agendaTimeFormat: 't',
  13493. agendaTimeRangeFormat: timeRangeFormat$1
  13494. };
  13495. function oldGlobalize (globalize) {
  13496. function getCulture(culture) {
  13497. return culture ? globalize.findClosestCulture(culture) : globalize.culture();
  13498. }
  13499. function firstOfWeek(culture) {
  13500. culture = getCulture(culture);
  13501. return culture && culture.calendar.firstDay || 0;
  13502. }
  13503. return new DateLocalizer({
  13504. firstOfWeek: firstOfWeek,
  13505. formats: formats$1,
  13506. format: function format(value, _format, culture) {
  13507. return globalize.format(value, _format, culture);
  13508. }
  13509. });
  13510. }
  13511. var dateRangeFormat$3 = function dateRangeFormat(_ref, culture, local) {
  13512. var start = _ref.start,
  13513. end = _ref.end;
  13514. return local.format(start, {
  13515. date: 'short'
  13516. }, culture) + ' – ' + local.format(end, {
  13517. date: 'short'
  13518. }, culture);
  13519. };
  13520. var timeRangeFormat$2 = function timeRangeFormat(_ref2, culture, local) {
  13521. var start = _ref2.start,
  13522. end = _ref2.end;
  13523. return local.format(start, {
  13524. time: 'short'
  13525. }, culture) + ' – ' + local.format(end, {
  13526. time: 'short'
  13527. }, culture);
  13528. };
  13529. var timeRangeStartFormat$2 = function timeRangeStartFormat(_ref3, culture, local) {
  13530. var start = _ref3.start;
  13531. return local.format(start, {
  13532. time: 'short'
  13533. }, culture) + ' – ';
  13534. };
  13535. var timeRangeEndFormat$2 = function timeRangeEndFormat(_ref4, culture, local) {
  13536. var end = _ref4.end;
  13537. return ' – ' + local.format(end, {
  13538. time: 'short'
  13539. }, culture);
  13540. };
  13541. var weekRangeFormat$2 = function weekRangeFormat(_ref5, culture, local) {
  13542. var start = _ref5.start,
  13543. end = _ref5.end;
  13544. return local.format(start, 'MMM dd', culture) + ' – ' + local.format(end, eq(start, end, 'month') ? 'dd' : 'MMM dd', culture);
  13545. };
  13546. var formats$2 = {
  13547. dateFormat: 'dd',
  13548. dayFormat: 'eee dd/MM',
  13549. weekdayFormat: 'eee',
  13550. selectRangeFormat: timeRangeFormat$2,
  13551. eventTimeRangeFormat: timeRangeFormat$2,
  13552. eventTimeRangeStartFormat: timeRangeStartFormat$2,
  13553. eventTimeRangeEndFormat: timeRangeEndFormat$2,
  13554. timeGutterFormat: {
  13555. time: 'short'
  13556. },
  13557. monthHeaderFormat: 'MMMM yyyy',
  13558. dayHeaderFormat: 'eeee MMM dd',
  13559. dayRangeHeaderFormat: weekRangeFormat$2,
  13560. agendaHeaderFormat: dateRangeFormat$3,
  13561. agendaDateFormat: 'eee MMM dd',
  13562. agendaTimeFormat: {
  13563. time: 'short'
  13564. },
  13565. agendaTimeRangeFormat: timeRangeFormat$2
  13566. };
  13567. function globalize (globalize) {
  13568. var locale = function locale(culture) {
  13569. return culture ? globalize(culture) : globalize;
  13570. }; // return the first day of the week from the locale data. Defaults to 'world'
  13571. // territory if no territory is derivable from CLDR.
  13572. // Failing to use CLDR supplemental (not loaded?), revert to the original
  13573. // method of getting first day of week.
  13574. function firstOfWeek(culture) {
  13575. try {
  13576. var days = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
  13577. var cldr = locale(culture).cldr;
  13578. var territory = cldr.attributes.territory;
  13579. var weekData = cldr.get('supplemental').weekData;
  13580. var firstDay = weekData.firstDay[territory || '001'];
  13581. return days.indexOf(firstDay);
  13582. } catch (e) {
  13583. warning_1(true, "Failed to accurately determine first day of the week.\n Is supplemental data loaded into CLDR?"); // maybe cldr supplemental is not loaded? revert to original method
  13584. var date = new Date(); //cldr-data doesn't seem to be zero based
  13585. var localeDay = Math.max(parseInt(locale(culture).formatDate(date, {
  13586. raw: 'e'
  13587. }), 10) - 1, 0);
  13588. return Math.abs(date.getDay() - localeDay);
  13589. }
  13590. }
  13591. if (!globalize.load) return oldGlobalize(globalize);
  13592. return new DateLocalizer({
  13593. firstOfWeek: firstOfWeek,
  13594. formats: formats$2,
  13595. format: function format(value, _format, culture) {
  13596. _format = typeof _format === 'string' ? {
  13597. raw: _format
  13598. } : _format;
  13599. return locale(culture).formatDate(value, _format);
  13600. }
  13601. });
  13602. }
  13603. var components = {
  13604. eventWrapper: NoopWrapper,
  13605. timeSlotWrapper: NoopWrapper,
  13606. dateCellWrapper: NoopWrapper
  13607. };
  13608. exports.Calendar = Calendar$1;
  13609. exports.DateLocalizer = DateLocalizer;
  13610. exports.Navigate = navigate;
  13611. exports.Views = views;
  13612. exports.components = components;
  13613. exports.globalizeLocalizer = globalize;
  13614. exports.momentLocalizer = moment;
  13615. exports.move = moveDate;
  13616. Object.defineProperty(exports, '__esModule', { value: true });
  13617. }));