main.js 362 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679
  1. /*!
  2. FullCalendar Core Package v4.2.0
  3. Docs & License: https://fullcalendar.io/
  4. (c) 2019 Adam Shaw
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  8. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  9. (global = global || self, factory(global.FullCalendar = {}));
  10. }(this, function (exports) { 'use strict';
  11. // Creating
  12. // ----------------------------------------------------------------------------------------------------------------
  13. var elementPropHash = {
  14. className: true,
  15. colSpan: true,
  16. rowSpan: true
  17. };
  18. var containerTagHash = {
  19. '<tr': 'tbody',
  20. '<td': 'tr'
  21. };
  22. function createElement(tagName, attrs, content) {
  23. var el = document.createElement(tagName);
  24. if (attrs) {
  25. for (var attrName in attrs) {
  26. if (attrName === 'style') {
  27. applyStyle(el, attrs[attrName]);
  28. }
  29. else if (elementPropHash[attrName]) {
  30. el[attrName] = attrs[attrName];
  31. }
  32. else {
  33. el.setAttribute(attrName, attrs[attrName]);
  34. }
  35. }
  36. }
  37. if (typeof content === 'string') {
  38. el.innerHTML = content; // shortcut. no need to process HTML in any way
  39. }
  40. else if (content != null) {
  41. appendToElement(el, content);
  42. }
  43. return el;
  44. }
  45. function htmlToElement(html) {
  46. html = html.trim();
  47. var container = document.createElement(computeContainerTag(html));
  48. container.innerHTML = html;
  49. return container.firstChild;
  50. }
  51. function htmlToElements(html) {
  52. return Array.prototype.slice.call(htmlToNodeList(html));
  53. }
  54. function htmlToNodeList(html) {
  55. html = html.trim();
  56. var container = document.createElement(computeContainerTag(html));
  57. container.innerHTML = html;
  58. return container.childNodes;
  59. }
  60. // assumes html already trimmed and tag names are lowercase
  61. function computeContainerTag(html) {
  62. return containerTagHash[html.substr(0, 3) // faster than using regex
  63. ] || 'div';
  64. }
  65. function appendToElement(el, content) {
  66. var childNodes = normalizeContent(content);
  67. for (var i = 0; i < childNodes.length; i++) {
  68. el.appendChild(childNodes[i]);
  69. }
  70. }
  71. function prependToElement(parent, content) {
  72. var newEls = normalizeContent(content);
  73. var afterEl = parent.firstChild || null; // if no firstChild, will append to end, but that's okay, b/c there were no children
  74. for (var i = 0; i < newEls.length; i++) {
  75. parent.insertBefore(newEls[i], afterEl);
  76. }
  77. }
  78. function insertAfterElement(refEl, content) {
  79. var newEls = normalizeContent(content);
  80. var afterEl = refEl.nextSibling || null;
  81. for (var i = 0; i < newEls.length; i++) {
  82. refEl.parentNode.insertBefore(newEls[i], afterEl);
  83. }
  84. }
  85. function normalizeContent(content) {
  86. var els;
  87. if (typeof content === 'string') {
  88. els = htmlToElements(content);
  89. }
  90. else if (content instanceof Node) {
  91. els = [content];
  92. }
  93. else { // Node[] or NodeList
  94. els = Array.prototype.slice.call(content);
  95. }
  96. return els;
  97. }
  98. function removeElement(el) {
  99. if (el.parentNode) {
  100. el.parentNode.removeChild(el);
  101. }
  102. }
  103. // Querying
  104. // ----------------------------------------------------------------------------------------------------------------
  105. // from https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
  106. var matchesMethod = Element.prototype.matches ||
  107. Element.prototype.matchesSelector ||
  108. Element.prototype.msMatchesSelector;
  109. var closestMethod = Element.prototype.closest || function (selector) {
  110. // polyfill
  111. var el = this;
  112. if (!document.documentElement.contains(el)) {
  113. return null;
  114. }
  115. do {
  116. if (elementMatches(el, selector)) {
  117. return el;
  118. }
  119. el = el.parentElement || el.parentNode;
  120. } while (el !== null && el.nodeType === 1);
  121. return null;
  122. };
  123. function elementClosest(el, selector) {
  124. return closestMethod.call(el, selector);
  125. }
  126. function elementMatches(el, selector) {
  127. return matchesMethod.call(el, selector);
  128. }
  129. // accepts multiple subject els
  130. // returns a real array. good for methods like forEach
  131. function findElements(container, selector) {
  132. var containers = container instanceof HTMLElement ? [container] : container;
  133. var allMatches = [];
  134. for (var i = 0; i < containers.length; i++) {
  135. var matches = containers[i].querySelectorAll(selector);
  136. for (var j = 0; j < matches.length; j++) {
  137. allMatches.push(matches[j]);
  138. }
  139. }
  140. return allMatches;
  141. }
  142. // accepts multiple subject els
  143. // only queries direct child elements
  144. function findChildren(parent, selector) {
  145. var parents = parent instanceof HTMLElement ? [parent] : parent;
  146. var allMatches = [];
  147. for (var i = 0; i < parents.length; i++) {
  148. var childNodes = parents[i].children; // only ever elements
  149. for (var j = 0; j < childNodes.length; j++) {
  150. var childNode = childNodes[j];
  151. if (!selector || elementMatches(childNode, selector)) {
  152. allMatches.push(childNode);
  153. }
  154. }
  155. }
  156. return allMatches;
  157. }
  158. // Attributes
  159. // ----------------------------------------------------------------------------------------------------------------
  160. function forceClassName(el, className, bool) {
  161. if (bool) {
  162. el.classList.add(className);
  163. }
  164. else {
  165. el.classList.remove(className);
  166. }
  167. }
  168. // Style
  169. // ----------------------------------------------------------------------------------------------------------------
  170. var PIXEL_PROP_RE = /(top|left|right|bottom|width|height)$/i;
  171. function applyStyle(el, props) {
  172. for (var propName in props) {
  173. applyStyleProp(el, propName, props[propName]);
  174. }
  175. }
  176. function applyStyleProp(el, name, val) {
  177. if (val == null) {
  178. el.style[name] = '';
  179. }
  180. else if (typeof val === 'number' && PIXEL_PROP_RE.test(name)) {
  181. el.style[name] = val + 'px';
  182. }
  183. else {
  184. el.style[name] = val;
  185. }
  186. }
  187. function pointInsideRect(point, rect) {
  188. return point.left >= rect.left &&
  189. point.left < rect.right &&
  190. point.top >= rect.top &&
  191. point.top < rect.bottom;
  192. }
  193. // Returns a new rectangle that is the intersection of the two rectangles. If they don't intersect, returns false
  194. function intersectRects(rect1, rect2) {
  195. var res = {
  196. left: Math.max(rect1.left, rect2.left),
  197. right: Math.min(rect1.right, rect2.right),
  198. top: Math.max(rect1.top, rect2.top),
  199. bottom: Math.min(rect1.bottom, rect2.bottom)
  200. };
  201. if (res.left < res.right && res.top < res.bottom) {
  202. return res;
  203. }
  204. return false;
  205. }
  206. function translateRect(rect, deltaX, deltaY) {
  207. return {
  208. left: rect.left + deltaX,
  209. right: rect.right + deltaX,
  210. top: rect.top + deltaY,
  211. bottom: rect.bottom + deltaY
  212. };
  213. }
  214. // Returns a new point that will have been moved to reside within the given rectangle
  215. function constrainPoint(point, rect) {
  216. return {
  217. left: Math.min(Math.max(point.left, rect.left), rect.right),
  218. top: Math.min(Math.max(point.top, rect.top), rect.bottom)
  219. };
  220. }
  221. // Returns a point that is the center of the given rectangle
  222. function getRectCenter(rect) {
  223. return {
  224. left: (rect.left + rect.right) / 2,
  225. top: (rect.top + rect.bottom) / 2
  226. };
  227. }
  228. // Subtracts point2's coordinates from point1's coordinates, returning a delta
  229. function diffPoints(point1, point2) {
  230. return {
  231. left: point1.left - point2.left,
  232. top: point1.top - point2.top
  233. };
  234. }
  235. // Logic for determining if, when the element is right-to-left, the scrollbar appears on the left side
  236. var isRtlScrollbarOnLeft = null;
  237. function getIsRtlScrollbarOnLeft() {
  238. if (isRtlScrollbarOnLeft === null) {
  239. isRtlScrollbarOnLeft = computeIsRtlScrollbarOnLeft();
  240. }
  241. return isRtlScrollbarOnLeft;
  242. }
  243. function computeIsRtlScrollbarOnLeft() {
  244. var outerEl = createElement('div', {
  245. style: {
  246. position: 'absolute',
  247. top: -1000,
  248. left: 0,
  249. border: 0,
  250. padding: 0,
  251. overflow: 'scroll',
  252. direction: 'rtl'
  253. }
  254. }, '<div></div>');
  255. document.body.appendChild(outerEl);
  256. var innerEl = outerEl.firstChild;
  257. var res = innerEl.getBoundingClientRect().left > outerEl.getBoundingClientRect().left;
  258. removeElement(outerEl);
  259. return res;
  260. }
  261. // The scrollbar width computations in computeEdges are sometimes flawed when it comes to
  262. // retina displays, rounding, and IE11. Massage them into a usable value.
  263. function sanitizeScrollbarWidth(width) {
  264. width = Math.max(0, width); // no negatives
  265. width = Math.round(width);
  266. return width;
  267. }
  268. function computeEdges(el, getPadding) {
  269. if (getPadding === void 0) { getPadding = false; }
  270. var computedStyle = window.getComputedStyle(el);
  271. var borderLeft = parseInt(computedStyle.borderLeftWidth, 10) || 0;
  272. var borderRight = parseInt(computedStyle.borderRightWidth, 10) || 0;
  273. var borderTop = parseInt(computedStyle.borderTopWidth, 10) || 0;
  274. var borderBottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
  275. var scrollbarLeftRight = sanitizeScrollbarWidth(el.offsetWidth - el.clientWidth - borderLeft - borderRight);
  276. var scrollbarBottom = sanitizeScrollbarWidth(el.offsetHeight - el.clientHeight - borderTop - borderBottom);
  277. var res = {
  278. borderLeft: borderLeft,
  279. borderRight: borderRight,
  280. borderTop: borderTop,
  281. borderBottom: borderBottom,
  282. scrollbarBottom: scrollbarBottom,
  283. scrollbarLeft: 0,
  284. scrollbarRight: 0
  285. };
  286. if (getIsRtlScrollbarOnLeft() && computedStyle.direction === 'rtl') { // is the scrollbar on the left side?
  287. res.scrollbarLeft = scrollbarLeftRight;
  288. }
  289. else {
  290. res.scrollbarRight = scrollbarLeftRight;
  291. }
  292. if (getPadding) {
  293. res.paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
  294. res.paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
  295. res.paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
  296. res.paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
  297. }
  298. return res;
  299. }
  300. function computeInnerRect(el, goWithinPadding) {
  301. if (goWithinPadding === void 0) { goWithinPadding = false; }
  302. var outerRect = computeRect(el);
  303. var edges = computeEdges(el, goWithinPadding);
  304. var res = {
  305. left: outerRect.left + edges.borderLeft + edges.scrollbarLeft,
  306. right: outerRect.right - edges.borderRight - edges.scrollbarRight,
  307. top: outerRect.top + edges.borderTop,
  308. bottom: outerRect.bottom - edges.borderBottom - edges.scrollbarBottom
  309. };
  310. if (goWithinPadding) {
  311. res.left += edges.paddingLeft;
  312. res.right -= edges.paddingRight;
  313. res.top += edges.paddingTop;
  314. res.bottom -= edges.paddingBottom;
  315. }
  316. return res;
  317. }
  318. function computeRect(el) {
  319. var rect = el.getBoundingClientRect();
  320. return {
  321. left: rect.left + window.pageXOffset,
  322. top: rect.top + window.pageYOffset,
  323. right: rect.right + window.pageXOffset,
  324. bottom: rect.bottom + window.pageYOffset
  325. };
  326. }
  327. function computeViewportRect() {
  328. return {
  329. left: window.pageXOffset,
  330. right: window.pageXOffset + document.documentElement.clientWidth,
  331. top: window.pageYOffset,
  332. bottom: window.pageYOffset + document.documentElement.clientHeight
  333. };
  334. }
  335. function computeHeightAndMargins(el) {
  336. var computed = window.getComputedStyle(el);
  337. return el.getBoundingClientRect().height +
  338. parseInt(computed.marginTop, 10) +
  339. parseInt(computed.marginBottom, 10);
  340. }
  341. // does not return window
  342. function getClippingParents(el) {
  343. var parents = [];
  344. while (el instanceof HTMLElement) { // will stop when gets to document or null
  345. var computedStyle = window.getComputedStyle(el);
  346. if (computedStyle.position === 'fixed') {
  347. break;
  348. }
  349. if ((/(auto|scroll)/).test(computedStyle.overflow + computedStyle.overflowY + computedStyle.overflowX)) {
  350. parents.push(el);
  351. }
  352. el = el.parentNode;
  353. }
  354. return parents;
  355. }
  356. function computeClippingRect(el) {
  357. return getClippingParents(el)
  358. .map(function (el) {
  359. return computeInnerRect(el);
  360. })
  361. .concat(computeViewportRect())
  362. .reduce(function (rect0, rect1) {
  363. return intersectRects(rect0, rect1) || rect1; // should always intersect
  364. });
  365. }
  366. // Stops a mouse/touch event from doing it's native browser action
  367. function preventDefault(ev) {
  368. ev.preventDefault();
  369. }
  370. // Event Delegation
  371. // ----------------------------------------------------------------------------------------------------------------
  372. function listenBySelector(container, eventType, selector, handler) {
  373. function realHandler(ev) {
  374. var matchedChild = elementClosest(ev.target, selector);
  375. if (matchedChild) {
  376. handler.call(matchedChild, ev, matchedChild);
  377. }
  378. }
  379. container.addEventListener(eventType, realHandler);
  380. return function () {
  381. container.removeEventListener(eventType, realHandler);
  382. };
  383. }
  384. function listenToHoverBySelector(container, selector, onMouseEnter, onMouseLeave) {
  385. var currentMatchedChild;
  386. return listenBySelector(container, 'mouseover', selector, function (ev, matchedChild) {
  387. if (matchedChild !== currentMatchedChild) {
  388. currentMatchedChild = matchedChild;
  389. onMouseEnter(ev, matchedChild);
  390. var realOnMouseLeave_1 = function (ev) {
  391. currentMatchedChild = null;
  392. onMouseLeave(ev, matchedChild);
  393. matchedChild.removeEventListener('mouseleave', realOnMouseLeave_1);
  394. };
  395. // listen to the next mouseleave, and then unattach
  396. matchedChild.addEventListener('mouseleave', realOnMouseLeave_1);
  397. }
  398. });
  399. }
  400. // Animation
  401. // ----------------------------------------------------------------------------------------------------------------
  402. var transitionEventNames = [
  403. 'webkitTransitionEnd',
  404. 'otransitionend',
  405. 'oTransitionEnd',
  406. 'msTransitionEnd',
  407. 'transitionend'
  408. ];
  409. // triggered only when the next single subsequent transition finishes
  410. function whenTransitionDone(el, callback) {
  411. var realCallback = function (ev) {
  412. callback(ev);
  413. transitionEventNames.forEach(function (eventName) {
  414. el.removeEventListener(eventName, realCallback);
  415. });
  416. };
  417. transitionEventNames.forEach(function (eventName) {
  418. el.addEventListener(eventName, realCallback); // cross-browser way to determine when the transition finishes
  419. });
  420. }
  421. var DAY_IDS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
  422. // Adding
  423. function addWeeks(m, n) {
  424. var a = dateToUtcArray(m);
  425. a[2] += n * 7;
  426. return arrayToUtcDate(a);
  427. }
  428. function addDays(m, n) {
  429. var a = dateToUtcArray(m);
  430. a[2] += n;
  431. return arrayToUtcDate(a);
  432. }
  433. function addMs(m, n) {
  434. var a = dateToUtcArray(m);
  435. a[6] += n;
  436. return arrayToUtcDate(a);
  437. }
  438. // Diffing (all return floats)
  439. function diffWeeks(m0, m1) {
  440. return diffDays(m0, m1) / 7;
  441. }
  442. function diffDays(m0, m1) {
  443. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60 * 24);
  444. }
  445. function diffHours(m0, m1) {
  446. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60);
  447. }
  448. function diffMinutes(m0, m1) {
  449. return (m1.valueOf() - m0.valueOf()) / (1000 * 60);
  450. }
  451. function diffSeconds(m0, m1) {
  452. return (m1.valueOf() - m0.valueOf()) / 1000;
  453. }
  454. function diffDayAndTime(m0, m1) {
  455. var m0day = startOfDay(m0);
  456. var m1day = startOfDay(m1);
  457. return {
  458. years: 0,
  459. months: 0,
  460. days: Math.round(diffDays(m0day, m1day)),
  461. milliseconds: (m1.valueOf() - m1day.valueOf()) - (m0.valueOf() - m0day.valueOf())
  462. };
  463. }
  464. // Diffing Whole Units
  465. function diffWholeWeeks(m0, m1) {
  466. var d = diffWholeDays(m0, m1);
  467. if (d !== null && d % 7 === 0) {
  468. return d / 7;
  469. }
  470. return null;
  471. }
  472. function diffWholeDays(m0, m1) {
  473. if (timeAsMs(m0) === timeAsMs(m1)) {
  474. return Math.round(diffDays(m0, m1));
  475. }
  476. return null;
  477. }
  478. // Start-Of
  479. function startOfDay(m) {
  480. return arrayToUtcDate([
  481. m.getUTCFullYear(),
  482. m.getUTCMonth(),
  483. m.getUTCDate()
  484. ]);
  485. }
  486. function startOfHour(m) {
  487. return arrayToUtcDate([
  488. m.getUTCFullYear(),
  489. m.getUTCMonth(),
  490. m.getUTCDate(),
  491. m.getUTCHours()
  492. ]);
  493. }
  494. function startOfMinute(m) {
  495. return arrayToUtcDate([
  496. m.getUTCFullYear(),
  497. m.getUTCMonth(),
  498. m.getUTCDate(),
  499. m.getUTCHours(),
  500. m.getUTCMinutes()
  501. ]);
  502. }
  503. function startOfSecond(m) {
  504. return arrayToUtcDate([
  505. m.getUTCFullYear(),
  506. m.getUTCMonth(),
  507. m.getUTCDate(),
  508. m.getUTCHours(),
  509. m.getUTCMinutes(),
  510. m.getUTCSeconds()
  511. ]);
  512. }
  513. // Week Computation
  514. function weekOfYear(marker, dow, doy) {
  515. var y = marker.getUTCFullYear();
  516. var w = weekOfGivenYear(marker, y, dow, doy);
  517. if (w < 1) {
  518. return weekOfGivenYear(marker, y - 1, dow, doy);
  519. }
  520. var nextW = weekOfGivenYear(marker, y + 1, dow, doy);
  521. if (nextW >= 1) {
  522. return Math.min(w, nextW);
  523. }
  524. return w;
  525. }
  526. function weekOfGivenYear(marker, year, dow, doy) {
  527. var firstWeekStart = arrayToUtcDate([year, 0, 1 + firstWeekOffset(year, dow, doy)]);
  528. var dayStart = startOfDay(marker);
  529. var days = Math.round(diffDays(firstWeekStart, dayStart));
  530. return Math.floor(days / 7) + 1; // zero-indexed
  531. }
  532. // start-of-first-week - start-of-year
  533. function firstWeekOffset(year, dow, doy) {
  534. // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  535. var fwd = 7 + dow - doy;
  536. // first-week day local weekday -- which local weekday is fwd
  537. var fwdlw = (7 + arrayToUtcDate([year, 0, fwd]).getUTCDay() - dow) % 7;
  538. return -fwdlw + fwd - 1;
  539. }
  540. // Array Conversion
  541. function dateToLocalArray(date) {
  542. return [
  543. date.getFullYear(),
  544. date.getMonth(),
  545. date.getDate(),
  546. date.getHours(),
  547. date.getMinutes(),
  548. date.getSeconds(),
  549. date.getMilliseconds()
  550. ];
  551. }
  552. function arrayToLocalDate(a) {
  553. return new Date(a[0], a[1] || 0, a[2] == null ? 1 : a[2], // day of month
  554. a[3] || 0, a[4] || 0, a[5] || 0);
  555. }
  556. function dateToUtcArray(date) {
  557. return [
  558. date.getUTCFullYear(),
  559. date.getUTCMonth(),
  560. date.getUTCDate(),
  561. date.getUTCHours(),
  562. date.getUTCMinutes(),
  563. date.getUTCSeconds(),
  564. date.getUTCMilliseconds()
  565. ];
  566. }
  567. function arrayToUtcDate(a) {
  568. // according to web standards (and Safari), a month index is required.
  569. // massage if only given a year.
  570. if (a.length === 1) {
  571. a = a.concat([0]);
  572. }
  573. return new Date(Date.UTC.apply(Date, a));
  574. }
  575. // Other Utils
  576. function isValidDate(m) {
  577. return !isNaN(m.valueOf());
  578. }
  579. function timeAsMs(m) {
  580. return m.getUTCHours() * 1000 * 60 * 60 +
  581. m.getUTCMinutes() * 1000 * 60 +
  582. m.getUTCSeconds() * 1000 +
  583. m.getUTCMilliseconds();
  584. }
  585. var INTERNAL_UNITS = ['years', 'months', 'days', 'milliseconds'];
  586. var PARSE_RE = /^(-?)(?:(\d+)\.)?(\d+):(\d\d)(?::(\d\d)(?:\.(\d\d\d))?)?/;
  587. // Parsing and Creation
  588. function createDuration(input, unit) {
  589. var _a;
  590. if (typeof input === 'string') {
  591. return parseString(input);
  592. }
  593. else if (typeof input === 'object' && input) { // non-null object
  594. return normalizeObject(input);
  595. }
  596. else if (typeof input === 'number') {
  597. return normalizeObject((_a = {}, _a[unit || 'milliseconds'] = input, _a));
  598. }
  599. else {
  600. return null;
  601. }
  602. }
  603. function parseString(s) {
  604. var m = PARSE_RE.exec(s);
  605. if (m) {
  606. var sign = m[1] ? -1 : 1;
  607. return {
  608. years: 0,
  609. months: 0,
  610. days: sign * (m[2] ? parseInt(m[2], 10) : 0),
  611. milliseconds: sign * ((m[3] ? parseInt(m[3], 10) : 0) * 60 * 60 * 1000 + // hours
  612. (m[4] ? parseInt(m[4], 10) : 0) * 60 * 1000 + // minutes
  613. (m[5] ? parseInt(m[5], 10) : 0) * 1000 + // seconds
  614. (m[6] ? parseInt(m[6], 10) : 0) // ms
  615. )
  616. };
  617. }
  618. return null;
  619. }
  620. function normalizeObject(obj) {
  621. return {
  622. years: obj.years || obj.year || 0,
  623. months: obj.months || obj.month || 0,
  624. days: (obj.days || obj.day || 0) +
  625. getWeeksFromInput(obj) * 7,
  626. milliseconds: (obj.hours || obj.hour || 0) * 60 * 60 * 1000 + // hours
  627. (obj.minutes || obj.minute || 0) * 60 * 1000 + // minutes
  628. (obj.seconds || obj.second || 0) * 1000 + // seconds
  629. (obj.milliseconds || obj.millisecond || obj.ms || 0) // ms
  630. };
  631. }
  632. function getWeeksFromInput(obj) {
  633. return obj.weeks || obj.week || 0;
  634. }
  635. // Equality
  636. function durationsEqual(d0, d1) {
  637. return d0.years === d1.years &&
  638. d0.months === d1.months &&
  639. d0.days === d1.days &&
  640. d0.milliseconds === d1.milliseconds;
  641. }
  642. function isSingleDay(dur) {
  643. return dur.years === 0 && dur.months === 0 && dur.days === 1 && dur.milliseconds === 0;
  644. }
  645. // Simple Math
  646. function addDurations(d0, d1) {
  647. return {
  648. years: d0.years + d1.years,
  649. months: d0.months + d1.months,
  650. days: d0.days + d1.days,
  651. milliseconds: d0.milliseconds + d1.milliseconds
  652. };
  653. }
  654. function subtractDurations(d1, d0) {
  655. return {
  656. years: d1.years - d0.years,
  657. months: d1.months - d0.months,
  658. days: d1.days - d0.days,
  659. milliseconds: d1.milliseconds - d0.milliseconds
  660. };
  661. }
  662. function multiplyDuration(d, n) {
  663. return {
  664. years: d.years * n,
  665. months: d.months * n,
  666. days: d.days * n,
  667. milliseconds: d.milliseconds * n
  668. };
  669. }
  670. // Conversions
  671. // "Rough" because they are based on average-case Gregorian months/years
  672. function asRoughYears(dur) {
  673. return asRoughDays(dur) / 365;
  674. }
  675. function asRoughMonths(dur) {
  676. return asRoughDays(dur) / 30;
  677. }
  678. function asRoughDays(dur) {
  679. return asRoughMs(dur) / 864e5;
  680. }
  681. function asRoughMinutes(dur) {
  682. return asRoughMs(dur) / (1000 * 60);
  683. }
  684. function asRoughSeconds(dur) {
  685. return asRoughMs(dur) / 1000;
  686. }
  687. function asRoughMs(dur) {
  688. return dur.years * (365 * 864e5) +
  689. dur.months * (30 * 864e5) +
  690. dur.days * 864e5 +
  691. dur.milliseconds;
  692. }
  693. // Advanced Math
  694. function wholeDivideDurations(numerator, denominator) {
  695. var res = null;
  696. for (var i = 0; i < INTERNAL_UNITS.length; i++) {
  697. var unit = INTERNAL_UNITS[i];
  698. if (denominator[unit]) {
  699. var localRes = numerator[unit] / denominator[unit];
  700. if (!isInt(localRes) || (res !== null && res !== localRes)) {
  701. return null;
  702. }
  703. res = localRes;
  704. }
  705. else if (numerator[unit]) {
  706. // needs to divide by something but can't!
  707. return null;
  708. }
  709. }
  710. return res;
  711. }
  712. function greatestDurationDenominator(dur, dontReturnWeeks) {
  713. var ms = dur.milliseconds;
  714. if (ms) {
  715. if (ms % 1000 !== 0) {
  716. return { unit: 'millisecond', value: ms };
  717. }
  718. if (ms % (1000 * 60) !== 0) {
  719. return { unit: 'second', value: ms / 1000 };
  720. }
  721. if (ms % (1000 * 60 * 60) !== 0) {
  722. return { unit: 'minute', value: ms / (1000 * 60) };
  723. }
  724. if (ms) {
  725. return { unit: 'hour', value: ms / (1000 * 60 * 60) };
  726. }
  727. }
  728. if (dur.days) {
  729. if (!dontReturnWeeks && dur.days % 7 === 0) {
  730. return { unit: 'week', value: dur.days / 7 };
  731. }
  732. return { unit: 'day', value: dur.days };
  733. }
  734. if (dur.months) {
  735. return { unit: 'month', value: dur.months };
  736. }
  737. if (dur.years) {
  738. return { unit: 'year', value: dur.years };
  739. }
  740. return { unit: 'millisecond', value: 0 };
  741. }
  742. /* FullCalendar-specific DOM Utilities
  743. ----------------------------------------------------------------------------------------------------------------------*/
  744. // Given the scrollbar widths of some other container, create borders/margins on rowEls in order to match the left
  745. // and right space that was offset by the scrollbars. A 1-pixel border first, then margin beyond that.
  746. function compensateScroll(rowEl, scrollbarWidths) {
  747. if (scrollbarWidths.left) {
  748. applyStyle(rowEl, {
  749. borderLeftWidth: 1,
  750. marginLeft: scrollbarWidths.left - 1
  751. });
  752. }
  753. if (scrollbarWidths.right) {
  754. applyStyle(rowEl, {
  755. borderRightWidth: 1,
  756. marginRight: scrollbarWidths.right - 1
  757. });
  758. }
  759. }
  760. // Undoes compensateScroll and restores all borders/margins
  761. function uncompensateScroll(rowEl) {
  762. applyStyle(rowEl, {
  763. marginLeft: '',
  764. marginRight: '',
  765. borderLeftWidth: '',
  766. borderRightWidth: ''
  767. });
  768. }
  769. // Make the mouse cursor express that an event is not allowed in the current area
  770. function disableCursor() {
  771. document.body.classList.add('fc-not-allowed');
  772. }
  773. // Returns the mouse cursor to its original look
  774. function enableCursor() {
  775. document.body.classList.remove('fc-not-allowed');
  776. }
  777. // Given a total available height to fill, have `els` (essentially child rows) expand to accomodate.
  778. // By default, all elements that are shorter than the recommended height are expanded uniformly, not considering
  779. // any other els that are already too tall. if `shouldRedistribute` is on, it considers these tall rows and
  780. // reduces the available height.
  781. function distributeHeight(els, availableHeight, shouldRedistribute) {
  782. // *FLOORING NOTE*: we floor in certain places because zoom can give inaccurate floating-point dimensions,
  783. // and it is better to be shorter than taller, to avoid creating unnecessary scrollbars.
  784. var minOffset1 = Math.floor(availableHeight / els.length); // for non-last element
  785. var minOffset2 = Math.floor(availableHeight - minOffset1 * (els.length - 1)); // for last element *FLOORING NOTE*
  786. var flexEls = []; // elements that are allowed to expand. array of DOM nodes
  787. var flexOffsets = []; // amount of vertical space it takes up
  788. var flexHeights = []; // actual css height
  789. var usedHeight = 0;
  790. undistributeHeight(els); // give all elements their natural height
  791. // find elements that are below the recommended height (expandable).
  792. // important to query for heights in a single first pass (to avoid reflow oscillation).
  793. els.forEach(function (el, i) {
  794. var minOffset = i === els.length - 1 ? minOffset2 : minOffset1;
  795. var naturalOffset = computeHeightAndMargins(el);
  796. if (naturalOffset < minOffset) {
  797. flexEls.push(el);
  798. flexOffsets.push(naturalOffset);
  799. flexHeights.push(el.offsetHeight);
  800. }
  801. else {
  802. // this element stretches past recommended height (non-expandable). mark the space as occupied.
  803. usedHeight += naturalOffset;
  804. }
  805. });
  806. // readjust the recommended height to only consider the height available to non-maxed-out rows.
  807. if (shouldRedistribute) {
  808. availableHeight -= usedHeight;
  809. minOffset1 = Math.floor(availableHeight / flexEls.length);
  810. minOffset2 = Math.floor(availableHeight - minOffset1 * (flexEls.length - 1)); // *FLOORING NOTE*
  811. }
  812. // assign heights to all expandable elements
  813. flexEls.forEach(function (el, i) {
  814. var minOffset = i === flexEls.length - 1 ? minOffset2 : minOffset1;
  815. var naturalOffset = flexOffsets[i];
  816. var naturalHeight = flexHeights[i];
  817. var newHeight = minOffset - (naturalOffset - naturalHeight); // subtract the margin/padding
  818. if (naturalOffset < minOffset) { // we check this again because redistribution might have changed things
  819. el.style.height = newHeight + 'px';
  820. }
  821. });
  822. }
  823. // Undoes distrubuteHeight, restoring all els to their natural height
  824. function undistributeHeight(els) {
  825. els.forEach(function (el) {
  826. el.style.height = '';
  827. });
  828. }
  829. // Given `els`, a set of <td> cells, find the cell with the largest natural width and set the widths of all the
  830. // cells to be that width.
  831. // PREREQUISITE: if you want a cell to take up width, it needs to have a single inner element w/ display:inline
  832. function matchCellWidths(els) {
  833. var maxInnerWidth = 0;
  834. els.forEach(function (el) {
  835. var innerEl = el.firstChild; // hopefully an element
  836. if (innerEl instanceof HTMLElement) {
  837. var innerWidth_1 = innerEl.offsetWidth;
  838. if (innerWidth_1 > maxInnerWidth) {
  839. maxInnerWidth = innerWidth_1;
  840. }
  841. }
  842. });
  843. maxInnerWidth++; // sometimes not accurate of width the text needs to stay on one line. insurance
  844. els.forEach(function (el) {
  845. el.style.width = maxInnerWidth + 'px';
  846. });
  847. return maxInnerWidth;
  848. }
  849. // Given one element that resides inside another,
  850. // Subtracts the height of the inner element from the outer element.
  851. function subtractInnerElHeight(outerEl, innerEl) {
  852. // effin' IE8/9/10/11 sometimes returns 0 for dimensions. this weird hack was the only thing that worked
  853. var reflowStyleProps = {
  854. position: 'relative',
  855. left: -1 // ensure reflow in case the el was already relative. negative is less likely to cause new scroll
  856. };
  857. applyStyle(outerEl, reflowStyleProps);
  858. applyStyle(innerEl, reflowStyleProps);
  859. var diff = outerEl.offsetHeight - innerEl.offsetHeight; // grab the dimensions
  860. // undo hack
  861. var resetStyleProps = { position: '', left: '' };
  862. applyStyle(outerEl, resetStyleProps);
  863. applyStyle(innerEl, resetStyleProps);
  864. return diff;
  865. }
  866. /* Selection
  867. ----------------------------------------------------------------------------------------------------------------------*/
  868. function preventSelection(el) {
  869. el.classList.add('fc-unselectable');
  870. el.addEventListener('selectstart', preventDefault);
  871. }
  872. function allowSelection(el) {
  873. el.classList.remove('fc-unselectable');
  874. el.removeEventListener('selectstart', preventDefault);
  875. }
  876. /* Context Menu
  877. ----------------------------------------------------------------------------------------------------------------------*/
  878. function preventContextMenu(el) {
  879. el.addEventListener('contextmenu', preventDefault);
  880. }
  881. function allowContextMenu(el) {
  882. el.removeEventListener('contextmenu', preventDefault);
  883. }
  884. /* Object Ordering by Field
  885. ----------------------------------------------------------------------------------------------------------------------*/
  886. function parseFieldSpecs(input) {
  887. var specs = [];
  888. var tokens = [];
  889. var i;
  890. var token;
  891. if (typeof input === 'string') {
  892. tokens = input.split(/\s*,\s*/);
  893. }
  894. else if (typeof input === 'function') {
  895. tokens = [input];
  896. }
  897. else if (Array.isArray(input)) {
  898. tokens = input;
  899. }
  900. for (i = 0; i < tokens.length; i++) {
  901. token = tokens[i];
  902. if (typeof token === 'string') {
  903. specs.push(token.charAt(0) === '-' ?
  904. { field: token.substring(1), order: -1 } :
  905. { field: token, order: 1 });
  906. }
  907. else if (typeof token === 'function') {
  908. specs.push({ func: token });
  909. }
  910. }
  911. return specs;
  912. }
  913. function compareByFieldSpecs(obj0, obj1, fieldSpecs) {
  914. var i;
  915. var cmp;
  916. for (i = 0; i < fieldSpecs.length; i++) {
  917. cmp = compareByFieldSpec(obj0, obj1, fieldSpecs[i]);
  918. if (cmp) {
  919. return cmp;
  920. }
  921. }
  922. return 0;
  923. }
  924. function compareByFieldSpec(obj0, obj1, fieldSpec) {
  925. if (fieldSpec.func) {
  926. return fieldSpec.func(obj0, obj1);
  927. }
  928. return flexibleCompare(obj0[fieldSpec.field], obj1[fieldSpec.field])
  929. * (fieldSpec.order || 1);
  930. }
  931. function flexibleCompare(a, b) {
  932. if (!a && !b) {
  933. return 0;
  934. }
  935. if (b == null) {
  936. return -1;
  937. }
  938. if (a == null) {
  939. return 1;
  940. }
  941. if (typeof a === 'string' || typeof b === 'string') {
  942. return String(a).localeCompare(String(b));
  943. }
  944. return a - b;
  945. }
  946. /* String Utilities
  947. ----------------------------------------------------------------------------------------------------------------------*/
  948. function capitaliseFirstLetter(str) {
  949. return str.charAt(0).toUpperCase() + str.slice(1);
  950. }
  951. function padStart(val, len) {
  952. var s = String(val);
  953. return '000'.substr(0, len - s.length) + s;
  954. }
  955. /* Number Utilities
  956. ----------------------------------------------------------------------------------------------------------------------*/
  957. function compareNumbers(a, b) {
  958. return a - b;
  959. }
  960. function isInt(n) {
  961. return n % 1 === 0;
  962. }
  963. /* Weird Utilities
  964. ----------------------------------------------------------------------------------------------------------------------*/
  965. function applyAll(functions, thisObj, args) {
  966. if (typeof functions === 'function') { // supplied a single function
  967. functions = [functions];
  968. }
  969. if (functions) {
  970. var i = void 0;
  971. var ret = void 0;
  972. for (i = 0; i < functions.length; i++) {
  973. ret = functions[i].apply(thisObj, args) || ret;
  974. }
  975. return ret;
  976. }
  977. }
  978. function firstDefined() {
  979. var args = [];
  980. for (var _i = 0; _i < arguments.length; _i++) {
  981. args[_i] = arguments[_i];
  982. }
  983. for (var i = 0; i < args.length; i++) {
  984. if (args[i] !== undefined) {
  985. return args[i];
  986. }
  987. }
  988. }
  989. // Returns a function, that, as long as it continues to be invoked, will not
  990. // be triggered. The function will be called after it stops being called for
  991. // N milliseconds. If `immediate` is passed, trigger the function on the
  992. // leading edge, instead of the trailing.
  993. // https://github.com/jashkenas/underscore/blob/1.6.0/underscore.js#L714
  994. function debounce(func, wait) {
  995. var timeout;
  996. var args;
  997. var context;
  998. var timestamp;
  999. var result;
  1000. var later = function () {
  1001. var last = new Date().valueOf() - timestamp;
  1002. if (last < wait) {
  1003. timeout = setTimeout(later, wait - last);
  1004. }
  1005. else {
  1006. timeout = null;
  1007. result = func.apply(context, args);
  1008. context = args = null;
  1009. }
  1010. };
  1011. return function () {
  1012. context = this;
  1013. args = arguments;
  1014. timestamp = new Date().valueOf();
  1015. if (!timeout) {
  1016. timeout = setTimeout(later, wait);
  1017. }
  1018. return result;
  1019. };
  1020. }
  1021. // Number and Boolean are only types that defaults or not computed for
  1022. // TODO: write more comments
  1023. function refineProps(rawProps, processors, defaults, leftoverProps) {
  1024. if (defaults === void 0) { defaults = {}; }
  1025. var refined = {};
  1026. for (var key in processors) {
  1027. var processor = processors[key];
  1028. if (rawProps[key] !== undefined) {
  1029. // found
  1030. if (processor === Function) {
  1031. refined[key] = typeof rawProps[key] === 'function' ? rawProps[key] : null;
  1032. }
  1033. else if (processor) { // a refining function?
  1034. refined[key] = processor(rawProps[key]);
  1035. }
  1036. else {
  1037. refined[key] = rawProps[key];
  1038. }
  1039. }
  1040. else if (defaults[key] !== undefined) {
  1041. // there's an explicit default
  1042. refined[key] = defaults[key];
  1043. }
  1044. else {
  1045. // must compute a default
  1046. if (processor === String) {
  1047. refined[key] = ''; // empty string is default for String
  1048. }
  1049. else if (!processor || processor === Number || processor === Boolean || processor === Function) {
  1050. refined[key] = null; // assign null for other non-custom processor funcs
  1051. }
  1052. else {
  1053. refined[key] = processor(null); // run the custom processor func
  1054. }
  1055. }
  1056. }
  1057. if (leftoverProps) {
  1058. for (var key in rawProps) {
  1059. if (processors[key] === undefined) {
  1060. leftoverProps[key] = rawProps[key];
  1061. }
  1062. }
  1063. }
  1064. return refined;
  1065. }
  1066. /* Date stuff that doesn't belong in datelib core
  1067. ----------------------------------------------------------------------------------------------------------------------*/
  1068. // given a timed range, computes an all-day range that has the same exact duration,
  1069. // but whose start time is aligned with the start of the day.
  1070. function computeAlignedDayRange(timedRange) {
  1071. var dayCnt = Math.floor(diffDays(timedRange.start, timedRange.end)) || 1;
  1072. var start = startOfDay(timedRange.start);
  1073. var end = addDays(start, dayCnt);
  1074. return { start: start, end: end };
  1075. }
  1076. // given a timed range, computes an all-day range based on how for the end date bleeds into the next day
  1077. // TODO: give nextDayThreshold a default arg
  1078. function computeVisibleDayRange(timedRange, nextDayThreshold) {
  1079. if (nextDayThreshold === void 0) { nextDayThreshold = createDuration(0); }
  1080. var startDay = null;
  1081. var endDay = null;
  1082. if (timedRange.end) {
  1083. endDay = startOfDay(timedRange.end);
  1084. var endTimeMS = timedRange.end.valueOf() - endDay.valueOf(); // # of milliseconds into `endDay`
  1085. // If the end time is actually inclusively part of the next day and is equal to or
  1086. // beyond the next day threshold, adjust the end to be the exclusive end of `endDay`.
  1087. // Otherwise, leaving it as inclusive will cause it to exclude `endDay`.
  1088. if (endTimeMS && endTimeMS >= asRoughMs(nextDayThreshold)) {
  1089. endDay = addDays(endDay, 1);
  1090. }
  1091. }
  1092. if (timedRange.start) {
  1093. startDay = startOfDay(timedRange.start); // the beginning of the day the range starts
  1094. // If end is within `startDay` but not past nextDayThreshold, assign the default duration of one day.
  1095. if (endDay && endDay <= startDay) {
  1096. endDay = addDays(startDay, 1);
  1097. }
  1098. }
  1099. return { start: startDay, end: endDay };
  1100. }
  1101. // spans from one day into another?
  1102. function isMultiDayRange(range) {
  1103. var visibleRange = computeVisibleDayRange(range);
  1104. return diffDays(visibleRange.start, visibleRange.end) > 1;
  1105. }
  1106. function diffDates(date0, date1, dateEnv, largeUnit) {
  1107. if (largeUnit === 'year') {
  1108. return createDuration(dateEnv.diffWholeYears(date0, date1), 'year');
  1109. }
  1110. else if (largeUnit === 'month') {
  1111. return createDuration(dateEnv.diffWholeMonths(date0, date1), 'month');
  1112. }
  1113. else {
  1114. return diffDayAndTime(date0, date1); // returns a duration
  1115. }
  1116. }
  1117. /*! *****************************************************************************
  1118. Copyright (c) Microsoft Corporation. All rights reserved.
  1119. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  1120. this file except in compliance with the License. You may obtain a copy of the
  1121. License at http://www.apache.org/licenses/LICENSE-2.0
  1122. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  1123. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  1124. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  1125. MERCHANTABLITY OR NON-INFRINGEMENT.
  1126. See the Apache Version 2.0 License for specific language governing permissions
  1127. and limitations under the License.
  1128. ***************************************************************************** */
  1129. /* global Reflect, Promise */
  1130. var extendStatics = function(d, b) {
  1131. extendStatics = Object.setPrototypeOf ||
  1132. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1133. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1134. return extendStatics(d, b);
  1135. };
  1136. function __extends(d, b) {
  1137. extendStatics(d, b);
  1138. function __() { this.constructor = d; }
  1139. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1140. }
  1141. var __assign = function() {
  1142. __assign = Object.assign || function __assign(t) {
  1143. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1144. s = arguments[i];
  1145. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  1146. }
  1147. return t;
  1148. };
  1149. return __assign.apply(this, arguments);
  1150. };
  1151. function parseRecurring(eventInput, allDayDefault, dateEnv, recurringTypes, leftovers) {
  1152. for (var i = 0; i < recurringTypes.length; i++) {
  1153. var localLeftovers = {};
  1154. var parsed = recurringTypes[i].parse(eventInput, localLeftovers, dateEnv);
  1155. if (parsed) {
  1156. var allDay = localLeftovers.allDay;
  1157. delete localLeftovers.allDay; // remove from leftovers
  1158. if (allDay == null) {
  1159. allDay = allDayDefault;
  1160. if (allDay == null) {
  1161. allDay = parsed.allDayGuess;
  1162. if (allDay == null) {
  1163. allDay = false;
  1164. }
  1165. }
  1166. }
  1167. __assign(leftovers, localLeftovers);
  1168. return {
  1169. allDay: allDay,
  1170. duration: parsed.duration,
  1171. typeData: parsed.typeData,
  1172. typeId: i
  1173. };
  1174. }
  1175. }
  1176. return null;
  1177. }
  1178. /*
  1179. Event MUST have a recurringDef
  1180. */
  1181. function expandRecurringRanges(eventDef, duration, framingRange, dateEnv, recurringTypes) {
  1182. var typeDef = recurringTypes[eventDef.recurringDef.typeId];
  1183. var markers = typeDef.expand(eventDef.recurringDef.typeData, {
  1184. start: dateEnv.subtract(framingRange.start, duration),
  1185. end: framingRange.end
  1186. }, dateEnv);
  1187. // the recurrence plugins don't guarantee that all-day events are start-of-day, so we have to
  1188. if (eventDef.allDay) {
  1189. markers = markers.map(startOfDay);
  1190. }
  1191. return markers;
  1192. }
  1193. var hasOwnProperty = Object.prototype.hasOwnProperty;
  1194. // Merges an array of objects into a single object.
  1195. // The second argument allows for an array of property names who's object values will be merged together.
  1196. function mergeProps(propObjs, complexProps) {
  1197. var dest = {};
  1198. var i;
  1199. var name;
  1200. var complexObjs;
  1201. var j;
  1202. var val;
  1203. var props;
  1204. if (complexProps) {
  1205. for (i = 0; i < complexProps.length; i++) {
  1206. name = complexProps[i];
  1207. complexObjs = [];
  1208. // collect the trailing object values, stopping when a non-object is discovered
  1209. for (j = propObjs.length - 1; j >= 0; j--) {
  1210. val = propObjs[j][name];
  1211. if (typeof val === 'object' && val) { // non-null object
  1212. complexObjs.unshift(val);
  1213. }
  1214. else if (val !== undefined) {
  1215. dest[name] = val; // if there were no objects, this value will be used
  1216. break;
  1217. }
  1218. }
  1219. // if the trailing values were objects, use the merged value
  1220. if (complexObjs.length) {
  1221. dest[name] = mergeProps(complexObjs);
  1222. }
  1223. }
  1224. }
  1225. // copy values into the destination, going from last to first
  1226. for (i = propObjs.length - 1; i >= 0; i--) {
  1227. props = propObjs[i];
  1228. for (name in props) {
  1229. if (!(name in dest)) { // if already assigned by previous props or complex props, don't reassign
  1230. dest[name] = props[name];
  1231. }
  1232. }
  1233. }
  1234. return dest;
  1235. }
  1236. function filterHash(hash, func) {
  1237. var filtered = {};
  1238. for (var key in hash) {
  1239. if (func(hash[key], key)) {
  1240. filtered[key] = hash[key];
  1241. }
  1242. }
  1243. return filtered;
  1244. }
  1245. function mapHash(hash, func) {
  1246. var newHash = {};
  1247. for (var key in hash) {
  1248. newHash[key] = func(hash[key], key);
  1249. }
  1250. return newHash;
  1251. }
  1252. function arrayToHash(a) {
  1253. var hash = {};
  1254. for (var _i = 0, a_1 = a; _i < a_1.length; _i++) {
  1255. var item = a_1[_i];
  1256. hash[item] = true;
  1257. }
  1258. return hash;
  1259. }
  1260. function hashValuesToArray(obj) {
  1261. var a = [];
  1262. for (var key in obj) {
  1263. a.push(obj[key]);
  1264. }
  1265. return a;
  1266. }
  1267. function isPropsEqual(obj0, obj1) {
  1268. for (var key in obj0) {
  1269. if (hasOwnProperty.call(obj0, key)) {
  1270. if (!(key in obj1)) {
  1271. return false;
  1272. }
  1273. }
  1274. }
  1275. for (var key in obj1) {
  1276. if (hasOwnProperty.call(obj1, key)) {
  1277. if (obj0[key] !== obj1[key]) {
  1278. return false;
  1279. }
  1280. }
  1281. }
  1282. return true;
  1283. }
  1284. function parseEvents(rawEvents, sourceId, calendar, allowOpenRange) {
  1285. var eventStore = createEmptyEventStore();
  1286. for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
  1287. var rawEvent = rawEvents_1[_i];
  1288. var tuple = parseEvent(rawEvent, sourceId, calendar, allowOpenRange);
  1289. if (tuple) {
  1290. eventTupleToStore(tuple, eventStore);
  1291. }
  1292. }
  1293. return eventStore;
  1294. }
  1295. function eventTupleToStore(tuple, eventStore) {
  1296. if (eventStore === void 0) { eventStore = createEmptyEventStore(); }
  1297. eventStore.defs[tuple.def.defId] = tuple.def;
  1298. if (tuple.instance) {
  1299. eventStore.instances[tuple.instance.instanceId] = tuple.instance;
  1300. }
  1301. return eventStore;
  1302. }
  1303. function expandRecurring(eventStore, framingRange, calendar) {
  1304. var dateEnv = calendar.dateEnv;
  1305. var defs = eventStore.defs, instances = eventStore.instances;
  1306. // remove existing recurring instances
  1307. instances = filterHash(instances, function (instance) {
  1308. return !defs[instance.defId].recurringDef;
  1309. });
  1310. for (var defId in defs) {
  1311. var def = defs[defId];
  1312. if (def.recurringDef) {
  1313. var duration = def.recurringDef.duration;
  1314. if (!duration) {
  1315. duration = def.allDay ?
  1316. calendar.defaultAllDayEventDuration :
  1317. calendar.defaultTimedEventDuration;
  1318. }
  1319. var starts = expandRecurringRanges(def, duration, framingRange, calendar.dateEnv, calendar.pluginSystem.hooks.recurringTypes);
  1320. for (var _i = 0, starts_1 = starts; _i < starts_1.length; _i++) {
  1321. var start = starts_1[_i];
  1322. var instance = createEventInstance(defId, {
  1323. start: start,
  1324. end: dateEnv.add(start, duration)
  1325. });
  1326. instances[instance.instanceId] = instance;
  1327. }
  1328. }
  1329. }
  1330. return { defs: defs, instances: instances };
  1331. }
  1332. // retrieves events that have the same groupId as the instance specified by `instanceId`
  1333. // or they are the same as the instance.
  1334. // why might instanceId not be in the store? an event from another calendar?
  1335. function getRelevantEvents(eventStore, instanceId) {
  1336. var instance = eventStore.instances[instanceId];
  1337. if (instance) {
  1338. var def_1 = eventStore.defs[instance.defId];
  1339. // get events/instances with same group
  1340. var newStore = filterEventStoreDefs(eventStore, function (lookDef) {
  1341. return isEventDefsGrouped(def_1, lookDef);
  1342. });
  1343. // add the original
  1344. // TODO: wish we could use eventTupleToStore or something like it
  1345. newStore.defs[def_1.defId] = def_1;
  1346. newStore.instances[instance.instanceId] = instance;
  1347. return newStore;
  1348. }
  1349. return createEmptyEventStore();
  1350. }
  1351. function isEventDefsGrouped(def0, def1) {
  1352. return Boolean(def0.groupId && def0.groupId === def1.groupId);
  1353. }
  1354. function transformRawEvents(rawEvents, eventSource, calendar) {
  1355. var calEachTransform = calendar.opt('eventDataTransform');
  1356. var sourceEachTransform = eventSource ? eventSource.eventDataTransform : null;
  1357. if (sourceEachTransform) {
  1358. rawEvents = transformEachRawEvent(rawEvents, sourceEachTransform);
  1359. }
  1360. if (calEachTransform) {
  1361. rawEvents = transformEachRawEvent(rawEvents, calEachTransform);
  1362. }
  1363. return rawEvents;
  1364. }
  1365. function transformEachRawEvent(rawEvents, func) {
  1366. var refinedEvents;
  1367. if (!func) {
  1368. refinedEvents = rawEvents;
  1369. }
  1370. else {
  1371. refinedEvents = [];
  1372. for (var _i = 0, rawEvents_2 = rawEvents; _i < rawEvents_2.length; _i++) {
  1373. var rawEvent = rawEvents_2[_i];
  1374. var refinedEvent = func(rawEvent);
  1375. if (refinedEvent) {
  1376. refinedEvents.push(refinedEvent);
  1377. }
  1378. else if (refinedEvent == null) {
  1379. refinedEvents.push(rawEvent);
  1380. } // if a different falsy value, do nothing
  1381. }
  1382. }
  1383. return refinedEvents;
  1384. }
  1385. function createEmptyEventStore() {
  1386. return { defs: {}, instances: {} };
  1387. }
  1388. function mergeEventStores(store0, store1) {
  1389. return {
  1390. defs: __assign({}, store0.defs, store1.defs),
  1391. instances: __assign({}, store0.instances, store1.instances)
  1392. };
  1393. }
  1394. function filterEventStoreDefs(eventStore, filterFunc) {
  1395. var defs = filterHash(eventStore.defs, filterFunc);
  1396. var instances = filterHash(eventStore.instances, function (instance) {
  1397. return defs[instance.defId]; // still exists?
  1398. });
  1399. return { defs: defs, instances: instances };
  1400. }
  1401. function parseRange(input, dateEnv) {
  1402. var start = null;
  1403. var end = null;
  1404. if (input.start) {
  1405. start = dateEnv.createMarker(input.start);
  1406. }
  1407. if (input.end) {
  1408. end = dateEnv.createMarker(input.end);
  1409. }
  1410. if (!start && !end) {
  1411. return null;
  1412. }
  1413. if (start && end && end < start) {
  1414. return null;
  1415. }
  1416. return { start: start, end: end };
  1417. }
  1418. // SIDE-EFFECT: will mutate ranges.
  1419. // Will return a new array result.
  1420. function invertRanges(ranges, constraintRange) {
  1421. var invertedRanges = [];
  1422. var start = constraintRange.start; // the end of the previous range. the start of the new range
  1423. var i;
  1424. var dateRange;
  1425. // ranges need to be in order. required for our date-walking algorithm
  1426. ranges.sort(compareRanges);
  1427. for (i = 0; i < ranges.length; i++) {
  1428. dateRange = ranges[i];
  1429. // add the span of time before the event (if there is any)
  1430. if (dateRange.start > start) { // compare millisecond time (skip any ambig logic)
  1431. invertedRanges.push({ start: start, end: dateRange.start });
  1432. }
  1433. if (dateRange.end > start) {
  1434. start = dateRange.end;
  1435. }
  1436. }
  1437. // add the span of time after the last event (if there is any)
  1438. if (start < constraintRange.end) { // compare millisecond time (skip any ambig logic)
  1439. invertedRanges.push({ start: start, end: constraintRange.end });
  1440. }
  1441. return invertedRanges;
  1442. }
  1443. function compareRanges(range0, range1) {
  1444. return range0.start.valueOf() - range1.start.valueOf(); // earlier ranges go first
  1445. }
  1446. function intersectRanges(range0, range1) {
  1447. var start = range0.start;
  1448. var end = range0.end;
  1449. var newRange = null;
  1450. if (range1.start !== null) {
  1451. if (start === null) {
  1452. start = range1.start;
  1453. }
  1454. else {
  1455. start = new Date(Math.max(start.valueOf(), range1.start.valueOf()));
  1456. }
  1457. }
  1458. if (range1.end != null) {
  1459. if (end === null) {
  1460. end = range1.end;
  1461. }
  1462. else {
  1463. end = new Date(Math.min(end.valueOf(), range1.end.valueOf()));
  1464. }
  1465. }
  1466. if (start === null || end === null || start < end) {
  1467. newRange = { start: start, end: end };
  1468. }
  1469. return newRange;
  1470. }
  1471. function rangesEqual(range0, range1) {
  1472. return (range0.start === null ? null : range0.start.valueOf()) === (range1.start === null ? null : range1.start.valueOf()) &&
  1473. (range0.end === null ? null : range0.end.valueOf()) === (range1.end === null ? null : range1.end.valueOf());
  1474. }
  1475. function rangesIntersect(range0, range1) {
  1476. return (range0.end === null || range1.start === null || range0.end > range1.start) &&
  1477. (range0.start === null || range1.end === null || range0.start < range1.end);
  1478. }
  1479. function rangeContainsRange(outerRange, innerRange) {
  1480. return (outerRange.start === null || (innerRange.start !== null && innerRange.start >= outerRange.start)) &&
  1481. (outerRange.end === null || (innerRange.end !== null && innerRange.end <= outerRange.end));
  1482. }
  1483. function rangeContainsMarker(range, date) {
  1484. return (range.start === null || date >= range.start) &&
  1485. (range.end === null || date < range.end);
  1486. }
  1487. // If the given date is not within the given range, move it inside.
  1488. // (If it's past the end, make it one millisecond before the end).
  1489. function constrainMarkerToRange(date, range) {
  1490. if (range.start != null && date < range.start) {
  1491. return range.start;
  1492. }
  1493. if (range.end != null && date >= range.end) {
  1494. return new Date(range.end.valueOf() - 1);
  1495. }
  1496. return date;
  1497. }
  1498. function removeExact(array, exactVal) {
  1499. var removeCnt = 0;
  1500. var i = 0;
  1501. while (i < array.length) {
  1502. if (array[i] === exactVal) {
  1503. array.splice(i, 1);
  1504. removeCnt++;
  1505. }
  1506. else {
  1507. i++;
  1508. }
  1509. }
  1510. return removeCnt;
  1511. }
  1512. function isArraysEqual(a0, a1) {
  1513. var len = a0.length;
  1514. var i;
  1515. if (len !== a1.length) { // not array? or not same length?
  1516. return false;
  1517. }
  1518. for (i = 0; i < len; i++) {
  1519. if (a0[i] !== a1[i]) {
  1520. return false;
  1521. }
  1522. }
  1523. return true;
  1524. }
  1525. function memoize(workerFunc) {
  1526. var args;
  1527. var res;
  1528. return function () {
  1529. if (!args || !isArraysEqual(args, arguments)) {
  1530. args = arguments;
  1531. res = workerFunc.apply(this, arguments);
  1532. }
  1533. return res;
  1534. };
  1535. }
  1536. /*
  1537. always executes the workerFunc, but if the result is equal to the previous result,
  1538. return the previous result instead.
  1539. */
  1540. function memoizeOutput(workerFunc, equalityFunc) {
  1541. var cachedRes = null;
  1542. return function () {
  1543. var newRes = workerFunc.apply(this, arguments);
  1544. if (cachedRes === null || !(cachedRes === newRes || equalityFunc(cachedRes, newRes))) {
  1545. cachedRes = newRes;
  1546. }
  1547. return cachedRes;
  1548. };
  1549. }
  1550. var EXTENDED_SETTINGS_AND_SEVERITIES = {
  1551. week: 3,
  1552. separator: 0,
  1553. omitZeroMinute: 0,
  1554. meridiem: 0,
  1555. omitCommas: 0
  1556. };
  1557. var STANDARD_DATE_PROP_SEVERITIES = {
  1558. timeZoneName: 7,
  1559. era: 6,
  1560. year: 5,
  1561. month: 4,
  1562. day: 2,
  1563. weekday: 2,
  1564. hour: 1,
  1565. minute: 1,
  1566. second: 1
  1567. };
  1568. var MERIDIEM_RE = /\s*([ap])\.?m\.?/i; // eats up leading spaces too
  1569. var COMMA_RE = /,/g; // we need re for globalness
  1570. var MULTI_SPACE_RE = /\s+/g;
  1571. var LTR_RE = /\u200e/g; // control character
  1572. var UTC_RE = /UTC|GMT/;
  1573. var NativeFormatter = /** @class */ (function () {
  1574. function NativeFormatter(formatSettings) {
  1575. var standardDateProps = {};
  1576. var extendedSettings = {};
  1577. var severity = 0;
  1578. for (var name_1 in formatSettings) {
  1579. if (name_1 in EXTENDED_SETTINGS_AND_SEVERITIES) {
  1580. extendedSettings[name_1] = formatSettings[name_1];
  1581. severity = Math.max(EXTENDED_SETTINGS_AND_SEVERITIES[name_1], severity);
  1582. }
  1583. else {
  1584. standardDateProps[name_1] = formatSettings[name_1];
  1585. if (name_1 in STANDARD_DATE_PROP_SEVERITIES) {
  1586. severity = Math.max(STANDARD_DATE_PROP_SEVERITIES[name_1], severity);
  1587. }
  1588. }
  1589. }
  1590. this.standardDateProps = standardDateProps;
  1591. this.extendedSettings = extendedSettings;
  1592. this.severity = severity;
  1593. this.buildFormattingFunc = memoize(buildFormattingFunc);
  1594. }
  1595. NativeFormatter.prototype.format = function (date, context) {
  1596. return this.buildFormattingFunc(this.standardDateProps, this.extendedSettings, context)(date);
  1597. };
  1598. NativeFormatter.prototype.formatRange = function (start, end, context) {
  1599. var _a = this, standardDateProps = _a.standardDateProps, extendedSettings = _a.extendedSettings;
  1600. var diffSeverity = computeMarkerDiffSeverity(start.marker, end.marker, context.calendarSystem);
  1601. if (!diffSeverity) {
  1602. return this.format(start, context);
  1603. }
  1604. var biggestUnitForPartial = diffSeverity;
  1605. if (biggestUnitForPartial > 1 && // the two dates are different in a way that's larger scale than time
  1606. (standardDateProps.year === 'numeric' || standardDateProps.year === '2-digit') &&
  1607. (standardDateProps.month === 'numeric' || standardDateProps.month === '2-digit') &&
  1608. (standardDateProps.day === 'numeric' || standardDateProps.day === '2-digit')) {
  1609. biggestUnitForPartial = 1; // make it look like the dates are only different in terms of time
  1610. }
  1611. var full0 = this.format(start, context);
  1612. var full1 = this.format(end, context);
  1613. if (full0 === full1) {
  1614. return full0;
  1615. }
  1616. var partialDateProps = computePartialFormattingOptions(standardDateProps, biggestUnitForPartial);
  1617. var partialFormattingFunc = buildFormattingFunc(partialDateProps, extendedSettings, context);
  1618. var partial0 = partialFormattingFunc(start);
  1619. var partial1 = partialFormattingFunc(end);
  1620. var insertion = findCommonInsertion(full0, partial0, full1, partial1);
  1621. var separator = extendedSettings.separator || '';
  1622. if (insertion) {
  1623. return insertion.before + partial0 + separator + partial1 + insertion.after;
  1624. }
  1625. return full0 + separator + full1;
  1626. };
  1627. NativeFormatter.prototype.getLargestUnit = function () {
  1628. switch (this.severity) {
  1629. case 7:
  1630. case 6:
  1631. case 5:
  1632. return 'year';
  1633. case 4:
  1634. return 'month';
  1635. case 3:
  1636. return 'week';
  1637. default:
  1638. return 'day';
  1639. }
  1640. };
  1641. return NativeFormatter;
  1642. }());
  1643. function buildFormattingFunc(standardDateProps, extendedSettings, context) {
  1644. var standardDatePropCnt = Object.keys(standardDateProps).length;
  1645. if (standardDatePropCnt === 1 && standardDateProps.timeZoneName === 'short') {
  1646. return function (date) {
  1647. return formatTimeZoneOffset(date.timeZoneOffset);
  1648. };
  1649. }
  1650. if (standardDatePropCnt === 0 && extendedSettings.week) {
  1651. return function (date) {
  1652. return formatWeekNumber(context.computeWeekNumber(date.marker), context.weekLabel, context.locale, extendedSettings.week);
  1653. };
  1654. }
  1655. return buildNativeFormattingFunc(standardDateProps, extendedSettings, context);
  1656. }
  1657. function buildNativeFormattingFunc(standardDateProps, extendedSettings, context) {
  1658. standardDateProps = __assign({}, standardDateProps); // copy
  1659. extendedSettings = __assign({}, extendedSettings); // copy
  1660. sanitizeSettings(standardDateProps, extendedSettings);
  1661. standardDateProps.timeZone = 'UTC'; // we leverage the only guaranteed timeZone for our UTC markers
  1662. var normalFormat = new Intl.DateTimeFormat(context.locale.codes, standardDateProps);
  1663. var zeroFormat; // needed?
  1664. if (extendedSettings.omitZeroMinute) {
  1665. var zeroProps = __assign({}, standardDateProps);
  1666. delete zeroProps.minute; // seconds and ms were already considered in sanitizeSettings
  1667. zeroFormat = new Intl.DateTimeFormat(context.locale.codes, zeroProps);
  1668. }
  1669. return function (date) {
  1670. var marker = date.marker;
  1671. var format;
  1672. if (zeroFormat && !marker.getUTCMinutes()) {
  1673. format = zeroFormat;
  1674. }
  1675. else {
  1676. format = normalFormat;
  1677. }
  1678. var s = format.format(marker);
  1679. return postProcess(s, date, standardDateProps, extendedSettings, context);
  1680. };
  1681. }
  1682. function sanitizeSettings(standardDateProps, extendedSettings) {
  1683. // deal with a browser inconsistency where formatting the timezone
  1684. // requires that the hour/minute be present.
  1685. if (standardDateProps.timeZoneName) {
  1686. if (!standardDateProps.hour) {
  1687. standardDateProps.hour = '2-digit';
  1688. }
  1689. if (!standardDateProps.minute) {
  1690. standardDateProps.minute = '2-digit';
  1691. }
  1692. }
  1693. // only support short timezone names
  1694. if (standardDateProps.timeZoneName === 'long') {
  1695. standardDateProps.timeZoneName = 'short';
  1696. }
  1697. // if requesting to display seconds, MUST display minutes
  1698. if (extendedSettings.omitZeroMinute && (standardDateProps.second || standardDateProps.millisecond)) {
  1699. delete extendedSettings.omitZeroMinute;
  1700. }
  1701. }
  1702. function postProcess(s, date, standardDateProps, extendedSettings, context) {
  1703. s = s.replace(LTR_RE, ''); // remove left-to-right control chars. do first. good for other regexes
  1704. if (standardDateProps.timeZoneName === 'short') {
  1705. s = injectTzoStr(s, (context.timeZone === 'UTC' || date.timeZoneOffset == null) ?
  1706. 'UTC' : // important to normalize for IE, which does "GMT"
  1707. formatTimeZoneOffset(date.timeZoneOffset));
  1708. }
  1709. if (extendedSettings.omitCommas) {
  1710. s = s.replace(COMMA_RE, '').trim();
  1711. }
  1712. if (extendedSettings.omitZeroMinute) {
  1713. s = s.replace(':00', ''); // zeroFormat doesn't always achieve this
  1714. }
  1715. // ^ do anything that might create adjacent spaces before this point,
  1716. // because MERIDIEM_RE likes to eat up loading spaces
  1717. if (extendedSettings.meridiem === false) {
  1718. s = s.replace(MERIDIEM_RE, '').trim();
  1719. }
  1720. else if (extendedSettings.meridiem === 'narrow') { // a/p
  1721. s = s.replace(MERIDIEM_RE, function (m0, m1) {
  1722. return m1.toLocaleLowerCase();
  1723. });
  1724. }
  1725. else if (extendedSettings.meridiem === 'short') { // am/pm
  1726. s = s.replace(MERIDIEM_RE, function (m0, m1) {
  1727. return m1.toLocaleLowerCase() + 'm';
  1728. });
  1729. }
  1730. else if (extendedSettings.meridiem === 'lowercase') { // other meridiem transformers already converted to lowercase
  1731. s = s.replace(MERIDIEM_RE, function (m0) {
  1732. return m0.toLocaleLowerCase();
  1733. });
  1734. }
  1735. s = s.replace(MULTI_SPACE_RE, ' ');
  1736. s = s.trim();
  1737. return s;
  1738. }
  1739. function injectTzoStr(s, tzoStr) {
  1740. var replaced = false;
  1741. s = s.replace(UTC_RE, function () {
  1742. replaced = true;
  1743. return tzoStr;
  1744. });
  1745. // IE11 doesn't include UTC/GMT in the original string, so append to end
  1746. if (!replaced) {
  1747. s += ' ' + tzoStr;
  1748. }
  1749. return s;
  1750. }
  1751. function formatWeekNumber(num, weekLabel, locale, display) {
  1752. var parts = [];
  1753. if (display === 'narrow') {
  1754. parts.push(weekLabel);
  1755. }
  1756. else if (display === 'short') {
  1757. parts.push(weekLabel, ' ');
  1758. }
  1759. // otherwise, considered 'numeric'
  1760. parts.push(locale.simpleNumberFormat.format(num));
  1761. if (locale.options.isRtl) { // TODO: use control characters instead?
  1762. parts.reverse();
  1763. }
  1764. return parts.join('');
  1765. }
  1766. // Range Formatting Utils
  1767. // 0 = exactly the same
  1768. // 1 = different by time
  1769. // and bigger
  1770. function computeMarkerDiffSeverity(d0, d1, ca) {
  1771. if (ca.getMarkerYear(d0) !== ca.getMarkerYear(d1)) {
  1772. return 5;
  1773. }
  1774. if (ca.getMarkerMonth(d0) !== ca.getMarkerMonth(d1)) {
  1775. return 4;
  1776. }
  1777. if (ca.getMarkerDay(d0) !== ca.getMarkerDay(d1)) {
  1778. return 2;
  1779. }
  1780. if (timeAsMs(d0) !== timeAsMs(d1)) {
  1781. return 1;
  1782. }
  1783. return 0;
  1784. }
  1785. function computePartialFormattingOptions(options, biggestUnit) {
  1786. var partialOptions = {};
  1787. for (var name_2 in options) {
  1788. if (!(name_2 in STANDARD_DATE_PROP_SEVERITIES) || // not a date part prop (like timeZone)
  1789. STANDARD_DATE_PROP_SEVERITIES[name_2] <= biggestUnit) {
  1790. partialOptions[name_2] = options[name_2];
  1791. }
  1792. }
  1793. return partialOptions;
  1794. }
  1795. function findCommonInsertion(full0, partial0, full1, partial1) {
  1796. var i0 = 0;
  1797. while (i0 < full0.length) {
  1798. var found0 = full0.indexOf(partial0, i0);
  1799. if (found0 === -1) {
  1800. break;
  1801. }
  1802. var before0 = full0.substr(0, found0);
  1803. i0 = found0 + partial0.length;
  1804. var after0 = full0.substr(i0);
  1805. var i1 = 0;
  1806. while (i1 < full1.length) {
  1807. var found1 = full1.indexOf(partial1, i1);
  1808. if (found1 === -1) {
  1809. break;
  1810. }
  1811. var before1 = full1.substr(0, found1);
  1812. i1 = found1 + partial1.length;
  1813. var after1 = full1.substr(i1);
  1814. if (before0 === before1 && after0 === after1) {
  1815. return {
  1816. before: before0,
  1817. after: after0
  1818. };
  1819. }
  1820. }
  1821. }
  1822. return null;
  1823. }
  1824. /*
  1825. TODO: fix the terminology of "formatter" vs "formatting func"
  1826. */
  1827. /*
  1828. At the time of instantiation, this object does not know which cmd-formatting system it will use.
  1829. It receives this at the time of formatting, as a setting.
  1830. */
  1831. var CmdFormatter = /** @class */ (function () {
  1832. function CmdFormatter(cmdStr, separator) {
  1833. this.cmdStr = cmdStr;
  1834. this.separator = separator;
  1835. }
  1836. CmdFormatter.prototype.format = function (date, context) {
  1837. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(date, null, context, this.separator));
  1838. };
  1839. CmdFormatter.prototype.formatRange = function (start, end, context) {
  1840. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(start, end, context, this.separator));
  1841. };
  1842. return CmdFormatter;
  1843. }());
  1844. var FuncFormatter = /** @class */ (function () {
  1845. function FuncFormatter(func) {
  1846. this.func = func;
  1847. }
  1848. FuncFormatter.prototype.format = function (date, context) {
  1849. return this.func(createVerboseFormattingArg(date, null, context));
  1850. };
  1851. FuncFormatter.prototype.formatRange = function (start, end, context) {
  1852. return this.func(createVerboseFormattingArg(start, end, context));
  1853. };
  1854. return FuncFormatter;
  1855. }());
  1856. // Formatter Object Creation
  1857. function createFormatter(input, defaultSeparator) {
  1858. if (typeof input === 'object' && input) { // non-null object
  1859. if (typeof defaultSeparator === 'string') {
  1860. input = __assign({ separator: defaultSeparator }, input);
  1861. }
  1862. return new NativeFormatter(input);
  1863. }
  1864. else if (typeof input === 'string') {
  1865. return new CmdFormatter(input, defaultSeparator);
  1866. }
  1867. else if (typeof input === 'function') {
  1868. return new FuncFormatter(input);
  1869. }
  1870. }
  1871. // String Utils
  1872. // timeZoneOffset is in minutes
  1873. function buildIsoString(marker, timeZoneOffset, stripZeroTime) {
  1874. if (stripZeroTime === void 0) { stripZeroTime = false; }
  1875. var s = marker.toISOString();
  1876. s = s.replace('.000', '');
  1877. if (stripZeroTime) {
  1878. s = s.replace('T00:00:00Z', '');
  1879. }
  1880. if (s.length > 10) { // time part wasn't stripped, can add timezone info
  1881. if (timeZoneOffset == null) {
  1882. s = s.replace('Z', '');
  1883. }
  1884. else if (timeZoneOffset !== 0) {
  1885. s = s.replace('Z', formatTimeZoneOffset(timeZoneOffset, true));
  1886. }
  1887. // otherwise, its UTC-0 and we want to keep the Z
  1888. }
  1889. return s;
  1890. }
  1891. function formatIsoTimeString(marker) {
  1892. return padStart(marker.getUTCHours(), 2) + ':' +
  1893. padStart(marker.getUTCMinutes(), 2) + ':' +
  1894. padStart(marker.getUTCSeconds(), 2);
  1895. }
  1896. function formatTimeZoneOffset(minutes, doIso) {
  1897. if (doIso === void 0) { doIso = false; }
  1898. var sign = minutes < 0 ? '-' : '+';
  1899. var abs = Math.abs(minutes);
  1900. var hours = Math.floor(abs / 60);
  1901. var mins = Math.round(abs % 60);
  1902. if (doIso) {
  1903. return sign + padStart(hours, 2) + ':' + padStart(mins, 2);
  1904. }
  1905. else {
  1906. return 'GMT' + sign + hours + (mins ? ':' + padStart(mins, 2) : '');
  1907. }
  1908. }
  1909. // Arg Utils
  1910. function createVerboseFormattingArg(start, end, context, separator) {
  1911. var startInfo = expandZonedMarker(start, context.calendarSystem);
  1912. var endInfo = end ? expandZonedMarker(end, context.calendarSystem) : null;
  1913. return {
  1914. date: startInfo,
  1915. start: startInfo,
  1916. end: endInfo,
  1917. timeZone: context.timeZone,
  1918. localeCodes: context.locale.codes,
  1919. separator: separator
  1920. };
  1921. }
  1922. function expandZonedMarker(dateInfo, calendarSystem) {
  1923. var a = calendarSystem.markerToArray(dateInfo.marker);
  1924. return {
  1925. marker: dateInfo.marker,
  1926. timeZoneOffset: dateInfo.timeZoneOffset,
  1927. array: a,
  1928. year: a[0],
  1929. month: a[1],
  1930. day: a[2],
  1931. hour: a[3],
  1932. minute: a[4],
  1933. second: a[5],
  1934. millisecond: a[6]
  1935. };
  1936. }
  1937. var EventSourceApi = /** @class */ (function () {
  1938. function EventSourceApi(calendar, internalEventSource) {
  1939. this.calendar = calendar;
  1940. this.internalEventSource = internalEventSource;
  1941. }
  1942. EventSourceApi.prototype.remove = function () {
  1943. this.calendar.dispatch({
  1944. type: 'REMOVE_EVENT_SOURCE',
  1945. sourceId: this.internalEventSource.sourceId
  1946. });
  1947. };
  1948. EventSourceApi.prototype.refetch = function () {
  1949. this.calendar.dispatch({
  1950. type: 'FETCH_EVENT_SOURCES',
  1951. sourceIds: [this.internalEventSource.sourceId]
  1952. });
  1953. };
  1954. Object.defineProperty(EventSourceApi.prototype, "id", {
  1955. get: function () {
  1956. return this.internalEventSource.publicId;
  1957. },
  1958. enumerable: true,
  1959. configurable: true
  1960. });
  1961. Object.defineProperty(EventSourceApi.prototype, "url", {
  1962. // only relevant to json-feed event sources
  1963. get: function () {
  1964. return this.internalEventSource.meta.url;
  1965. },
  1966. enumerable: true,
  1967. configurable: true
  1968. });
  1969. return EventSourceApi;
  1970. }());
  1971. var EventApi = /** @class */ (function () {
  1972. function EventApi(calendar, def, instance) {
  1973. this._calendar = calendar;
  1974. this._def = def;
  1975. this._instance = instance || null;
  1976. }
  1977. /*
  1978. TODO: make event struct more responsible for this
  1979. */
  1980. EventApi.prototype.setProp = function (name, val) {
  1981. var _a, _b;
  1982. if (name in DATE_PROPS) ;
  1983. else if (name in NON_DATE_PROPS) {
  1984. if (typeof NON_DATE_PROPS[name] === 'function') {
  1985. val = NON_DATE_PROPS[name](val);
  1986. }
  1987. this.mutate({
  1988. standardProps: (_a = {}, _a[name] = val, _a)
  1989. });
  1990. }
  1991. else if (name in UNSCOPED_EVENT_UI_PROPS) {
  1992. var ui = void 0;
  1993. if (typeof UNSCOPED_EVENT_UI_PROPS[name] === 'function') {
  1994. val = UNSCOPED_EVENT_UI_PROPS[name](val);
  1995. }
  1996. if (name === 'color') {
  1997. ui = { backgroundColor: val, borderColor: val };
  1998. }
  1999. else if (name === 'editable') {
  2000. ui = { startEditable: val, durationEditable: val };
  2001. }
  2002. else {
  2003. ui = (_b = {}, _b[name] = val, _b);
  2004. }
  2005. this.mutate({
  2006. standardProps: { ui: ui }
  2007. });
  2008. }
  2009. };
  2010. EventApi.prototype.setExtendedProp = function (name, val) {
  2011. var _a;
  2012. this.mutate({
  2013. extendedProps: (_a = {}, _a[name] = val, _a)
  2014. });
  2015. };
  2016. EventApi.prototype.setStart = function (startInput, options) {
  2017. if (options === void 0) { options = {}; }
  2018. var dateEnv = this._calendar.dateEnv;
  2019. var start = dateEnv.createMarker(startInput);
  2020. if (start && this._instance) { // TODO: warning if parsed bad
  2021. var instanceRange = this._instance.range;
  2022. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity); // what if parsed bad!?
  2023. var endDelta = null;
  2024. if (options.maintainDuration) {
  2025. var origDuration = diffDates(instanceRange.start, instanceRange.end, dateEnv, options.granularity);
  2026. var newDuration = diffDates(start, instanceRange.end, dateEnv, options.granularity);
  2027. endDelta = subtractDurations(origDuration, newDuration);
  2028. }
  2029. this.mutate({ startDelta: startDelta, endDelta: endDelta });
  2030. }
  2031. };
  2032. EventApi.prototype.setEnd = function (endInput, options) {
  2033. if (options === void 0) { options = {}; }
  2034. var dateEnv = this._calendar.dateEnv;
  2035. var end;
  2036. if (endInput != null) {
  2037. end = dateEnv.createMarker(endInput);
  2038. if (!end) {
  2039. return; // TODO: warning if parsed bad
  2040. }
  2041. }
  2042. if (this._instance) {
  2043. if (end) {
  2044. var endDelta = diffDates(this._instance.range.end, end, dateEnv, options.granularity);
  2045. this.mutate({ endDelta: endDelta });
  2046. }
  2047. else {
  2048. this.mutate({ standardProps: { hasEnd: false } });
  2049. }
  2050. }
  2051. };
  2052. EventApi.prototype.setDates = function (startInput, endInput, options) {
  2053. if (options === void 0) { options = {}; }
  2054. var dateEnv = this._calendar.dateEnv;
  2055. var standardProps = { allDay: options.allDay };
  2056. var start = dateEnv.createMarker(startInput);
  2057. var end;
  2058. if (!start) {
  2059. return; // TODO: warning if parsed bad
  2060. }
  2061. if (endInput != null) {
  2062. end = dateEnv.createMarker(endInput);
  2063. if (!end) { // TODO: warning if parsed bad
  2064. return;
  2065. }
  2066. }
  2067. if (this._instance) {
  2068. var instanceRange = this._instance.range;
  2069. // when computing the diff for an event being converted to all-day,
  2070. // compute diff off of the all-day values the way event-mutation does.
  2071. if (options.allDay === true) {
  2072. instanceRange = computeAlignedDayRange(instanceRange);
  2073. }
  2074. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity);
  2075. if (end) {
  2076. var endDelta = diffDates(instanceRange.end, end, dateEnv, options.granularity);
  2077. this.mutate({ startDelta: startDelta, endDelta: endDelta, standardProps: standardProps });
  2078. }
  2079. else {
  2080. standardProps.hasEnd = false;
  2081. this.mutate({ startDelta: startDelta, standardProps: standardProps });
  2082. }
  2083. }
  2084. };
  2085. EventApi.prototype.moveStart = function (deltaInput) {
  2086. var delta = createDuration(deltaInput);
  2087. if (delta) { // TODO: warning if parsed bad
  2088. this.mutate({ startDelta: delta });
  2089. }
  2090. };
  2091. EventApi.prototype.moveEnd = function (deltaInput) {
  2092. var delta = createDuration(deltaInput);
  2093. if (delta) { // TODO: warning if parsed bad
  2094. this.mutate({ endDelta: delta });
  2095. }
  2096. };
  2097. EventApi.prototype.moveDates = function (deltaInput) {
  2098. var delta = createDuration(deltaInput);
  2099. if (delta) { // TODO: warning if parsed bad
  2100. this.mutate({ startDelta: delta, endDelta: delta });
  2101. }
  2102. };
  2103. EventApi.prototype.setAllDay = function (allDay, options) {
  2104. if (options === void 0) { options = {}; }
  2105. var standardProps = { allDay: allDay };
  2106. var maintainDuration = options.maintainDuration;
  2107. if (maintainDuration == null) {
  2108. maintainDuration = this._calendar.opt('allDayMaintainDuration');
  2109. }
  2110. if (this._def.allDay !== allDay) {
  2111. standardProps.hasEnd = maintainDuration;
  2112. }
  2113. this.mutate({ standardProps: standardProps });
  2114. };
  2115. EventApi.prototype.formatRange = function (formatInput) {
  2116. var dateEnv = this._calendar.dateEnv;
  2117. var instance = this._instance;
  2118. var formatter = createFormatter(formatInput, this._calendar.opt('defaultRangeSeparator'));
  2119. if (this._def.hasEnd) {
  2120. return dateEnv.formatRange(instance.range.start, instance.range.end, formatter, {
  2121. forcedStartTzo: instance.forcedStartTzo,
  2122. forcedEndTzo: instance.forcedEndTzo
  2123. });
  2124. }
  2125. else {
  2126. return dateEnv.format(instance.range.start, formatter, {
  2127. forcedTzo: instance.forcedStartTzo
  2128. });
  2129. }
  2130. };
  2131. EventApi.prototype.mutate = function (mutation) {
  2132. var def = this._def;
  2133. var instance = this._instance;
  2134. if (instance) {
  2135. this._calendar.dispatch({
  2136. type: 'MUTATE_EVENTS',
  2137. instanceId: instance.instanceId,
  2138. mutation: mutation,
  2139. fromApi: true
  2140. });
  2141. var eventStore = this._calendar.state.eventStore;
  2142. this._def = eventStore.defs[def.defId];
  2143. this._instance = eventStore.instances[instance.instanceId];
  2144. }
  2145. };
  2146. EventApi.prototype.remove = function () {
  2147. this._calendar.dispatch({
  2148. type: 'REMOVE_EVENT_DEF',
  2149. defId: this._def.defId
  2150. });
  2151. };
  2152. Object.defineProperty(EventApi.prototype, "source", {
  2153. get: function () {
  2154. var sourceId = this._def.sourceId;
  2155. if (sourceId) {
  2156. return new EventSourceApi(this._calendar, this._calendar.state.eventSources[sourceId]);
  2157. }
  2158. return null;
  2159. },
  2160. enumerable: true,
  2161. configurable: true
  2162. });
  2163. Object.defineProperty(EventApi.prototype, "start", {
  2164. get: function () {
  2165. return this._instance ?
  2166. this._calendar.dateEnv.toDate(this._instance.range.start) :
  2167. null;
  2168. },
  2169. enumerable: true,
  2170. configurable: true
  2171. });
  2172. Object.defineProperty(EventApi.prototype, "end", {
  2173. get: function () {
  2174. return (this._instance && this._def.hasEnd) ?
  2175. this._calendar.dateEnv.toDate(this._instance.range.end) :
  2176. null;
  2177. },
  2178. enumerable: true,
  2179. configurable: true
  2180. });
  2181. Object.defineProperty(EventApi.prototype, "id", {
  2182. // computable props that all access the def
  2183. // TODO: find a TypeScript-compatible way to do this at scale
  2184. get: function () { return this._def.publicId; },
  2185. enumerable: true,
  2186. configurable: true
  2187. });
  2188. Object.defineProperty(EventApi.prototype, "groupId", {
  2189. get: function () { return this._def.groupId; },
  2190. enumerable: true,
  2191. configurable: true
  2192. });
  2193. Object.defineProperty(EventApi.prototype, "allDay", {
  2194. get: function () { return this._def.allDay; },
  2195. enumerable: true,
  2196. configurable: true
  2197. });
  2198. Object.defineProperty(EventApi.prototype, "title", {
  2199. get: function () { return this._def.title; },
  2200. enumerable: true,
  2201. configurable: true
  2202. });
  2203. Object.defineProperty(EventApi.prototype, "url", {
  2204. get: function () { return this._def.url; },
  2205. enumerable: true,
  2206. configurable: true
  2207. });
  2208. Object.defineProperty(EventApi.prototype, "rendering", {
  2209. get: function () { return this._def.rendering; },
  2210. enumerable: true,
  2211. configurable: true
  2212. });
  2213. Object.defineProperty(EventApi.prototype, "startEditable", {
  2214. get: function () { return this._def.ui.startEditable; },
  2215. enumerable: true,
  2216. configurable: true
  2217. });
  2218. Object.defineProperty(EventApi.prototype, "durationEditable", {
  2219. get: function () { return this._def.ui.durationEditable; },
  2220. enumerable: true,
  2221. configurable: true
  2222. });
  2223. Object.defineProperty(EventApi.prototype, "constraint", {
  2224. get: function () { return this._def.ui.constraints[0] || null; },
  2225. enumerable: true,
  2226. configurable: true
  2227. });
  2228. Object.defineProperty(EventApi.prototype, "overlap", {
  2229. get: function () { return this._def.ui.overlap; },
  2230. enumerable: true,
  2231. configurable: true
  2232. });
  2233. Object.defineProperty(EventApi.prototype, "allow", {
  2234. get: function () { return this._def.ui.allows[0] || null; },
  2235. enumerable: true,
  2236. configurable: true
  2237. });
  2238. Object.defineProperty(EventApi.prototype, "backgroundColor", {
  2239. get: function () { return this._def.ui.backgroundColor; },
  2240. enumerable: true,
  2241. configurable: true
  2242. });
  2243. Object.defineProperty(EventApi.prototype, "borderColor", {
  2244. get: function () { return this._def.ui.borderColor; },
  2245. enumerable: true,
  2246. configurable: true
  2247. });
  2248. Object.defineProperty(EventApi.prototype, "textColor", {
  2249. get: function () { return this._def.ui.textColor; },
  2250. enumerable: true,
  2251. configurable: true
  2252. });
  2253. Object.defineProperty(EventApi.prototype, "classNames", {
  2254. // NOTE: user can't modify these because Object.freeze was called in event-def parsing
  2255. get: function () { return this._def.ui.classNames; },
  2256. enumerable: true,
  2257. configurable: true
  2258. });
  2259. Object.defineProperty(EventApi.prototype, "extendedProps", {
  2260. get: function () { return this._def.extendedProps; },
  2261. enumerable: true,
  2262. configurable: true
  2263. });
  2264. return EventApi;
  2265. }());
  2266. /*
  2267. Specifying nextDayThreshold signals that all-day ranges should be sliced.
  2268. */
  2269. function sliceEventStore(eventStore, eventUiBases, framingRange, nextDayThreshold) {
  2270. var inverseBgByGroupId = {};
  2271. var inverseBgByDefId = {};
  2272. var defByGroupId = {};
  2273. var bgRanges = [];
  2274. var fgRanges = [];
  2275. var eventUis = compileEventUis(eventStore.defs, eventUiBases);
  2276. for (var defId in eventStore.defs) {
  2277. var def = eventStore.defs[defId];
  2278. if (def.rendering === 'inverse-background') {
  2279. if (def.groupId) {
  2280. inverseBgByGroupId[def.groupId] = [];
  2281. if (!defByGroupId[def.groupId]) {
  2282. defByGroupId[def.groupId] = def;
  2283. }
  2284. }
  2285. else {
  2286. inverseBgByDefId[defId] = [];
  2287. }
  2288. }
  2289. }
  2290. for (var instanceId in eventStore.instances) {
  2291. var instance = eventStore.instances[instanceId];
  2292. var def = eventStore.defs[instance.defId];
  2293. var ui = eventUis[def.defId];
  2294. var origRange = instance.range;
  2295. var normalRange = (!def.allDay && nextDayThreshold) ?
  2296. computeVisibleDayRange(origRange, nextDayThreshold) :
  2297. origRange;
  2298. var slicedRange = intersectRanges(normalRange, framingRange);
  2299. if (slicedRange) {
  2300. if (def.rendering === 'inverse-background') {
  2301. if (def.groupId) {
  2302. inverseBgByGroupId[def.groupId].push(slicedRange);
  2303. }
  2304. else {
  2305. inverseBgByDefId[instance.defId].push(slicedRange);
  2306. }
  2307. }
  2308. else {
  2309. (def.rendering === 'background' ? bgRanges : fgRanges).push({
  2310. def: def,
  2311. ui: ui,
  2312. instance: instance,
  2313. range: slicedRange,
  2314. isStart: normalRange.start && normalRange.start.valueOf() === slicedRange.start.valueOf(),
  2315. isEnd: normalRange.end && normalRange.end.valueOf() === slicedRange.end.valueOf()
  2316. });
  2317. }
  2318. }
  2319. }
  2320. for (var groupId in inverseBgByGroupId) { // BY GROUP
  2321. var ranges = inverseBgByGroupId[groupId];
  2322. var invertedRanges = invertRanges(ranges, framingRange);
  2323. for (var _i = 0, invertedRanges_1 = invertedRanges; _i < invertedRanges_1.length; _i++) {
  2324. var invertedRange = invertedRanges_1[_i];
  2325. var def = defByGroupId[groupId];
  2326. var ui = eventUis[def.defId];
  2327. bgRanges.push({
  2328. def: def,
  2329. ui: ui,
  2330. instance: null,
  2331. range: invertedRange,
  2332. isStart: false,
  2333. isEnd: false
  2334. });
  2335. }
  2336. }
  2337. for (var defId in inverseBgByDefId) {
  2338. var ranges = inverseBgByDefId[defId];
  2339. var invertedRanges = invertRanges(ranges, framingRange);
  2340. for (var _a = 0, invertedRanges_2 = invertedRanges; _a < invertedRanges_2.length; _a++) {
  2341. var invertedRange = invertedRanges_2[_a];
  2342. bgRanges.push({
  2343. def: eventStore.defs[defId],
  2344. ui: eventUis[defId],
  2345. instance: null,
  2346. range: invertedRange,
  2347. isStart: false,
  2348. isEnd: false
  2349. });
  2350. }
  2351. }
  2352. return { bg: bgRanges, fg: fgRanges };
  2353. }
  2354. function hasBgRendering(def) {
  2355. return def.rendering === 'background' || def.rendering === 'inverse-background';
  2356. }
  2357. function filterSegsViaEls(view, segs, isMirror) {
  2358. if (view.hasPublicHandlers('eventRender')) {
  2359. segs = segs.filter(function (seg) {
  2360. var custom = view.publiclyTrigger('eventRender', [
  2361. {
  2362. event: new EventApi(view.calendar, seg.eventRange.def, seg.eventRange.instance),
  2363. isMirror: isMirror,
  2364. isStart: seg.isStart,
  2365. isEnd: seg.isEnd,
  2366. // TODO: include seg.range once all components consistently generate it
  2367. el: seg.el,
  2368. view: view
  2369. }
  2370. ]);
  2371. if (custom === false) { // means don't render at all
  2372. return false;
  2373. }
  2374. else if (custom && custom !== true) {
  2375. seg.el = custom;
  2376. }
  2377. return true;
  2378. });
  2379. }
  2380. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  2381. var seg = segs_1[_i];
  2382. setElSeg(seg.el, seg);
  2383. }
  2384. return segs;
  2385. }
  2386. function setElSeg(el, seg) {
  2387. el.fcSeg = seg;
  2388. }
  2389. function getElSeg(el) {
  2390. return el.fcSeg || null;
  2391. }
  2392. // event ui computation
  2393. function compileEventUis(eventDefs, eventUiBases) {
  2394. return mapHash(eventDefs, function (eventDef) {
  2395. return compileEventUi(eventDef, eventUiBases);
  2396. });
  2397. }
  2398. function compileEventUi(eventDef, eventUiBases) {
  2399. var uis = [];
  2400. if (eventUiBases['']) {
  2401. uis.push(eventUiBases['']);
  2402. }
  2403. if (eventUiBases[eventDef.defId]) {
  2404. uis.push(eventUiBases[eventDef.defId]);
  2405. }
  2406. uis.push(eventDef.ui);
  2407. return combineEventUis(uis);
  2408. }
  2409. // applies the mutation to ALL defs/instances within the event store
  2410. function applyMutationToEventStore(eventStore, eventConfigBase, mutation, calendar) {
  2411. var eventConfigs = compileEventUis(eventStore.defs, eventConfigBase);
  2412. var dest = createEmptyEventStore();
  2413. for (var defId in eventStore.defs) {
  2414. var def = eventStore.defs[defId];
  2415. dest.defs[defId] = applyMutationToEventDef(def, eventConfigs[defId], mutation, calendar.pluginSystem.hooks.eventDefMutationAppliers, calendar);
  2416. }
  2417. for (var instanceId in eventStore.instances) {
  2418. var instance = eventStore.instances[instanceId];
  2419. var def = dest.defs[instance.defId]; // important to grab the newly modified def
  2420. dest.instances[instanceId] = applyMutationToEventInstance(instance, def, eventConfigs[instance.defId], mutation, calendar);
  2421. }
  2422. return dest;
  2423. }
  2424. function applyMutationToEventDef(eventDef, eventConfig, mutation, appliers, calendar) {
  2425. var standardProps = mutation.standardProps || {};
  2426. // if hasEnd has not been specified, guess a good value based on deltas.
  2427. // if duration will change, there's no way the default duration will persist,
  2428. // and thus, we need to mark the event as having a real end
  2429. if (standardProps.hasEnd == null &&
  2430. eventConfig.durationEditable &&
  2431. willDeltasAffectDuration(eventConfig.startEditable ? mutation.startDelta : null, mutation.endDelta || null)) {
  2432. standardProps.hasEnd = true; // TODO: is this mutation okay?
  2433. }
  2434. var copy = __assign({}, eventDef, standardProps, { ui: __assign({}, eventDef.ui, standardProps.ui) });
  2435. if (mutation.extendedProps) {
  2436. copy.extendedProps = __assign({}, copy.extendedProps, mutation.extendedProps);
  2437. }
  2438. for (var _i = 0, appliers_1 = appliers; _i < appliers_1.length; _i++) {
  2439. var applier = appliers_1[_i];
  2440. applier(copy, mutation, calendar);
  2441. }
  2442. if (!copy.hasEnd && calendar.opt('forceEventDuration')) {
  2443. copy.hasEnd = true;
  2444. }
  2445. return copy;
  2446. }
  2447. function willDeltasAffectDuration(startDelta, endDelta) {
  2448. if (startDelta && !asRoughMs(startDelta)) {
  2449. startDelta = null;
  2450. }
  2451. if (endDelta && !asRoughMs(endDelta)) {
  2452. endDelta = null;
  2453. }
  2454. if (!startDelta && !endDelta) {
  2455. return false;
  2456. }
  2457. if (Boolean(startDelta) !== Boolean(endDelta)) {
  2458. return true;
  2459. }
  2460. return !durationsEqual(startDelta, endDelta);
  2461. }
  2462. function applyMutationToEventInstance(eventInstance, eventDef, // must first be modified by applyMutationToEventDef
  2463. eventConfig, mutation, calendar) {
  2464. var dateEnv = calendar.dateEnv;
  2465. var forceAllDay = mutation.standardProps && mutation.standardProps.allDay === true;
  2466. var clearEnd = mutation.standardProps && mutation.standardProps.hasEnd === false;
  2467. var copy = __assign({}, eventInstance);
  2468. if (forceAllDay) {
  2469. copy.range = computeAlignedDayRange(copy.range);
  2470. }
  2471. if (mutation.startDelta && eventConfig.startEditable) {
  2472. copy.range = {
  2473. start: dateEnv.add(copy.range.start, mutation.startDelta),
  2474. end: copy.range.end
  2475. };
  2476. }
  2477. if (clearEnd) {
  2478. copy.range = {
  2479. start: copy.range.start,
  2480. end: calendar.getDefaultEventEnd(eventDef.allDay, copy.range.start)
  2481. };
  2482. }
  2483. else if (mutation.endDelta &&
  2484. (eventConfig.durationEditable ||
  2485. !willDeltasAffectDuration(// TODO: nonDRY logic above
  2486. eventConfig.startEditable ? mutation.startDelta : null, mutation.endDelta))) {
  2487. copy.range = {
  2488. start: copy.range.start,
  2489. end: dateEnv.add(copy.range.end, mutation.endDelta)
  2490. };
  2491. }
  2492. // in case event was all-day but the supplied deltas were not
  2493. // better util for this?
  2494. if (eventDef.allDay) {
  2495. copy.range = {
  2496. start: startOfDay(copy.range.start),
  2497. end: startOfDay(copy.range.end)
  2498. };
  2499. }
  2500. // handle invalid durations
  2501. if (copy.range.end < copy.range.start) {
  2502. copy.range.end = calendar.getDefaultEventEnd(eventDef.allDay, copy.range.start);
  2503. }
  2504. return copy;
  2505. }
  2506. function reduceEventStore (eventStore, action, eventSources, dateProfile, calendar) {
  2507. switch (action.type) {
  2508. case 'RECEIVE_EVENTS': // raw
  2509. return receiveRawEvents(eventStore, eventSources[action.sourceId], action.fetchId, action.fetchRange, action.rawEvents, calendar);
  2510. case 'ADD_EVENTS': // already parsed, but not expanded
  2511. return addEvent(eventStore, action.eventStore, // new ones
  2512. dateProfile ? dateProfile.activeRange : null, calendar);
  2513. case 'MERGE_EVENTS': // already parsed and expanded
  2514. return mergeEventStores(eventStore, action.eventStore);
  2515. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  2516. case 'NEXT':
  2517. case 'SET_DATE':
  2518. case 'SET_VIEW_TYPE':
  2519. if (dateProfile) {
  2520. return expandRecurring(eventStore, dateProfile.activeRange, calendar);
  2521. }
  2522. else {
  2523. return eventStore;
  2524. }
  2525. case 'CHANGE_TIMEZONE':
  2526. return rezoneDates(eventStore, action.oldDateEnv, calendar.dateEnv);
  2527. case 'MUTATE_EVENTS':
  2528. return applyMutationToRelated(eventStore, action.instanceId, action.mutation, action.fromApi, calendar);
  2529. case 'REMOVE_EVENT_INSTANCES':
  2530. return excludeInstances(eventStore, action.instances);
  2531. case 'REMOVE_EVENT_DEF':
  2532. return filterEventStoreDefs(eventStore, function (eventDef) {
  2533. return eventDef.defId !== action.defId;
  2534. });
  2535. case 'REMOVE_EVENT_SOURCE':
  2536. return excludeEventsBySourceId(eventStore, action.sourceId);
  2537. case 'REMOVE_ALL_EVENT_SOURCES':
  2538. return filterEventStoreDefs(eventStore, function (eventDef) {
  2539. return !eventDef.sourceId; // only keep events with no source id
  2540. });
  2541. case 'REMOVE_ALL_EVENTS':
  2542. return createEmptyEventStore();
  2543. case 'RESET_EVENTS':
  2544. return {
  2545. defs: eventStore.defs,
  2546. instances: eventStore.instances
  2547. };
  2548. default:
  2549. return eventStore;
  2550. }
  2551. }
  2552. function receiveRawEvents(eventStore, eventSource, fetchId, fetchRange, rawEvents, calendar) {
  2553. if (eventSource && // not already removed
  2554. fetchId === eventSource.latestFetchId // TODO: wish this logic was always in event-sources
  2555. ) {
  2556. var subset = parseEvents(transformRawEvents(rawEvents, eventSource, calendar), eventSource.sourceId, calendar);
  2557. if (fetchRange) {
  2558. subset = expandRecurring(subset, fetchRange, calendar);
  2559. }
  2560. return mergeEventStores(excludeEventsBySourceId(eventStore, eventSource.sourceId), subset);
  2561. }
  2562. return eventStore;
  2563. }
  2564. function addEvent(eventStore, subset, expandRange, calendar) {
  2565. if (expandRange) {
  2566. subset = expandRecurring(subset, expandRange, calendar);
  2567. }
  2568. return mergeEventStores(eventStore, subset);
  2569. }
  2570. function rezoneDates(eventStore, oldDateEnv, newDateEnv) {
  2571. var defs = eventStore.defs;
  2572. var instances = mapHash(eventStore.instances, function (instance) {
  2573. var def = defs[instance.defId];
  2574. if (def.allDay || def.recurringDef) {
  2575. return instance; // isn't dependent on timezone
  2576. }
  2577. else {
  2578. return __assign({}, instance, { range: {
  2579. start: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.start, instance.forcedStartTzo)),
  2580. end: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.end, instance.forcedEndTzo))
  2581. }, forcedStartTzo: newDateEnv.canComputeOffset ? null : instance.forcedStartTzo, forcedEndTzo: newDateEnv.canComputeOffset ? null : instance.forcedEndTzo });
  2582. }
  2583. });
  2584. return { defs: defs, instances: instances };
  2585. }
  2586. function applyMutationToRelated(eventStore, instanceId, mutation, fromApi, calendar) {
  2587. var relevant = getRelevantEvents(eventStore, instanceId);
  2588. var eventConfigBase = fromApi ?
  2589. { '': {
  2590. startEditable: true,
  2591. durationEditable: true,
  2592. constraints: [],
  2593. overlap: null,
  2594. allows: [],
  2595. backgroundColor: '',
  2596. borderColor: '',
  2597. textColor: '',
  2598. classNames: []
  2599. } } :
  2600. calendar.eventUiBases;
  2601. relevant = applyMutationToEventStore(relevant, eventConfigBase, mutation, calendar);
  2602. return mergeEventStores(eventStore, relevant);
  2603. }
  2604. function excludeEventsBySourceId(eventStore, sourceId) {
  2605. return filterEventStoreDefs(eventStore, function (eventDef) {
  2606. return eventDef.sourceId !== sourceId;
  2607. });
  2608. }
  2609. // QUESTION: why not just return instances? do a general object-property-exclusion util
  2610. function excludeInstances(eventStore, removals) {
  2611. return {
  2612. defs: eventStore.defs,
  2613. instances: filterHash(eventStore.instances, function (instance) {
  2614. return !removals[instance.instanceId];
  2615. })
  2616. };
  2617. }
  2618. // high-level segmenting-aware tester functions
  2619. // ------------------------------------------------------------------------------------------------------------------------
  2620. function isInteractionValid(interaction, calendar) {
  2621. return isNewPropsValid({ eventDrag: interaction }, calendar); // HACK: the eventDrag props is used for ALL interactions
  2622. }
  2623. function isDateSelectionValid(dateSelection, calendar) {
  2624. return isNewPropsValid({ dateSelection: dateSelection }, calendar);
  2625. }
  2626. function isNewPropsValid(newProps, calendar) {
  2627. var view = calendar.view;
  2628. var props = __assign({ businessHours: view ? view.props.businessHours : createEmptyEventStore(), dateSelection: '', eventStore: calendar.state.eventStore, eventUiBases: calendar.eventUiBases, eventSelection: '', eventDrag: null, eventResize: null }, newProps);
  2629. return (calendar.pluginSystem.hooks.isPropsValid || isPropsValid)(props, calendar);
  2630. }
  2631. function isPropsValid(state, calendar, dateSpanMeta, filterConfig) {
  2632. if (dateSpanMeta === void 0) { dateSpanMeta = {}; }
  2633. if (state.eventDrag && !isInteractionPropsValid(state, calendar, dateSpanMeta, filterConfig)) {
  2634. return false;
  2635. }
  2636. if (state.dateSelection && !isDateSelectionPropsValid(state, calendar, dateSpanMeta, filterConfig)) {
  2637. return false;
  2638. }
  2639. return true;
  2640. }
  2641. // Moving Event Validation
  2642. // ------------------------------------------------------------------------------------------------------------------------
  2643. function isInteractionPropsValid(state, calendar, dateSpanMeta, filterConfig) {
  2644. var interaction = state.eventDrag; // HACK: the eventDrag props is used for ALL interactions
  2645. var subjectEventStore = interaction.mutatedEvents;
  2646. var subjectDefs = subjectEventStore.defs;
  2647. var subjectInstances = subjectEventStore.instances;
  2648. var subjectConfigs = compileEventUis(subjectDefs, interaction.isEvent ?
  2649. state.eventUiBases :
  2650. { '': calendar.selectionConfig } // if not a real event, validate as a selection
  2651. );
  2652. if (filterConfig) {
  2653. subjectConfigs = mapHash(subjectConfigs, filterConfig);
  2654. }
  2655. var otherEventStore = excludeInstances(state.eventStore, interaction.affectedEvents.instances); // exclude the subject events. TODO: exclude defs too?
  2656. var otherDefs = otherEventStore.defs;
  2657. var otherInstances = otherEventStore.instances;
  2658. var otherConfigs = compileEventUis(otherDefs, state.eventUiBases);
  2659. for (var subjectInstanceId in subjectInstances) {
  2660. var subjectInstance = subjectInstances[subjectInstanceId];
  2661. var subjectRange = subjectInstance.range;
  2662. var subjectConfig = subjectConfigs[subjectInstance.defId];
  2663. var subjectDef = subjectDefs[subjectInstance.defId];
  2664. // constraint
  2665. if (!allConstraintsPass(subjectConfig.constraints, subjectRange, otherEventStore, state.businessHours, calendar)) {
  2666. return false;
  2667. }
  2668. // overlap
  2669. var overlapFunc = calendar.opt('eventOverlap');
  2670. if (typeof overlapFunc !== 'function') {
  2671. overlapFunc = null;
  2672. }
  2673. for (var otherInstanceId in otherInstances) {
  2674. var otherInstance = otherInstances[otherInstanceId];
  2675. // intersect! evaluate
  2676. if (rangesIntersect(subjectRange, otherInstance.range)) {
  2677. var otherOverlap = otherConfigs[otherInstance.defId].overlap;
  2678. // consider the other event's overlap. only do this if the subject event is a "real" event
  2679. if (otherOverlap === false && interaction.isEvent) {
  2680. return false;
  2681. }
  2682. if (subjectConfig.overlap === false) {
  2683. return false;
  2684. }
  2685. if (overlapFunc && !overlapFunc(new EventApi(calendar, otherDefs[otherInstance.defId], otherInstance), // still event
  2686. new EventApi(calendar, subjectDef, subjectInstance) // moving event
  2687. )) {
  2688. return false;
  2689. }
  2690. }
  2691. }
  2692. // allow (a function)
  2693. for (var _i = 0, _a = subjectConfig.allows; _i < _a.length; _i++) {
  2694. var subjectAllow = _a[_i];
  2695. var subjectDateSpan = __assign({}, dateSpanMeta, { range: subjectInstance.range, allDay: subjectDef.allDay });
  2696. var origDef = state.eventStore.defs[subjectDef.defId];
  2697. var origInstance = state.eventStore.instances[subjectInstanceId];
  2698. var eventApi = void 0;
  2699. if (origDef) { // was previously in the calendar
  2700. eventApi = new EventApi(calendar, origDef, origInstance);
  2701. }
  2702. else { // was an external event
  2703. eventApi = new EventApi(calendar, subjectDef); // no instance, because had no dates
  2704. }
  2705. if (!subjectAllow(calendar.buildDateSpanApi(subjectDateSpan), eventApi)) {
  2706. return false;
  2707. }
  2708. }
  2709. }
  2710. return true;
  2711. }
  2712. // Date Selection Validation
  2713. // ------------------------------------------------------------------------------------------------------------------------
  2714. function isDateSelectionPropsValid(state, calendar, dateSpanMeta, filterConfig) {
  2715. var relevantEventStore = state.eventStore;
  2716. var relevantDefs = relevantEventStore.defs;
  2717. var relevantInstances = relevantEventStore.instances;
  2718. var selection = state.dateSelection;
  2719. var selectionRange = selection.range;
  2720. var selectionConfig = calendar.selectionConfig;
  2721. if (filterConfig) {
  2722. selectionConfig = filterConfig(selectionConfig);
  2723. }
  2724. // constraint
  2725. if (!allConstraintsPass(selectionConfig.constraints, selectionRange, relevantEventStore, state.businessHours, calendar)) {
  2726. return false;
  2727. }
  2728. // overlap
  2729. var overlapFunc = calendar.opt('selectOverlap');
  2730. if (typeof overlapFunc !== 'function') {
  2731. overlapFunc = null;
  2732. }
  2733. for (var relevantInstanceId in relevantInstances) {
  2734. var relevantInstance = relevantInstances[relevantInstanceId];
  2735. // intersect! evaluate
  2736. if (rangesIntersect(selectionRange, relevantInstance.range)) {
  2737. if (selectionConfig.overlap === false) {
  2738. return false;
  2739. }
  2740. if (overlapFunc && !overlapFunc(new EventApi(calendar, relevantDefs[relevantInstance.defId], relevantInstance))) {
  2741. return false;
  2742. }
  2743. }
  2744. }
  2745. // allow (a function)
  2746. for (var _i = 0, _a = selectionConfig.allows; _i < _a.length; _i++) {
  2747. var selectionAllow = _a[_i];
  2748. var fullDateSpan = __assign({}, dateSpanMeta, selection);
  2749. if (!selectionAllow(calendar.buildDateSpanApi(fullDateSpan), null)) {
  2750. return false;
  2751. }
  2752. }
  2753. return true;
  2754. }
  2755. // Constraint Utils
  2756. // ------------------------------------------------------------------------------------------------------------------------
  2757. function allConstraintsPass(constraints, subjectRange, otherEventStore, businessHoursUnexpanded, calendar) {
  2758. for (var _i = 0, constraints_1 = constraints; _i < constraints_1.length; _i++) {
  2759. var constraint = constraints_1[_i];
  2760. if (!anyRangesContainRange(constraintToRanges(constraint, subjectRange, otherEventStore, businessHoursUnexpanded, calendar), subjectRange)) {
  2761. return false;
  2762. }
  2763. }
  2764. return true;
  2765. }
  2766. function constraintToRanges(constraint, subjectRange, // for expanding a recurring constraint, or expanding business hours
  2767. otherEventStore, // for if constraint is an even group ID
  2768. businessHoursUnexpanded, // for if constraint is 'businessHours'
  2769. calendar // for expanding businesshours
  2770. ) {
  2771. if (constraint === 'businessHours') {
  2772. return eventStoreToRanges(expandRecurring(businessHoursUnexpanded, subjectRange, calendar));
  2773. }
  2774. else if (typeof constraint === 'string') { // an group ID
  2775. return eventStoreToRanges(filterEventStoreDefs(otherEventStore, function (eventDef) {
  2776. return eventDef.groupId === constraint;
  2777. }));
  2778. }
  2779. else if (typeof constraint === 'object' && constraint) { // non-null object
  2780. return eventStoreToRanges(expandRecurring(constraint, subjectRange, calendar));
  2781. }
  2782. return []; // if it's false
  2783. }
  2784. // TODO: move to event-store file?
  2785. function eventStoreToRanges(eventStore) {
  2786. var instances = eventStore.instances;
  2787. var ranges = [];
  2788. for (var instanceId in instances) {
  2789. ranges.push(instances[instanceId].range);
  2790. }
  2791. return ranges;
  2792. }
  2793. // TODO: move to geom file?
  2794. function anyRangesContainRange(outerRanges, innerRange) {
  2795. for (var _i = 0, outerRanges_1 = outerRanges; _i < outerRanges_1.length; _i++) {
  2796. var outerRange = outerRanges_1[_i];
  2797. if (rangeContainsRange(outerRange, innerRange)) {
  2798. return true;
  2799. }
  2800. }
  2801. return false;
  2802. }
  2803. // Parsing
  2804. // ------------------------------------------------------------------------------------------------------------------------
  2805. function normalizeConstraint(input, calendar) {
  2806. if (Array.isArray(input)) {
  2807. return parseEvents(input, '', calendar, true); // allowOpenRange=true
  2808. }
  2809. else if (typeof input === 'object' && input) { // non-null object
  2810. return parseEvents([input], '', calendar, true); // allowOpenRange=true
  2811. }
  2812. else if (input != null) {
  2813. return String(input);
  2814. }
  2815. else {
  2816. return null;
  2817. }
  2818. }
  2819. function htmlEscape(s) {
  2820. return (s + '').replace(/&/g, '&amp;')
  2821. .replace(/</g, '&lt;')
  2822. .replace(/>/g, '&gt;')
  2823. .replace(/'/g, '&#039;')
  2824. .replace(/"/g, '&quot;')
  2825. .replace(/\n/g, '<br />');
  2826. }
  2827. // Given a hash of CSS properties, returns a string of CSS.
  2828. // Uses property names as-is (no camel-case conversion). Will not make statements for null/undefined values.
  2829. function cssToStr(cssProps) {
  2830. var statements = [];
  2831. for (var name_1 in cssProps) {
  2832. var val = cssProps[name_1];
  2833. if (val != null && val !== '') {
  2834. statements.push(name_1 + ':' + val);
  2835. }
  2836. }
  2837. return statements.join(';');
  2838. }
  2839. // Given an object hash of HTML attribute names to values,
  2840. // generates a string that can be injected between < > in HTML
  2841. function attrsToStr(attrs) {
  2842. var parts = [];
  2843. for (var name_2 in attrs) {
  2844. var val = attrs[name_2];
  2845. if (val != null) {
  2846. parts.push(name_2 + '="' + htmlEscape(val) + '"');
  2847. }
  2848. }
  2849. return parts.join(' ');
  2850. }
  2851. function parseClassName(raw) {
  2852. if (Array.isArray(raw)) {
  2853. return raw;
  2854. }
  2855. else if (typeof raw === 'string') {
  2856. return raw.split(/\s+/);
  2857. }
  2858. else {
  2859. return [];
  2860. }
  2861. }
  2862. var UNSCOPED_EVENT_UI_PROPS = {
  2863. editable: Boolean,
  2864. startEditable: Boolean,
  2865. durationEditable: Boolean,
  2866. constraint: null,
  2867. overlap: null,
  2868. allow: null,
  2869. className: parseClassName,
  2870. classNames: parseClassName,
  2871. color: String,
  2872. backgroundColor: String,
  2873. borderColor: String,
  2874. textColor: String
  2875. };
  2876. function processUnscopedUiProps(rawProps, calendar, leftovers) {
  2877. var props = refineProps(rawProps, UNSCOPED_EVENT_UI_PROPS, {}, leftovers);
  2878. var constraint = normalizeConstraint(props.constraint, calendar);
  2879. return {
  2880. startEditable: props.startEditable != null ? props.startEditable : props.editable,
  2881. durationEditable: props.durationEditable != null ? props.durationEditable : props.editable,
  2882. constraints: constraint != null ? [constraint] : [],
  2883. overlap: props.overlap,
  2884. allows: props.allow != null ? [props.allow] : [],
  2885. backgroundColor: props.backgroundColor || props.color,
  2886. borderColor: props.borderColor || props.color,
  2887. textColor: props.textColor,
  2888. classNames: props.classNames.concat(props.className)
  2889. };
  2890. }
  2891. function processScopedUiProps(prefix, rawScoped, calendar, leftovers) {
  2892. var rawUnscoped = {};
  2893. var wasFound = {};
  2894. for (var key in UNSCOPED_EVENT_UI_PROPS) {
  2895. var scopedKey = prefix + capitaliseFirstLetter(key);
  2896. rawUnscoped[key] = rawScoped[scopedKey];
  2897. wasFound[scopedKey] = true;
  2898. }
  2899. if (prefix === 'event') {
  2900. rawUnscoped.editable = rawScoped.editable; // special case. there is no 'eventEditable', just 'editable'
  2901. }
  2902. if (leftovers) {
  2903. for (var key in rawScoped) {
  2904. if (!wasFound[key]) {
  2905. leftovers[key] = rawScoped[key];
  2906. }
  2907. }
  2908. }
  2909. return processUnscopedUiProps(rawUnscoped, calendar);
  2910. }
  2911. var EMPTY_EVENT_UI = {
  2912. startEditable: null,
  2913. durationEditable: null,
  2914. constraints: [],
  2915. overlap: null,
  2916. allows: [],
  2917. backgroundColor: '',
  2918. borderColor: '',
  2919. textColor: '',
  2920. classNames: []
  2921. };
  2922. // prevent against problems with <2 args!
  2923. function combineEventUis(uis) {
  2924. return uis.reduce(combineTwoEventUis, EMPTY_EVENT_UI);
  2925. }
  2926. function combineTwoEventUis(item0, item1) {
  2927. return {
  2928. startEditable: item1.startEditable != null ? item1.startEditable : item0.startEditable,
  2929. durationEditable: item1.durationEditable != null ? item1.durationEditable : item0.durationEditable,
  2930. constraints: item0.constraints.concat(item1.constraints),
  2931. overlap: typeof item1.overlap === 'boolean' ? item1.overlap : item0.overlap,
  2932. allows: item0.allows.concat(item1.allows),
  2933. backgroundColor: item1.backgroundColor || item0.backgroundColor,
  2934. borderColor: item1.borderColor || item0.borderColor,
  2935. textColor: item1.textColor || item0.textColor,
  2936. classNames: item0.classNames.concat(item1.classNames)
  2937. };
  2938. }
  2939. var NON_DATE_PROPS = {
  2940. id: String,
  2941. groupId: String,
  2942. title: String,
  2943. url: String,
  2944. rendering: String,
  2945. extendedProps: null
  2946. };
  2947. var DATE_PROPS = {
  2948. start: null,
  2949. date: null,
  2950. end: null,
  2951. allDay: null
  2952. };
  2953. var uid = 0;
  2954. function parseEvent(raw, sourceId, calendar, allowOpenRange) {
  2955. var allDayDefault = computeIsAllDayDefault(sourceId, calendar);
  2956. var leftovers0 = {};
  2957. var recurringRes = parseRecurring(raw, // raw, but with single-event stuff stripped out
  2958. allDayDefault, calendar.dateEnv, calendar.pluginSystem.hooks.recurringTypes, leftovers0 // will populate with non-recurring props
  2959. );
  2960. if (recurringRes) {
  2961. var def = parseEventDef(leftovers0, sourceId, recurringRes.allDay, Boolean(recurringRes.duration), calendar);
  2962. def.recurringDef = {
  2963. typeId: recurringRes.typeId,
  2964. typeData: recurringRes.typeData,
  2965. duration: recurringRes.duration
  2966. };
  2967. return { def: def, instance: null };
  2968. }
  2969. else {
  2970. var leftovers1 = {};
  2971. var singleRes = parseSingle(raw, allDayDefault, calendar, leftovers1, allowOpenRange);
  2972. if (singleRes) {
  2973. var def = parseEventDef(leftovers1, sourceId, singleRes.allDay, singleRes.hasEnd, calendar);
  2974. var instance = createEventInstance(def.defId, singleRes.range, singleRes.forcedStartTzo, singleRes.forcedEndTzo);
  2975. return { def: def, instance: instance };
  2976. }
  2977. }
  2978. return null;
  2979. }
  2980. /*
  2981. Will NOT populate extendedProps with the leftover properties.
  2982. Will NOT populate date-related props.
  2983. The EventNonDateInput has been normalized (id => publicId, etc).
  2984. */
  2985. function parseEventDef(raw, sourceId, allDay, hasEnd, calendar) {
  2986. var leftovers = {};
  2987. var def = pluckNonDateProps(raw, calendar, leftovers);
  2988. def.defId = String(uid++);
  2989. def.sourceId = sourceId;
  2990. def.allDay = allDay;
  2991. def.hasEnd = hasEnd;
  2992. for (var _i = 0, _a = calendar.pluginSystem.hooks.eventDefParsers; _i < _a.length; _i++) {
  2993. var eventDefParser = _a[_i];
  2994. var newLeftovers = {};
  2995. eventDefParser(def, leftovers, newLeftovers);
  2996. leftovers = newLeftovers;
  2997. }
  2998. def.extendedProps = __assign(leftovers, def.extendedProps || {});
  2999. // help out EventApi from having user modify props
  3000. Object.freeze(def.ui.classNames);
  3001. Object.freeze(def.extendedProps);
  3002. return def;
  3003. }
  3004. function createEventInstance(defId, range, forcedStartTzo, forcedEndTzo) {
  3005. return {
  3006. instanceId: String(uid++),
  3007. defId: defId,
  3008. range: range,
  3009. forcedStartTzo: forcedStartTzo == null ? null : forcedStartTzo,
  3010. forcedEndTzo: forcedEndTzo == null ? null : forcedEndTzo
  3011. };
  3012. }
  3013. function parseSingle(raw, allDayDefault, calendar, leftovers, allowOpenRange) {
  3014. var props = pluckDateProps(raw, leftovers);
  3015. var allDay = props.allDay;
  3016. var startMeta;
  3017. var startMarker = null;
  3018. var hasEnd = false;
  3019. var endMeta;
  3020. var endMarker = null;
  3021. startMeta = calendar.dateEnv.createMarkerMeta(props.start);
  3022. if (startMeta) {
  3023. startMarker = startMeta.marker;
  3024. }
  3025. else if (!allowOpenRange) {
  3026. return null;
  3027. }
  3028. if (props.end != null) {
  3029. endMeta = calendar.dateEnv.createMarkerMeta(props.end);
  3030. }
  3031. if (allDay == null) {
  3032. if (allDayDefault != null) {
  3033. allDay = allDayDefault;
  3034. }
  3035. else {
  3036. // fall back to the date props LAST
  3037. allDay = (!startMeta || startMeta.isTimeUnspecified) &&
  3038. (!endMeta || endMeta.isTimeUnspecified);
  3039. }
  3040. }
  3041. if (allDay && startMarker) {
  3042. startMarker = startOfDay(startMarker);
  3043. }
  3044. if (endMeta) {
  3045. endMarker = endMeta.marker;
  3046. if (allDay) {
  3047. endMarker = startOfDay(endMarker);
  3048. }
  3049. if (startMarker && endMarker <= startMarker) {
  3050. endMarker = null;
  3051. }
  3052. }
  3053. if (endMarker) {
  3054. hasEnd = true;
  3055. }
  3056. else if (!allowOpenRange) {
  3057. hasEnd = calendar.opt('forceEventDuration') || false;
  3058. endMarker = calendar.dateEnv.add(startMarker, allDay ?
  3059. calendar.defaultAllDayEventDuration :
  3060. calendar.defaultTimedEventDuration);
  3061. }
  3062. return {
  3063. allDay: allDay,
  3064. hasEnd: hasEnd,
  3065. range: { start: startMarker, end: endMarker },
  3066. forcedStartTzo: startMeta ? startMeta.forcedTzo : null,
  3067. forcedEndTzo: endMeta ? endMeta.forcedTzo : null
  3068. };
  3069. }
  3070. function pluckDateProps(raw, leftovers) {
  3071. var props = refineProps(raw, DATE_PROPS, {}, leftovers);
  3072. props.start = (props.start !== null) ? props.start : props.date;
  3073. delete props.date;
  3074. return props;
  3075. }
  3076. function pluckNonDateProps(raw, calendar, leftovers) {
  3077. var preLeftovers = {};
  3078. var props = refineProps(raw, NON_DATE_PROPS, {}, preLeftovers);
  3079. var ui = processUnscopedUiProps(preLeftovers, calendar, leftovers);
  3080. props.publicId = props.id;
  3081. delete props.id;
  3082. props.ui = ui;
  3083. return props;
  3084. }
  3085. function computeIsAllDayDefault(sourceId, calendar) {
  3086. var res = null;
  3087. if (sourceId) {
  3088. var source = calendar.state.eventSources[sourceId];
  3089. res = source.allDayDefault;
  3090. }
  3091. if (res == null) {
  3092. res = calendar.opt('allDayDefault');
  3093. }
  3094. return res;
  3095. }
  3096. var DEF_DEFAULTS = {
  3097. startTime: '09:00',
  3098. endTime: '17:00',
  3099. daysOfWeek: [1, 2, 3, 4, 5],
  3100. rendering: 'inverse-background',
  3101. classNames: 'fc-nonbusiness',
  3102. groupId: '_businessHours' // so multiple defs get grouped
  3103. };
  3104. /*
  3105. TODO: pass around as EventDefHash!!!
  3106. */
  3107. function parseBusinessHours(input, calendar) {
  3108. return parseEvents(refineInputs(input), '', calendar);
  3109. }
  3110. function refineInputs(input) {
  3111. var rawDefs;
  3112. if (input === true) {
  3113. rawDefs = [{}]; // will get DEF_DEFAULTS verbatim
  3114. }
  3115. else if (Array.isArray(input)) {
  3116. // if specifying an array, every sub-definition NEEDS a day-of-week
  3117. rawDefs = input.filter(function (rawDef) {
  3118. return rawDef.daysOfWeek;
  3119. });
  3120. }
  3121. else if (typeof input === 'object' && input) { // non-null object
  3122. rawDefs = [input];
  3123. }
  3124. else { // is probably false
  3125. rawDefs = [];
  3126. }
  3127. rawDefs = rawDefs.map(function (rawDef) {
  3128. return __assign({}, DEF_DEFAULTS, rawDef);
  3129. });
  3130. return rawDefs;
  3131. }
  3132. function memoizeRendering(renderFunc, unrenderFunc, dependencies) {
  3133. if (dependencies === void 0) { dependencies = []; }
  3134. var dependents = [];
  3135. var thisContext;
  3136. var prevArgs;
  3137. function unrender() {
  3138. if (prevArgs) {
  3139. for (var _i = 0, dependents_1 = dependents; _i < dependents_1.length; _i++) {
  3140. var dependent = dependents_1[_i];
  3141. dependent.unrender();
  3142. }
  3143. if (unrenderFunc) {
  3144. unrenderFunc.apply(thisContext, prevArgs);
  3145. }
  3146. prevArgs = null;
  3147. }
  3148. }
  3149. function res() {
  3150. if (!prevArgs || !isArraysEqual(prevArgs, arguments)) {
  3151. unrender();
  3152. thisContext = this;
  3153. prevArgs = arguments;
  3154. renderFunc.apply(this, arguments);
  3155. }
  3156. }
  3157. res.dependents = dependents;
  3158. res.unrender = unrender;
  3159. for (var _i = 0, dependencies_1 = dependencies; _i < dependencies_1.length; _i++) {
  3160. var dependency = dependencies_1[_i];
  3161. dependency.dependents.push(res);
  3162. }
  3163. return res;
  3164. }
  3165. var EMPTY_EVENT_STORE = createEmptyEventStore(); // for purecomponents. TODO: keep elsewhere
  3166. var Splitter = /** @class */ (function () {
  3167. function Splitter() {
  3168. this.getKeysForEventDefs = memoize(this._getKeysForEventDefs);
  3169. this.splitDateSelection = memoize(this._splitDateSpan);
  3170. this.splitEventStore = memoize(this._splitEventStore);
  3171. this.splitIndividualUi = memoize(this._splitIndividualUi);
  3172. this.splitEventDrag = memoize(this._splitInteraction);
  3173. this.splitEventResize = memoize(this._splitInteraction);
  3174. this.eventUiBuilders = {}; // TODO: typescript protection
  3175. }
  3176. Splitter.prototype.splitProps = function (props) {
  3177. var _this = this;
  3178. var keyInfos = this.getKeyInfo(props);
  3179. var defKeys = this.getKeysForEventDefs(props.eventStore);
  3180. var dateSelections = this.splitDateSelection(props.dateSelection);
  3181. var individualUi = this.splitIndividualUi(props.eventUiBases, defKeys); // the individual *bases*
  3182. var eventStores = this.splitEventStore(props.eventStore, defKeys);
  3183. var eventDrags = this.splitEventDrag(props.eventDrag);
  3184. var eventResizes = this.splitEventResize(props.eventResize);
  3185. var splitProps = {};
  3186. this.eventUiBuilders = mapHash(keyInfos, function (info, key) {
  3187. return _this.eventUiBuilders[key] || memoize(buildEventUiForKey);
  3188. });
  3189. for (var key in keyInfos) {
  3190. var keyInfo = keyInfos[key];
  3191. var eventStore = eventStores[key] || EMPTY_EVENT_STORE;
  3192. var buildEventUi = this.eventUiBuilders[key];
  3193. splitProps[key] = {
  3194. businessHours: keyInfo.businessHours || props.businessHours,
  3195. dateSelection: dateSelections[key] || null,
  3196. eventStore: eventStore,
  3197. eventUiBases: buildEventUi(props.eventUiBases[''], keyInfo.ui, individualUi[key]),
  3198. eventSelection: eventStore.instances[props.eventSelection] ? props.eventSelection : '',
  3199. eventDrag: eventDrags[key] || null,
  3200. eventResize: eventResizes[key] || null
  3201. };
  3202. }
  3203. return splitProps;
  3204. };
  3205. Splitter.prototype._splitDateSpan = function (dateSpan) {
  3206. var dateSpans = {};
  3207. if (dateSpan) {
  3208. var keys = this.getKeysForDateSpan(dateSpan);
  3209. for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
  3210. var key = keys_1[_i];
  3211. dateSpans[key] = dateSpan;
  3212. }
  3213. }
  3214. return dateSpans;
  3215. };
  3216. Splitter.prototype._getKeysForEventDefs = function (eventStore) {
  3217. var _this = this;
  3218. return mapHash(eventStore.defs, function (eventDef) {
  3219. return _this.getKeysForEventDef(eventDef);
  3220. });
  3221. };
  3222. Splitter.prototype._splitEventStore = function (eventStore, defKeys) {
  3223. var defs = eventStore.defs, instances = eventStore.instances;
  3224. var splitStores = {};
  3225. for (var defId in defs) {
  3226. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  3227. var key = _a[_i];
  3228. if (!splitStores[key]) {
  3229. splitStores[key] = createEmptyEventStore();
  3230. }
  3231. splitStores[key].defs[defId] = defs[defId];
  3232. }
  3233. }
  3234. for (var instanceId in instances) {
  3235. var instance = instances[instanceId];
  3236. for (var _b = 0, _c = defKeys[instance.defId]; _b < _c.length; _b++) {
  3237. var key = _c[_b];
  3238. if (splitStores[key]) { // must have already been created
  3239. splitStores[key].instances[instanceId] = instance;
  3240. }
  3241. }
  3242. }
  3243. return splitStores;
  3244. };
  3245. Splitter.prototype._splitIndividualUi = function (eventUiBases, defKeys) {
  3246. var splitHashes = {};
  3247. for (var defId in eventUiBases) {
  3248. if (defId) { // not the '' key
  3249. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  3250. var key = _a[_i];
  3251. if (!splitHashes[key]) {
  3252. splitHashes[key] = {};
  3253. }
  3254. splitHashes[key][defId] = eventUiBases[defId];
  3255. }
  3256. }
  3257. }
  3258. return splitHashes;
  3259. };
  3260. Splitter.prototype._splitInteraction = function (interaction) {
  3261. var splitStates = {};
  3262. if (interaction) {
  3263. var affectedStores_1 = this._splitEventStore(interaction.affectedEvents, this._getKeysForEventDefs(interaction.affectedEvents) // can't use cached. might be events from other calendar
  3264. );
  3265. // can't rely on defKeys because event data is mutated
  3266. var mutatedKeysByDefId = this._getKeysForEventDefs(interaction.mutatedEvents);
  3267. var mutatedStores_1 = this._splitEventStore(interaction.mutatedEvents, mutatedKeysByDefId);
  3268. var populate = function (key) {
  3269. if (!splitStates[key]) {
  3270. splitStates[key] = {
  3271. affectedEvents: affectedStores_1[key] || EMPTY_EVENT_STORE,
  3272. mutatedEvents: mutatedStores_1[key] || EMPTY_EVENT_STORE,
  3273. isEvent: interaction.isEvent,
  3274. origSeg: interaction.origSeg
  3275. };
  3276. }
  3277. };
  3278. for (var key in affectedStores_1) {
  3279. populate(key);
  3280. }
  3281. for (var key in mutatedStores_1) {
  3282. populate(key);
  3283. }
  3284. }
  3285. return splitStates;
  3286. };
  3287. return Splitter;
  3288. }());
  3289. function buildEventUiForKey(allUi, eventUiForKey, individualUi) {
  3290. var baseParts = [];
  3291. if (allUi) {
  3292. baseParts.push(allUi);
  3293. }
  3294. if (eventUiForKey) {
  3295. baseParts.push(eventUiForKey);
  3296. }
  3297. var stuff = {
  3298. '': combineEventUis(baseParts)
  3299. };
  3300. if (individualUi) {
  3301. __assign(stuff, individualUi);
  3302. }
  3303. return stuff;
  3304. }
  3305. // Generates HTML for an anchor to another view into the calendar.
  3306. // Will either generate an <a> tag or a non-clickable <span> tag, depending on enabled settings.
  3307. // `gotoOptions` can either be a DateMarker, or an object with the form:
  3308. // { date, type, forceOff }
  3309. // `type` is a view-type like "day" or "week". default value is "day".
  3310. // `attrs` and `innerHtml` are use to generate the rest of the HTML tag.
  3311. function buildGotoAnchorHtml(component, gotoOptions, attrs, innerHtml) {
  3312. var dateEnv = component.dateEnv;
  3313. var date;
  3314. var type;
  3315. var forceOff;
  3316. var finalOptions;
  3317. if (gotoOptions instanceof Date) {
  3318. date = gotoOptions; // a single date-like input
  3319. }
  3320. else {
  3321. date = gotoOptions.date;
  3322. type = gotoOptions.type;
  3323. forceOff = gotoOptions.forceOff;
  3324. }
  3325. finalOptions = {
  3326. date: dateEnv.formatIso(date, { omitTime: true }),
  3327. type: type || 'day'
  3328. };
  3329. if (typeof attrs === 'string') {
  3330. innerHtml = attrs;
  3331. attrs = null;
  3332. }
  3333. attrs = attrs ? ' ' + attrsToStr(attrs) : ''; // will have a leading space
  3334. innerHtml = innerHtml || '';
  3335. if (!forceOff && component.opt('navLinks')) {
  3336. return '<a' + attrs +
  3337. ' data-goto="' + htmlEscape(JSON.stringify(finalOptions)) + '">' +
  3338. innerHtml +
  3339. '</a>';
  3340. }
  3341. else {
  3342. return '<span' + attrs + '>' +
  3343. innerHtml +
  3344. '</span>';
  3345. }
  3346. }
  3347. function getAllDayHtml(component) {
  3348. return component.opt('allDayHtml') || htmlEscape(component.opt('allDayText'));
  3349. }
  3350. // Computes HTML classNames for a single-day element
  3351. function getDayClasses(date, dateProfile, context, noThemeHighlight) {
  3352. var calendar = context.calendar, view = context.view, theme = context.theme, dateEnv = context.dateEnv;
  3353. var classes = [];
  3354. var todayStart;
  3355. var todayEnd;
  3356. if (!rangeContainsMarker(dateProfile.activeRange, date)) {
  3357. classes.push('fc-disabled-day');
  3358. }
  3359. else {
  3360. classes.push('fc-' + DAY_IDS[date.getUTCDay()]);
  3361. if (view.opt('monthMode') &&
  3362. dateEnv.getMonth(date) !== dateEnv.getMonth(dateProfile.currentRange.start)) {
  3363. classes.push('fc-other-month');
  3364. }
  3365. todayStart = startOfDay(calendar.getNow());
  3366. todayEnd = addDays(todayStart, 1);
  3367. if (date < todayStart) {
  3368. classes.push('fc-past');
  3369. }
  3370. else if (date >= todayEnd) {
  3371. classes.push('fc-future');
  3372. }
  3373. else {
  3374. classes.push('fc-today');
  3375. if (noThemeHighlight !== true) {
  3376. classes.push(theme.getClass('today'));
  3377. }
  3378. }
  3379. }
  3380. return classes;
  3381. }
  3382. // given a function that resolves a result asynchronously.
  3383. // the function can either call passed-in success and failure callbacks,
  3384. // or it can return a promise.
  3385. // if you need to pass additional params to func, bind them first.
  3386. function unpromisify(func, success, failure) {
  3387. // guard against success/failure callbacks being called more than once
  3388. // and guard against a promise AND callback being used together.
  3389. var isResolved = false;
  3390. var wrappedSuccess = function () {
  3391. if (!isResolved) {
  3392. isResolved = true;
  3393. success.apply(this, arguments);
  3394. }
  3395. };
  3396. var wrappedFailure = function () {
  3397. if (!isResolved) {
  3398. isResolved = true;
  3399. if (failure) {
  3400. failure.apply(this, arguments);
  3401. }
  3402. }
  3403. };
  3404. var res = func(wrappedSuccess, wrappedFailure);
  3405. if (res && typeof res.then === 'function') {
  3406. res.then(wrappedSuccess, wrappedFailure);
  3407. }
  3408. }
  3409. var Mixin = /** @class */ (function () {
  3410. function Mixin() {
  3411. }
  3412. // mix into a CLASS
  3413. Mixin.mixInto = function (destClass) {
  3414. this.mixIntoObj(destClass.prototype);
  3415. };
  3416. // mix into ANY object
  3417. Mixin.mixIntoObj = function (destObj) {
  3418. var _this = this;
  3419. Object.getOwnPropertyNames(this.prototype).forEach(function (name) {
  3420. if (!destObj[name]) { // if destination doesn't already define it
  3421. destObj[name] = _this.prototype[name];
  3422. }
  3423. });
  3424. };
  3425. /*
  3426. will override existing methods
  3427. TODO: remove! not used anymore
  3428. */
  3429. Mixin.mixOver = function (destClass) {
  3430. var _this = this;
  3431. Object.getOwnPropertyNames(this.prototype).forEach(function (name) {
  3432. destClass.prototype[name] = _this.prototype[name];
  3433. });
  3434. };
  3435. return Mixin;
  3436. }());
  3437. /*
  3438. USAGE:
  3439. import { default as EmitterMixin, EmitterInterface } from './EmitterMixin'
  3440. in class:
  3441. on: EmitterInterface['on']
  3442. one: EmitterInterface['one']
  3443. off: EmitterInterface['off']
  3444. trigger: EmitterInterface['trigger']
  3445. triggerWith: EmitterInterface['triggerWith']
  3446. hasHandlers: EmitterInterface['hasHandlers']
  3447. after class:
  3448. EmitterMixin.mixInto(TheClass)
  3449. */
  3450. var EmitterMixin = /** @class */ (function (_super) {
  3451. __extends(EmitterMixin, _super);
  3452. function EmitterMixin() {
  3453. return _super !== null && _super.apply(this, arguments) || this;
  3454. }
  3455. EmitterMixin.prototype.on = function (type, handler) {
  3456. addToHash(this._handlers || (this._handlers = {}), type, handler);
  3457. return this; // for chaining
  3458. };
  3459. // todo: add comments
  3460. EmitterMixin.prototype.one = function (type, handler) {
  3461. addToHash(this._oneHandlers || (this._oneHandlers = {}), type, handler);
  3462. return this; // for chaining
  3463. };
  3464. EmitterMixin.prototype.off = function (type, handler) {
  3465. if (this._handlers) {
  3466. removeFromHash(this._handlers, type, handler);
  3467. }
  3468. if (this._oneHandlers) {
  3469. removeFromHash(this._oneHandlers, type, handler);
  3470. }
  3471. return this; // for chaining
  3472. };
  3473. EmitterMixin.prototype.trigger = function (type) {
  3474. var args = [];
  3475. for (var _i = 1; _i < arguments.length; _i++) {
  3476. args[_i - 1] = arguments[_i];
  3477. }
  3478. this.triggerWith(type, this, args);
  3479. return this; // for chaining
  3480. };
  3481. EmitterMixin.prototype.triggerWith = function (type, context, args) {
  3482. if (this._handlers) {
  3483. applyAll(this._handlers[type], context, args);
  3484. }
  3485. if (this._oneHandlers) {
  3486. applyAll(this._oneHandlers[type], context, args);
  3487. delete this._oneHandlers[type]; // will never fire again
  3488. }
  3489. return this; // for chaining
  3490. };
  3491. EmitterMixin.prototype.hasHandlers = function (type) {
  3492. return (this._handlers && this._handlers[type] && this._handlers[type].length) ||
  3493. (this._oneHandlers && this._oneHandlers[type] && this._oneHandlers[type].length);
  3494. };
  3495. return EmitterMixin;
  3496. }(Mixin));
  3497. function addToHash(hash, type, handler) {
  3498. (hash[type] || (hash[type] = []))
  3499. .push(handler);
  3500. }
  3501. function removeFromHash(hash, type, handler) {
  3502. if (handler) {
  3503. if (hash[type]) {
  3504. hash[type] = hash[type].filter(function (func) {
  3505. return func !== handler;
  3506. });
  3507. }
  3508. }
  3509. else {
  3510. delete hash[type]; // remove all handler funcs for this type
  3511. }
  3512. }
  3513. /*
  3514. Records offset information for a set of elements, relative to an origin element.
  3515. Can record the left/right OR the top/bottom OR both.
  3516. Provides methods for querying the cache by position.
  3517. */
  3518. var PositionCache = /** @class */ (function () {
  3519. function PositionCache(originEl, els, isHorizontal, isVertical) {
  3520. this.originEl = originEl;
  3521. this.els = els;
  3522. this.isHorizontal = isHorizontal;
  3523. this.isVertical = isVertical;
  3524. }
  3525. // Queries the els for coordinates and stores them.
  3526. // Call this method before using and of the get* methods below.
  3527. PositionCache.prototype.build = function () {
  3528. var originEl = this.originEl;
  3529. var originClientRect = this.originClientRect =
  3530. originEl.getBoundingClientRect(); // relative to viewport top-left
  3531. if (this.isHorizontal) {
  3532. this.buildElHorizontals(originClientRect.left);
  3533. }
  3534. if (this.isVertical) {
  3535. this.buildElVerticals(originClientRect.top);
  3536. }
  3537. };
  3538. // Populates the left/right internal coordinate arrays
  3539. PositionCache.prototype.buildElHorizontals = function (originClientLeft) {
  3540. var lefts = [];
  3541. var rights = [];
  3542. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  3543. var el = _a[_i];
  3544. var rect = el.getBoundingClientRect();
  3545. lefts.push(rect.left - originClientLeft);
  3546. rights.push(rect.right - originClientLeft);
  3547. }
  3548. this.lefts = lefts;
  3549. this.rights = rights;
  3550. };
  3551. // Populates the top/bottom internal coordinate arrays
  3552. PositionCache.prototype.buildElVerticals = function (originClientTop) {
  3553. var tops = [];
  3554. var bottoms = [];
  3555. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  3556. var el = _a[_i];
  3557. var rect = el.getBoundingClientRect();
  3558. tops.push(rect.top - originClientTop);
  3559. bottoms.push(rect.bottom - originClientTop);
  3560. }
  3561. this.tops = tops;
  3562. this.bottoms = bottoms;
  3563. };
  3564. // Given a left offset (from document left), returns the index of the el that it horizontally intersects.
  3565. // If no intersection is made, returns undefined.
  3566. PositionCache.prototype.leftToIndex = function (leftPosition) {
  3567. var lefts = this.lefts;
  3568. var rights = this.rights;
  3569. var len = lefts.length;
  3570. var i;
  3571. for (i = 0; i < len; i++) {
  3572. if (leftPosition >= lefts[i] && leftPosition < rights[i]) {
  3573. return i;
  3574. }
  3575. }
  3576. };
  3577. // Given a top offset (from document top), returns the index of the el that it vertically intersects.
  3578. // If no intersection is made, returns undefined.
  3579. PositionCache.prototype.topToIndex = function (topPosition) {
  3580. var tops = this.tops;
  3581. var bottoms = this.bottoms;
  3582. var len = tops.length;
  3583. var i;
  3584. for (i = 0; i < len; i++) {
  3585. if (topPosition >= tops[i] && topPosition < bottoms[i]) {
  3586. return i;
  3587. }
  3588. }
  3589. };
  3590. // Gets the width of the element at the given index
  3591. PositionCache.prototype.getWidth = function (leftIndex) {
  3592. return this.rights[leftIndex] - this.lefts[leftIndex];
  3593. };
  3594. // Gets the height of the element at the given index
  3595. PositionCache.prototype.getHeight = function (topIndex) {
  3596. return this.bottoms[topIndex] - this.tops[topIndex];
  3597. };
  3598. return PositionCache;
  3599. }());
  3600. /*
  3601. An object for getting/setting scroll-related information for an element.
  3602. Internally, this is done very differently for window versus DOM element,
  3603. so this object serves as a common interface.
  3604. */
  3605. var ScrollController = /** @class */ (function () {
  3606. function ScrollController() {
  3607. }
  3608. ScrollController.prototype.getMaxScrollTop = function () {
  3609. return this.getScrollHeight() - this.getClientHeight();
  3610. };
  3611. ScrollController.prototype.getMaxScrollLeft = function () {
  3612. return this.getScrollWidth() - this.getClientWidth();
  3613. };
  3614. ScrollController.prototype.canScrollVertically = function () {
  3615. return this.getMaxScrollTop() > 0;
  3616. };
  3617. ScrollController.prototype.canScrollHorizontally = function () {
  3618. return this.getMaxScrollLeft() > 0;
  3619. };
  3620. ScrollController.prototype.canScrollUp = function () {
  3621. return this.getScrollTop() > 0;
  3622. };
  3623. ScrollController.prototype.canScrollDown = function () {
  3624. return this.getScrollTop() < this.getMaxScrollTop();
  3625. };
  3626. ScrollController.prototype.canScrollLeft = function () {
  3627. return this.getScrollLeft() > 0;
  3628. };
  3629. ScrollController.prototype.canScrollRight = function () {
  3630. return this.getScrollLeft() < this.getMaxScrollLeft();
  3631. };
  3632. return ScrollController;
  3633. }());
  3634. var ElementScrollController = /** @class */ (function (_super) {
  3635. __extends(ElementScrollController, _super);
  3636. function ElementScrollController(el) {
  3637. var _this = _super.call(this) || this;
  3638. _this.el = el;
  3639. return _this;
  3640. }
  3641. ElementScrollController.prototype.getScrollTop = function () {
  3642. return this.el.scrollTop;
  3643. };
  3644. ElementScrollController.prototype.getScrollLeft = function () {
  3645. return this.el.scrollLeft;
  3646. };
  3647. ElementScrollController.prototype.setScrollTop = function (top) {
  3648. this.el.scrollTop = top;
  3649. };
  3650. ElementScrollController.prototype.setScrollLeft = function (left) {
  3651. this.el.scrollLeft = left;
  3652. };
  3653. ElementScrollController.prototype.getScrollWidth = function () {
  3654. return this.el.scrollWidth;
  3655. };
  3656. ElementScrollController.prototype.getScrollHeight = function () {
  3657. return this.el.scrollHeight;
  3658. };
  3659. ElementScrollController.prototype.getClientHeight = function () {
  3660. return this.el.clientHeight;
  3661. };
  3662. ElementScrollController.prototype.getClientWidth = function () {
  3663. return this.el.clientWidth;
  3664. };
  3665. return ElementScrollController;
  3666. }(ScrollController));
  3667. var WindowScrollController = /** @class */ (function (_super) {
  3668. __extends(WindowScrollController, _super);
  3669. function WindowScrollController() {
  3670. return _super !== null && _super.apply(this, arguments) || this;
  3671. }
  3672. WindowScrollController.prototype.getScrollTop = function () {
  3673. return window.pageYOffset;
  3674. };
  3675. WindowScrollController.prototype.getScrollLeft = function () {
  3676. return window.pageXOffset;
  3677. };
  3678. WindowScrollController.prototype.setScrollTop = function (n) {
  3679. window.scroll(window.pageXOffset, n);
  3680. };
  3681. WindowScrollController.prototype.setScrollLeft = function (n) {
  3682. window.scroll(n, window.pageYOffset);
  3683. };
  3684. WindowScrollController.prototype.getScrollWidth = function () {
  3685. return document.documentElement.scrollWidth;
  3686. };
  3687. WindowScrollController.prototype.getScrollHeight = function () {
  3688. return document.documentElement.scrollHeight;
  3689. };
  3690. WindowScrollController.prototype.getClientHeight = function () {
  3691. return document.documentElement.clientHeight;
  3692. };
  3693. WindowScrollController.prototype.getClientWidth = function () {
  3694. return document.documentElement.clientWidth;
  3695. };
  3696. return WindowScrollController;
  3697. }(ScrollController));
  3698. /*
  3699. Embodies a div that has potential scrollbars
  3700. */
  3701. var ScrollComponent = /** @class */ (function (_super) {
  3702. __extends(ScrollComponent, _super);
  3703. function ScrollComponent(overflowX, overflowY) {
  3704. var _this = _super.call(this, createElement('div', {
  3705. className: 'fc-scroller'
  3706. })) || this;
  3707. _this.overflowX = overflowX;
  3708. _this.overflowY = overflowY;
  3709. _this.applyOverflow();
  3710. return _this;
  3711. }
  3712. // sets to natural height, unlocks overflow
  3713. ScrollComponent.prototype.clear = function () {
  3714. this.setHeight('auto');
  3715. this.applyOverflow();
  3716. };
  3717. ScrollComponent.prototype.destroy = function () {
  3718. removeElement(this.el);
  3719. };
  3720. // Overflow
  3721. // -----------------------------------------------------------------------------------------------------------------
  3722. ScrollComponent.prototype.applyOverflow = function () {
  3723. applyStyle(this.el, {
  3724. overflowX: this.overflowX,
  3725. overflowY: this.overflowY
  3726. });
  3727. };
  3728. // Causes any 'auto' overflow values to resolves to 'scroll' or 'hidden'.
  3729. // Useful for preserving scrollbar widths regardless of future resizes.
  3730. // Can pass in scrollbarWidths for optimization.
  3731. ScrollComponent.prototype.lockOverflow = function (scrollbarWidths) {
  3732. var overflowX = this.overflowX;
  3733. var overflowY = this.overflowY;
  3734. scrollbarWidths = scrollbarWidths || this.getScrollbarWidths();
  3735. if (overflowX === 'auto') {
  3736. overflowX = (scrollbarWidths.bottom || // horizontal scrollbars?
  3737. this.canScrollHorizontally() // OR scrolling pane with massless scrollbars?
  3738. ) ? 'scroll' : 'hidden';
  3739. }
  3740. if (overflowY === 'auto') {
  3741. overflowY = (scrollbarWidths.left || scrollbarWidths.right || // horizontal scrollbars?
  3742. this.canScrollVertically() // OR scrolling pane with massless scrollbars?
  3743. ) ? 'scroll' : 'hidden';
  3744. }
  3745. applyStyle(this.el, { overflowX: overflowX, overflowY: overflowY });
  3746. };
  3747. ScrollComponent.prototype.setHeight = function (height) {
  3748. applyStyleProp(this.el, 'height', height);
  3749. };
  3750. ScrollComponent.prototype.getScrollbarWidths = function () {
  3751. var edges = computeEdges(this.el);
  3752. return {
  3753. left: edges.scrollbarLeft,
  3754. right: edges.scrollbarRight,
  3755. bottom: edges.scrollbarBottom
  3756. };
  3757. };
  3758. return ScrollComponent;
  3759. }(ElementScrollController));
  3760. var Theme = /** @class */ (function () {
  3761. function Theme(calendarOptions) {
  3762. this.calendarOptions = calendarOptions;
  3763. this.processIconOverride();
  3764. }
  3765. Theme.prototype.processIconOverride = function () {
  3766. if (this.iconOverrideOption) {
  3767. this.setIconOverride(this.calendarOptions[this.iconOverrideOption]);
  3768. }
  3769. };
  3770. Theme.prototype.setIconOverride = function (iconOverrideHash) {
  3771. var iconClassesCopy;
  3772. var buttonName;
  3773. if (typeof iconOverrideHash === 'object' && iconOverrideHash) { // non-null object
  3774. iconClassesCopy = __assign({}, this.iconClasses);
  3775. for (buttonName in iconOverrideHash) {
  3776. iconClassesCopy[buttonName] = this.applyIconOverridePrefix(iconOverrideHash[buttonName]);
  3777. }
  3778. this.iconClasses = iconClassesCopy;
  3779. }
  3780. else if (iconOverrideHash === false) {
  3781. this.iconClasses = {};
  3782. }
  3783. };
  3784. Theme.prototype.applyIconOverridePrefix = function (className) {
  3785. var prefix = this.iconOverridePrefix;
  3786. if (prefix && className.indexOf(prefix) !== 0) { // if not already present
  3787. className = prefix + className;
  3788. }
  3789. return className;
  3790. };
  3791. Theme.prototype.getClass = function (key) {
  3792. return this.classes[key] || '';
  3793. };
  3794. Theme.prototype.getIconClass = function (buttonName) {
  3795. var className = this.iconClasses[buttonName];
  3796. if (className) {
  3797. return this.baseIconClass + ' ' + className;
  3798. }
  3799. return '';
  3800. };
  3801. Theme.prototype.getCustomButtonIconClass = function (customButtonProps) {
  3802. var className;
  3803. if (this.iconOverrideCustomButtonOption) {
  3804. className = customButtonProps[this.iconOverrideCustomButtonOption];
  3805. if (className) {
  3806. return this.baseIconClass + ' ' + this.applyIconOverridePrefix(className);
  3807. }
  3808. }
  3809. return '';
  3810. };
  3811. return Theme;
  3812. }());
  3813. Theme.prototype.classes = {};
  3814. Theme.prototype.iconClasses = {};
  3815. Theme.prototype.baseIconClass = '';
  3816. Theme.prototype.iconOverridePrefix = '';
  3817. var guid = 0;
  3818. var Component = /** @class */ (function () {
  3819. function Component(context, isView) {
  3820. // HACK to populate view at top of component instantiation call chain
  3821. if (isView) {
  3822. context.view = this;
  3823. }
  3824. this.uid = String(guid++);
  3825. this.context = context;
  3826. this.dateEnv = context.dateEnv;
  3827. this.theme = context.theme;
  3828. this.view = context.view;
  3829. this.calendar = context.calendar;
  3830. this.isRtl = this.opt('dir') === 'rtl';
  3831. }
  3832. Component.addEqualityFuncs = function (newFuncs) {
  3833. this.prototype.equalityFuncs = __assign({}, this.prototype.equalityFuncs, newFuncs);
  3834. };
  3835. Component.prototype.opt = function (name) {
  3836. return this.context.options[name];
  3837. };
  3838. Component.prototype.receiveProps = function (props) {
  3839. var _a = recycleProps(this.props || {}, props, this.equalityFuncs), anyChanges = _a.anyChanges, comboProps = _a.comboProps;
  3840. this.props = comboProps;
  3841. if (anyChanges) {
  3842. this.render(comboProps);
  3843. }
  3844. };
  3845. Component.prototype.render = function (props) {
  3846. };
  3847. // after destroy is called, this component won't ever be used again
  3848. Component.prototype.destroy = function () {
  3849. };
  3850. return Component;
  3851. }());
  3852. Component.prototype.equalityFuncs = {};
  3853. /*
  3854. Reuses old values when equal. If anything is unequal, returns newProps as-is.
  3855. Great for PureComponent, but won't be feasible with React, so just eliminate and use React's DOM diffing.
  3856. */
  3857. function recycleProps(oldProps, newProps, equalityFuncs) {
  3858. var comboProps = {}; // some old, some new
  3859. var anyChanges = false;
  3860. for (var key in newProps) {
  3861. if (key in oldProps && (oldProps[key] === newProps[key] ||
  3862. (equalityFuncs[key] && equalityFuncs[key](oldProps[key], newProps[key])))) {
  3863. // equal to old? use old prop
  3864. comboProps[key] = oldProps[key];
  3865. }
  3866. else {
  3867. comboProps[key] = newProps[key];
  3868. anyChanges = true;
  3869. }
  3870. }
  3871. for (var key in oldProps) {
  3872. if (!(key in newProps)) {
  3873. anyChanges = true;
  3874. break;
  3875. }
  3876. }
  3877. return { anyChanges: anyChanges, comboProps: comboProps };
  3878. }
  3879. /*
  3880. PURPOSES:
  3881. - hook up to fg, fill, and mirror renderers
  3882. - interface for dragging and hits
  3883. */
  3884. var DateComponent = /** @class */ (function (_super) {
  3885. __extends(DateComponent, _super);
  3886. function DateComponent(context, el, isView) {
  3887. var _this = _super.call(this, context, isView) || this;
  3888. _this.el = el;
  3889. return _this;
  3890. }
  3891. DateComponent.prototype.destroy = function () {
  3892. _super.prototype.destroy.call(this);
  3893. removeElement(this.el);
  3894. };
  3895. // TODO: WHAT ABOUT (sourceSeg && sourceSeg.component.doesDragMirror)
  3896. //
  3897. // Event Drag-n-Drop Rendering (for both events and external elements)
  3898. // ---------------------------------------------------------------------------------------------------------------
  3899. /*
  3900. renderEventDragSegs(state: EventSegUiInteractionState) {
  3901. if (state) {
  3902. let { isEvent, segs, sourceSeg } = state
  3903. if (this.eventRenderer) {
  3904. this.eventRenderer.hideByHash(state.affectedInstances)
  3905. }
  3906. // if the user is dragging something that is considered an event with real event data,
  3907. // and this component likes to do drag mirrors OR the component where the seg came from
  3908. // likes to do drag mirrors, then render a drag mirror.
  3909. if (isEvent && (this.doesDragMirror || sourceSeg && sourceSeg.component.doesDragMirror)) {
  3910. if (this.mirrorRenderer) {
  3911. this.mirrorRenderer.renderSegs(segs, { isDragging: true, sourceSeg })
  3912. }
  3913. }
  3914. // if it would be impossible to render a drag mirror OR this component likes to render
  3915. // highlights, then render a highlight.
  3916. if (!isEvent || this.doesDragHighlight) {
  3917. if (this.fillRenderer) {
  3918. this.fillRenderer.renderSegs('highlight', segs)
  3919. }
  3920. }
  3921. }
  3922. }
  3923. */
  3924. // Hit System
  3925. // -----------------------------------------------------------------------------------------------------------------
  3926. DateComponent.prototype.buildPositionCaches = function () {
  3927. };
  3928. DateComponent.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  3929. return null; // this should be abstract
  3930. };
  3931. // Validation
  3932. // -----------------------------------------------------------------------------------------------------------------
  3933. DateComponent.prototype.isInteractionValid = function (interaction) {
  3934. var calendar = this.calendar;
  3935. var dateProfile = this.props.dateProfile; // HACK
  3936. var instances = interaction.mutatedEvents.instances;
  3937. if (dateProfile) { // HACK for DayTile
  3938. for (var instanceId in instances) {
  3939. if (!rangeContainsRange(dateProfile.validRange, instances[instanceId].range)) {
  3940. return false;
  3941. }
  3942. }
  3943. }
  3944. return isInteractionValid(interaction, calendar);
  3945. };
  3946. DateComponent.prototype.isDateSelectionValid = function (selection) {
  3947. var dateProfile = this.props.dateProfile; // HACK
  3948. if (dateProfile && // HACK for DayTile
  3949. !rangeContainsRange(dateProfile.validRange, selection.range)) {
  3950. return false;
  3951. }
  3952. return isDateSelectionValid(selection, this.calendar);
  3953. };
  3954. // Triggering
  3955. // -----------------------------------------------------------------------------------------------------------------
  3956. // TODO: move to Calendar
  3957. DateComponent.prototype.publiclyTrigger = function (name, args) {
  3958. var calendar = this.calendar;
  3959. return calendar.publiclyTrigger(name, args);
  3960. };
  3961. DateComponent.prototype.publiclyTriggerAfterSizing = function (name, args) {
  3962. var calendar = this.calendar;
  3963. return calendar.publiclyTriggerAfterSizing(name, args);
  3964. };
  3965. DateComponent.prototype.hasPublicHandlers = function (name) {
  3966. var calendar = this.calendar;
  3967. return calendar.hasPublicHandlers(name);
  3968. };
  3969. DateComponent.prototype.triggerRenderedSegs = function (segs, isMirrors) {
  3970. var calendar = this.calendar;
  3971. if (this.hasPublicHandlers('eventPositioned')) {
  3972. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  3973. var seg = segs_1[_i];
  3974. this.publiclyTriggerAfterSizing('eventPositioned', [
  3975. {
  3976. event: new EventApi(calendar, seg.eventRange.def, seg.eventRange.instance),
  3977. isMirror: isMirrors,
  3978. isStart: seg.isStart,
  3979. isEnd: seg.isEnd,
  3980. el: seg.el,
  3981. view: this // safe to cast because this method is only called on context.view
  3982. }
  3983. ]);
  3984. }
  3985. }
  3986. if (!calendar.state.loadingLevel) { // avoid initial empty state while pending
  3987. calendar.afterSizingTriggers._eventsPositioned = [null]; // fire once
  3988. }
  3989. };
  3990. DateComponent.prototype.triggerWillRemoveSegs = function (segs, isMirrors) {
  3991. var calendar = this.calendar;
  3992. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  3993. var seg = segs_2[_i];
  3994. calendar.trigger('eventElRemove', seg.el);
  3995. }
  3996. if (this.hasPublicHandlers('eventDestroy')) {
  3997. for (var _a = 0, segs_3 = segs; _a < segs_3.length; _a++) {
  3998. var seg = segs_3[_a];
  3999. this.publiclyTrigger('eventDestroy', [
  4000. {
  4001. event: new EventApi(calendar, seg.eventRange.def, seg.eventRange.instance),
  4002. isMirror: isMirrors,
  4003. el: seg.el,
  4004. view: this // safe to cast because this method is only called on context.view
  4005. }
  4006. ]);
  4007. }
  4008. }
  4009. };
  4010. // Pointer Interaction Utils
  4011. // -----------------------------------------------------------------------------------------------------------------
  4012. DateComponent.prototype.isValidSegDownEl = function (el) {
  4013. return !this.props.eventDrag && // HACK
  4014. !this.props.eventResize && // HACK
  4015. !elementClosest(el, '.fc-mirror') &&
  4016. (this.isPopover() || !this.isInPopover(el));
  4017. // ^above line ensures we don't detect a seg interaction within a nested component.
  4018. // it's a HACK because it only supports a popover as the nested component.
  4019. };
  4020. DateComponent.prototype.isValidDateDownEl = function (el) {
  4021. var segEl = elementClosest(el, this.fgSegSelector);
  4022. return (!segEl || segEl.classList.contains('fc-mirror')) &&
  4023. !elementClosest(el, '.fc-more') && // a "more.." link
  4024. !elementClosest(el, 'a[data-goto]') && // a clickable nav link
  4025. !this.isInPopover(el);
  4026. };
  4027. DateComponent.prototype.isPopover = function () {
  4028. return this.el.classList.contains('fc-popover');
  4029. };
  4030. DateComponent.prototype.isInPopover = function (el) {
  4031. return Boolean(elementClosest(el, '.fc-popover'));
  4032. };
  4033. return DateComponent;
  4034. }(Component));
  4035. DateComponent.prototype.fgSegSelector = '.fc-event-container > *';
  4036. DateComponent.prototype.bgSegSelector = '.fc-bgevent:not(.fc-nonbusiness)';
  4037. var uid$1 = 0;
  4038. function createPlugin(input) {
  4039. return {
  4040. id: String(uid$1++),
  4041. deps: input.deps || [],
  4042. reducers: input.reducers || [],
  4043. eventDefParsers: input.eventDefParsers || [],
  4044. eventDragMutationMassagers: input.eventDragMutationMassagers || [],
  4045. eventDefMutationAppliers: input.eventDefMutationAppliers || [],
  4046. dateSelectionTransformers: input.dateSelectionTransformers || [],
  4047. datePointTransforms: input.datePointTransforms || [],
  4048. dateSpanTransforms: input.dateSpanTransforms || [],
  4049. views: input.views || {},
  4050. viewPropsTransformers: input.viewPropsTransformers || [],
  4051. isPropsValid: input.isPropsValid || null,
  4052. externalDefTransforms: input.externalDefTransforms || [],
  4053. eventResizeJoinTransforms: input.eventResizeJoinTransforms || [],
  4054. viewContainerModifiers: input.viewContainerModifiers || [],
  4055. eventDropTransformers: input.eventDropTransformers || [],
  4056. componentInteractions: input.componentInteractions || [],
  4057. calendarInteractions: input.calendarInteractions || [],
  4058. themeClasses: input.themeClasses || {},
  4059. eventSourceDefs: input.eventSourceDefs || [],
  4060. cmdFormatter: input.cmdFormatter,
  4061. recurringTypes: input.recurringTypes || [],
  4062. namedTimeZonedImpl: input.namedTimeZonedImpl,
  4063. defaultView: input.defaultView || '',
  4064. elementDraggingImpl: input.elementDraggingImpl,
  4065. optionChangeHandlers: input.optionChangeHandlers || {}
  4066. };
  4067. }
  4068. var PluginSystem = /** @class */ (function () {
  4069. function PluginSystem() {
  4070. this.hooks = {
  4071. reducers: [],
  4072. eventDefParsers: [],
  4073. eventDragMutationMassagers: [],
  4074. eventDefMutationAppliers: [],
  4075. dateSelectionTransformers: [],
  4076. datePointTransforms: [],
  4077. dateSpanTransforms: [],
  4078. views: {},
  4079. viewPropsTransformers: [],
  4080. isPropsValid: null,
  4081. externalDefTransforms: [],
  4082. eventResizeJoinTransforms: [],
  4083. viewContainerModifiers: [],
  4084. eventDropTransformers: [],
  4085. componentInteractions: [],
  4086. calendarInteractions: [],
  4087. themeClasses: {},
  4088. eventSourceDefs: [],
  4089. cmdFormatter: null,
  4090. recurringTypes: [],
  4091. namedTimeZonedImpl: null,
  4092. defaultView: '',
  4093. elementDraggingImpl: null,
  4094. optionChangeHandlers: {}
  4095. };
  4096. this.addedHash = {};
  4097. }
  4098. PluginSystem.prototype.add = function (plugin) {
  4099. if (!this.addedHash[plugin.id]) {
  4100. this.addedHash[plugin.id] = true;
  4101. for (var _i = 0, _a = plugin.deps; _i < _a.length; _i++) {
  4102. var dep = _a[_i];
  4103. this.add(dep);
  4104. }
  4105. this.hooks = combineHooks(this.hooks, plugin);
  4106. }
  4107. };
  4108. return PluginSystem;
  4109. }());
  4110. function combineHooks(hooks0, hooks1) {
  4111. return {
  4112. reducers: hooks0.reducers.concat(hooks1.reducers),
  4113. eventDefParsers: hooks0.eventDefParsers.concat(hooks1.eventDefParsers),
  4114. eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
  4115. eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
  4116. dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
  4117. datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
  4118. dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
  4119. views: __assign({}, hooks0.views, hooks1.views),
  4120. viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
  4121. isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
  4122. externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
  4123. eventResizeJoinTransforms: hooks0.eventResizeJoinTransforms.concat(hooks1.eventResizeJoinTransforms),
  4124. viewContainerModifiers: hooks0.viewContainerModifiers.concat(hooks1.viewContainerModifiers),
  4125. eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
  4126. calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
  4127. componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
  4128. themeClasses: __assign({}, hooks0.themeClasses, hooks1.themeClasses),
  4129. eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
  4130. cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
  4131. recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
  4132. namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
  4133. defaultView: hooks0.defaultView || hooks1.defaultView,
  4134. elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
  4135. optionChangeHandlers: __assign({}, hooks0.optionChangeHandlers, hooks1.optionChangeHandlers)
  4136. };
  4137. }
  4138. var eventSourceDef = {
  4139. ignoreRange: true,
  4140. parseMeta: function (raw) {
  4141. if (Array.isArray(raw)) { // short form
  4142. return raw;
  4143. }
  4144. else if (Array.isArray(raw.events)) {
  4145. return raw.events;
  4146. }
  4147. return null;
  4148. },
  4149. fetch: function (arg, success) {
  4150. success({
  4151. rawEvents: arg.eventSource.meta
  4152. });
  4153. }
  4154. };
  4155. var ArrayEventSourcePlugin = createPlugin({
  4156. eventSourceDefs: [eventSourceDef]
  4157. });
  4158. var eventSourceDef$1 = {
  4159. parseMeta: function (raw) {
  4160. if (typeof raw === 'function') { // short form
  4161. return raw;
  4162. }
  4163. else if (typeof raw.events === 'function') {
  4164. return raw.events;
  4165. }
  4166. return null;
  4167. },
  4168. fetch: function (arg, success, failure) {
  4169. var dateEnv = arg.calendar.dateEnv;
  4170. var func = arg.eventSource.meta;
  4171. unpromisify(func.bind(null, {
  4172. start: dateEnv.toDate(arg.range.start),
  4173. end: dateEnv.toDate(arg.range.end),
  4174. startStr: dateEnv.formatIso(arg.range.start),
  4175. endStr: dateEnv.formatIso(arg.range.end),
  4176. timeZone: dateEnv.timeZone
  4177. }), function (rawEvents) {
  4178. success({ rawEvents: rawEvents }); // needs an object response
  4179. }, failure // send errorObj directly to failure callback
  4180. );
  4181. }
  4182. };
  4183. var FuncEventSourcePlugin = createPlugin({
  4184. eventSourceDefs: [eventSourceDef$1]
  4185. });
  4186. function requestJson(method, url, params, successCallback, failureCallback) {
  4187. method = method.toUpperCase();
  4188. var body = null;
  4189. if (method === 'GET') {
  4190. url = injectQueryStringParams(url, params);
  4191. }
  4192. else {
  4193. body = encodeParams(params);
  4194. }
  4195. var xhr = new XMLHttpRequest();
  4196. xhr.open(method, url, true);
  4197. if (method !== 'GET') {
  4198. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  4199. }
  4200. xhr.onload = function () {
  4201. if (xhr.status >= 200 && xhr.status < 400) {
  4202. try {
  4203. var res = JSON.parse(xhr.responseText);
  4204. successCallback(res, xhr);
  4205. }
  4206. catch (err) {
  4207. failureCallback('Failure parsing JSON', xhr);
  4208. }
  4209. }
  4210. else {
  4211. failureCallback('Request failed', xhr);
  4212. }
  4213. };
  4214. xhr.onerror = function () {
  4215. failureCallback('Request failed', xhr);
  4216. };
  4217. xhr.send(body);
  4218. }
  4219. function injectQueryStringParams(url, params) {
  4220. return url +
  4221. (url.indexOf('?') === -1 ? '?' : '&') +
  4222. encodeParams(params);
  4223. }
  4224. function encodeParams(params) {
  4225. var parts = [];
  4226. for (var key in params) {
  4227. parts.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
  4228. }
  4229. return parts.join('&');
  4230. }
  4231. var eventSourceDef$2 = {
  4232. parseMeta: function (raw) {
  4233. if (typeof raw === 'string') { // short form
  4234. raw = { url: raw };
  4235. }
  4236. else if (!raw || typeof raw !== 'object' || !raw.url) {
  4237. return null;
  4238. }
  4239. return {
  4240. url: raw.url,
  4241. method: (raw.method || 'GET').toUpperCase(),
  4242. extraParams: raw.extraParams,
  4243. startParam: raw.startParam,
  4244. endParam: raw.endParam,
  4245. timeZoneParam: raw.timeZoneParam
  4246. };
  4247. },
  4248. fetch: function (arg, success, failure) {
  4249. var meta = arg.eventSource.meta;
  4250. var requestParams = buildRequestParams(meta, arg.range, arg.calendar);
  4251. requestJson(meta.method, meta.url, requestParams, function (rawEvents, xhr) {
  4252. success({ rawEvents: rawEvents, xhr: xhr });
  4253. }, function (errorMessage, xhr) {
  4254. failure({ message: errorMessage, xhr: xhr });
  4255. });
  4256. }
  4257. };
  4258. var JsonFeedEventSourcePlugin = createPlugin({
  4259. eventSourceDefs: [eventSourceDef$2]
  4260. });
  4261. function buildRequestParams(meta, range, calendar) {
  4262. var dateEnv = calendar.dateEnv;
  4263. var startParam;
  4264. var endParam;
  4265. var timeZoneParam;
  4266. var customRequestParams;
  4267. var params = {};
  4268. startParam = meta.startParam;
  4269. if (startParam == null) {
  4270. startParam = calendar.opt('startParam');
  4271. }
  4272. endParam = meta.endParam;
  4273. if (endParam == null) {
  4274. endParam = calendar.opt('endParam');
  4275. }
  4276. timeZoneParam = meta.timeZoneParam;
  4277. if (timeZoneParam == null) {
  4278. timeZoneParam = calendar.opt('timeZoneParam');
  4279. }
  4280. // retrieve any outbound GET/POST data from the options
  4281. if (typeof meta.extraParams === 'function') {
  4282. // supplied as a function that returns a key/value object
  4283. customRequestParams = meta.extraParams();
  4284. }
  4285. else {
  4286. // probably supplied as a straight key/value object
  4287. customRequestParams = meta.extraParams || {};
  4288. }
  4289. __assign(params, customRequestParams);
  4290. params[startParam] = dateEnv.formatIso(range.start);
  4291. params[endParam] = dateEnv.formatIso(range.end);
  4292. if (dateEnv.timeZone !== 'local') {
  4293. params[timeZoneParam] = dateEnv.timeZone;
  4294. }
  4295. return params;
  4296. }
  4297. var recurring = {
  4298. parse: function (rawEvent, leftoverProps, dateEnv) {
  4299. var createMarker = dateEnv.createMarker.bind(dateEnv);
  4300. var processors = {
  4301. daysOfWeek: null,
  4302. startTime: createDuration,
  4303. endTime: createDuration,
  4304. startRecur: createMarker,
  4305. endRecur: createMarker
  4306. };
  4307. var props = refineProps(rawEvent, processors, {}, leftoverProps);
  4308. var anyValid = false;
  4309. for (var propName in props) {
  4310. if (props[propName] != null) {
  4311. anyValid = true;
  4312. break;
  4313. }
  4314. }
  4315. if (anyValid) {
  4316. var duration = null;
  4317. if ('duration' in leftoverProps) {
  4318. duration = createDuration(leftoverProps.duration);
  4319. delete leftoverProps.duration;
  4320. }
  4321. if (!duration && props.startTime && props.endTime) {
  4322. duration = subtractDurations(props.endTime, props.startTime);
  4323. }
  4324. return {
  4325. allDayGuess: Boolean(!props.startTime && !props.endTime),
  4326. duration: duration,
  4327. typeData: props // doesn't need endTime anymore but oh well
  4328. };
  4329. }
  4330. return null;
  4331. },
  4332. expand: function (typeData, framingRange, dateEnv) {
  4333. var clippedFramingRange = intersectRanges(framingRange, { start: typeData.startRecur, end: typeData.endRecur });
  4334. if (clippedFramingRange) {
  4335. return expandRanges(typeData.daysOfWeek, typeData.startTime, clippedFramingRange, dateEnv);
  4336. }
  4337. else {
  4338. return [];
  4339. }
  4340. }
  4341. };
  4342. var SimpleRecurrencePlugin = createPlugin({
  4343. recurringTypes: [recurring]
  4344. });
  4345. function expandRanges(daysOfWeek, startTime, framingRange, dateEnv) {
  4346. var dowHash = daysOfWeek ? arrayToHash(daysOfWeek) : null;
  4347. var dayMarker = startOfDay(framingRange.start);
  4348. var endMarker = framingRange.end;
  4349. var instanceStarts = [];
  4350. while (dayMarker < endMarker) {
  4351. var instanceStart
  4352. // if everyday, or this particular day-of-week
  4353. = void 0;
  4354. // if everyday, or this particular day-of-week
  4355. if (!dowHash || dowHash[dayMarker.getUTCDay()]) {
  4356. if (startTime) {
  4357. instanceStart = dateEnv.add(dayMarker, startTime);
  4358. }
  4359. else {
  4360. instanceStart = dayMarker;
  4361. }
  4362. instanceStarts.push(instanceStart);
  4363. }
  4364. dayMarker = addDays(dayMarker, 1);
  4365. }
  4366. return instanceStarts;
  4367. }
  4368. var DefaultOptionChangeHandlers = createPlugin({
  4369. optionChangeHandlers: {
  4370. events: function (events, calendar, deepEquals) {
  4371. handleEventSources([events], calendar, deepEquals);
  4372. },
  4373. eventSources: handleEventSources,
  4374. plugins: handlePlugins
  4375. }
  4376. });
  4377. function handleEventSources(inputs, calendar, deepEquals) {
  4378. var unfoundSources = hashValuesToArray(calendar.state.eventSources);
  4379. var newInputs = [];
  4380. for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
  4381. var input = inputs_1[_i];
  4382. var inputFound = false;
  4383. for (var i = 0; i < unfoundSources.length; i++) {
  4384. if (deepEquals(unfoundSources[i]._raw, input)) {
  4385. unfoundSources.splice(i, 1); // delete
  4386. inputFound = true;
  4387. break;
  4388. }
  4389. }
  4390. if (!inputFound) {
  4391. newInputs.push(input);
  4392. }
  4393. }
  4394. for (var _a = 0, unfoundSources_1 = unfoundSources; _a < unfoundSources_1.length; _a++) {
  4395. var unfoundSource = unfoundSources_1[_a];
  4396. calendar.dispatch({
  4397. type: 'REMOVE_EVENT_SOURCE',
  4398. sourceId: unfoundSource.sourceId
  4399. });
  4400. }
  4401. for (var _b = 0, newInputs_1 = newInputs; _b < newInputs_1.length; _b++) {
  4402. var newInput = newInputs_1[_b];
  4403. calendar.addEventSource(newInput);
  4404. }
  4405. }
  4406. // shortcoming: won't remove plugins
  4407. function handlePlugins(inputs, calendar) {
  4408. calendar.addPluginInputs(inputs); // will gracefully handle duplicates
  4409. }
  4410. var config = {}; // TODO: make these options
  4411. var globalDefaults = {
  4412. defaultRangeSeparator: ' - ',
  4413. titleRangeSeparator: ' \u2013 ',
  4414. defaultTimedEventDuration: '01:00:00',
  4415. defaultAllDayEventDuration: { day: 1 },
  4416. forceEventDuration: false,
  4417. nextDayThreshold: '00:00:00',
  4418. // display
  4419. columnHeader: true,
  4420. defaultView: '',
  4421. aspectRatio: 1.35,
  4422. header: {
  4423. left: 'title',
  4424. center: '',
  4425. right: 'today prev,next'
  4426. },
  4427. weekends: true,
  4428. weekNumbers: false,
  4429. weekNumberCalculation: 'local',
  4430. editable: false,
  4431. // nowIndicator: false,
  4432. scrollTime: '06:00:00',
  4433. minTime: '00:00:00',
  4434. maxTime: '24:00:00',
  4435. showNonCurrentDates: true,
  4436. // event ajax
  4437. lazyFetching: true,
  4438. startParam: 'start',
  4439. endParam: 'end',
  4440. timeZoneParam: 'timeZone',
  4441. timeZone: 'local',
  4442. // allDayDefault: undefined,
  4443. // locale
  4444. locales: [],
  4445. locale: '',
  4446. // dir: will get this from the default locale
  4447. // buttonIcons: null,
  4448. // allows setting a min-height to the event segment to prevent short events overlapping each other
  4449. timeGridEventMinHeight: 0,
  4450. themeSystem: 'standard',
  4451. // eventResizableFromStart: false,
  4452. dragRevertDuration: 500,
  4453. dragScroll: true,
  4454. allDayMaintainDuration: false,
  4455. // selectable: false,
  4456. unselectAuto: true,
  4457. // selectMinDistance: 0,
  4458. dropAccept: '*',
  4459. eventOrder: 'start,-duration,allDay,title',
  4460. // ^ if start tie, longer events go before shorter. final tie-breaker is title text
  4461. // rerenderDelay: null,
  4462. eventLimit: false,
  4463. eventLimitClick: 'popover',
  4464. dayPopoverFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  4465. handleWindowResize: true,
  4466. windowResizeDelay: 100,
  4467. longPressDelay: 1000,
  4468. eventDragMinDistance: 5 // only applies to mouse
  4469. };
  4470. var rtlDefaults = {
  4471. header: {
  4472. left: 'next,prev today',
  4473. center: '',
  4474. right: 'title'
  4475. },
  4476. buttonIcons: {
  4477. // TODO: make RTL support the responibility of the theme
  4478. prev: 'fc-icon-chevron-right',
  4479. next: 'fc-icon-chevron-left',
  4480. prevYear: 'fc-icon-chevrons-right',
  4481. nextYear: 'fc-icon-chevrons-left'
  4482. }
  4483. };
  4484. var complexOptions = [
  4485. 'header',
  4486. 'footer',
  4487. 'buttonText',
  4488. 'buttonIcons'
  4489. ];
  4490. // Merges an array of option objects into a single object
  4491. function mergeOptions(optionObjs) {
  4492. return mergeProps(optionObjs, complexOptions);
  4493. }
  4494. // TODO: move this stuff to a "plugin"-related file...
  4495. var INTERNAL_PLUGINS = [
  4496. ArrayEventSourcePlugin,
  4497. FuncEventSourcePlugin,
  4498. JsonFeedEventSourcePlugin,
  4499. SimpleRecurrencePlugin,
  4500. DefaultOptionChangeHandlers
  4501. ];
  4502. function refinePluginDefs(pluginInputs) {
  4503. var plugins = [];
  4504. for (var _i = 0, pluginInputs_1 = pluginInputs; _i < pluginInputs_1.length; _i++) {
  4505. var pluginInput = pluginInputs_1[_i];
  4506. if (typeof pluginInput === 'string') {
  4507. var globalName = 'FullCalendar' + capitaliseFirstLetter(pluginInput);
  4508. if (!window[globalName]) {
  4509. console.warn('Plugin file not loaded for ' + pluginInput);
  4510. }
  4511. else {
  4512. plugins.push(window[globalName].default); // is an ES6 module
  4513. }
  4514. }
  4515. else {
  4516. plugins.push(pluginInput);
  4517. }
  4518. }
  4519. return INTERNAL_PLUGINS.concat(plugins);
  4520. }
  4521. var RAW_EN_LOCALE = {
  4522. code: 'en',
  4523. week: {
  4524. dow: 0,
  4525. doy: 4 // 4 days need to be within the year to be considered the first week
  4526. },
  4527. dir: 'ltr',
  4528. buttonText: {
  4529. prev: 'prev',
  4530. next: 'next',
  4531. prevYear: 'prev year',
  4532. nextYear: 'next year',
  4533. year: 'year',
  4534. today: 'today',
  4535. month: 'month',
  4536. week: 'week',
  4537. day: 'day',
  4538. list: 'list'
  4539. },
  4540. weekLabel: 'W',
  4541. allDayText: 'all-day',
  4542. eventLimitText: 'more',
  4543. noEventsMessage: 'No events to display'
  4544. };
  4545. function parseRawLocales(explicitRawLocales) {
  4546. var defaultCode = explicitRawLocales.length > 0 ? explicitRawLocales[0].code : 'en';
  4547. var globalArray = window['FullCalendarLocalesAll'] || []; // from locales-all.js
  4548. var globalObject = window['FullCalendarLocales'] || {}; // from locales/*.js. keys are meaningless
  4549. var allRawLocales = globalArray.concat(// globalArray is low prio
  4550. hashValuesToArray(globalObject), // medium prio
  4551. explicitRawLocales // highest prio
  4552. );
  4553. var rawLocaleMap = {
  4554. en: RAW_EN_LOCALE // necessary?
  4555. };
  4556. for (var _i = 0, allRawLocales_1 = allRawLocales; _i < allRawLocales_1.length; _i++) {
  4557. var rawLocale = allRawLocales_1[_i];
  4558. rawLocaleMap[rawLocale.code] = rawLocale;
  4559. }
  4560. return {
  4561. map: rawLocaleMap,
  4562. defaultCode: defaultCode
  4563. };
  4564. }
  4565. function buildLocale(inputSingular, available) {
  4566. if (typeof inputSingular === 'object' && !Array.isArray(inputSingular)) {
  4567. return parseLocale(inputSingular.code, [inputSingular.code], inputSingular);
  4568. }
  4569. else {
  4570. return queryLocale(inputSingular, available);
  4571. }
  4572. }
  4573. function queryLocale(codeArg, available) {
  4574. var codes = [].concat(codeArg || []); // will convert to array
  4575. var raw = queryRawLocale(codes, available) || RAW_EN_LOCALE;
  4576. return parseLocale(codeArg, codes, raw);
  4577. }
  4578. function queryRawLocale(codes, available) {
  4579. for (var i = 0; i < codes.length; i++) {
  4580. var parts = codes[i].toLocaleLowerCase().split('-');
  4581. for (var j = parts.length; j > 0; j--) {
  4582. var simpleId = parts.slice(0, j).join('-');
  4583. if (available[simpleId]) {
  4584. return available[simpleId];
  4585. }
  4586. }
  4587. }
  4588. return null;
  4589. }
  4590. function parseLocale(codeArg, codes, raw) {
  4591. var merged = mergeProps([RAW_EN_LOCALE, raw], ['buttonText']);
  4592. delete merged.code; // don't want this part of the options
  4593. var week = merged.week;
  4594. delete merged.week;
  4595. return {
  4596. codeArg: codeArg,
  4597. codes: codes,
  4598. week: week,
  4599. simpleNumberFormat: new Intl.NumberFormat(codeArg),
  4600. options: merged
  4601. };
  4602. }
  4603. var OptionsManager = /** @class */ (function () {
  4604. function OptionsManager(overrides) {
  4605. this.overrides = __assign({}, overrides); // make a copy
  4606. this.dynamicOverrides = {};
  4607. this.compute();
  4608. }
  4609. OptionsManager.prototype.mutate = function (updates, removals, isDynamic) {
  4610. var overrideHash = isDynamic ? this.dynamicOverrides : this.overrides;
  4611. __assign(overrideHash, updates);
  4612. for (var _i = 0, removals_1 = removals; _i < removals_1.length; _i++) {
  4613. var propName = removals_1[_i];
  4614. delete overrideHash[propName];
  4615. }
  4616. this.compute();
  4617. };
  4618. // Computes the flattened options hash for the calendar and assigns to `this.options`.
  4619. // Assumes this.overrides and this.dynamicOverrides have already been initialized.
  4620. OptionsManager.prototype.compute = function () {
  4621. // TODO: not a very efficient system
  4622. var locales = firstDefined(// explicit locale option given?
  4623. this.dynamicOverrides.locales, this.overrides.locales, globalDefaults.locales);
  4624. var locale = firstDefined(// explicit locales option given?
  4625. this.dynamicOverrides.locale, this.overrides.locale, globalDefaults.locale);
  4626. var available = parseRawLocales(locales);
  4627. var localeDefaults = buildLocale(locale || available.defaultCode, available.map).options;
  4628. var dir = firstDefined(// based on options computed so far, is direction RTL?
  4629. this.dynamicOverrides.dir, this.overrides.dir, localeDefaults.dir);
  4630. var dirDefaults = dir === 'rtl' ? rtlDefaults : {};
  4631. this.dirDefaults = dirDefaults;
  4632. this.localeDefaults = localeDefaults;
  4633. this.computed = mergeOptions([
  4634. globalDefaults,
  4635. dirDefaults,
  4636. localeDefaults,
  4637. this.overrides,
  4638. this.dynamicOverrides
  4639. ]);
  4640. };
  4641. return OptionsManager;
  4642. }());
  4643. var calendarSystemClassMap = {};
  4644. function registerCalendarSystem(name, theClass) {
  4645. calendarSystemClassMap[name] = theClass;
  4646. }
  4647. function createCalendarSystem(name) {
  4648. return new calendarSystemClassMap[name]();
  4649. }
  4650. var GregorianCalendarSystem = /** @class */ (function () {
  4651. function GregorianCalendarSystem() {
  4652. }
  4653. GregorianCalendarSystem.prototype.getMarkerYear = function (d) {
  4654. return d.getUTCFullYear();
  4655. };
  4656. GregorianCalendarSystem.prototype.getMarkerMonth = function (d) {
  4657. return d.getUTCMonth();
  4658. };
  4659. GregorianCalendarSystem.prototype.getMarkerDay = function (d) {
  4660. return d.getUTCDate();
  4661. };
  4662. GregorianCalendarSystem.prototype.arrayToMarker = function (arr) {
  4663. return arrayToUtcDate(arr);
  4664. };
  4665. GregorianCalendarSystem.prototype.markerToArray = function (marker) {
  4666. return dateToUtcArray(marker);
  4667. };
  4668. return GregorianCalendarSystem;
  4669. }());
  4670. registerCalendarSystem('gregory', GregorianCalendarSystem);
  4671. var ISO_RE = /^\s*(\d{4})(-(\d{2})(-(\d{2})([T ](\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/;
  4672. function parse(str) {
  4673. var m = ISO_RE.exec(str);
  4674. if (m) {
  4675. var marker = new Date(Date.UTC(Number(m[1]), m[3] ? Number(m[3]) - 1 : 0, Number(m[5] || 1), Number(m[7] || 0), Number(m[8] || 0), Number(m[10] || 0), m[12] ? Number('0.' + m[12]) * 1000 : 0));
  4676. if (isValidDate(marker)) {
  4677. var timeZoneOffset = null;
  4678. if (m[13]) {
  4679. timeZoneOffset = (m[15] === '-' ? -1 : 1) * (Number(m[16] || 0) * 60 +
  4680. Number(m[18] || 0));
  4681. }
  4682. return {
  4683. marker: marker,
  4684. isTimeUnspecified: !m[6],
  4685. timeZoneOffset: timeZoneOffset
  4686. };
  4687. }
  4688. }
  4689. return null;
  4690. }
  4691. var DateEnv = /** @class */ (function () {
  4692. function DateEnv(settings) {
  4693. var timeZone = this.timeZone = settings.timeZone;
  4694. var isNamedTimeZone = timeZone !== 'local' && timeZone !== 'UTC';
  4695. if (settings.namedTimeZoneImpl && isNamedTimeZone) {
  4696. this.namedTimeZoneImpl = new settings.namedTimeZoneImpl(timeZone);
  4697. }
  4698. this.canComputeOffset = Boolean(!isNamedTimeZone || this.namedTimeZoneImpl);
  4699. this.calendarSystem = createCalendarSystem(settings.calendarSystem);
  4700. this.locale = settings.locale;
  4701. this.weekDow = settings.locale.week.dow;
  4702. this.weekDoy = settings.locale.week.doy;
  4703. if (settings.weekNumberCalculation === 'ISO') {
  4704. this.weekDow = 1;
  4705. this.weekDoy = 4;
  4706. }
  4707. else if (typeof settings.firstDay === 'number') {
  4708. this.weekDow = settings.firstDay;
  4709. }
  4710. if (typeof settings.weekNumberCalculation === 'function') {
  4711. this.weekNumberFunc = settings.weekNumberCalculation;
  4712. }
  4713. this.weekLabel = settings.weekLabel != null ? settings.weekLabel : settings.locale.options.weekLabel;
  4714. this.cmdFormatter = settings.cmdFormatter;
  4715. }
  4716. // Creating / Parsing
  4717. DateEnv.prototype.createMarker = function (input) {
  4718. var meta = this.createMarkerMeta(input);
  4719. if (meta === null) {
  4720. return null;
  4721. }
  4722. return meta.marker;
  4723. };
  4724. DateEnv.prototype.createNowMarker = function () {
  4725. if (this.canComputeOffset) {
  4726. return this.timestampToMarker(new Date().valueOf());
  4727. }
  4728. else {
  4729. // if we can't compute the current date val for a timezone,
  4730. // better to give the current local date vals than UTC
  4731. return arrayToUtcDate(dateToLocalArray(new Date()));
  4732. }
  4733. };
  4734. DateEnv.prototype.createMarkerMeta = function (input) {
  4735. if (typeof input === 'string') {
  4736. return this.parse(input);
  4737. }
  4738. var marker = null;
  4739. if (typeof input === 'number') {
  4740. marker = this.timestampToMarker(input);
  4741. }
  4742. else if (input instanceof Date) {
  4743. input = input.valueOf();
  4744. if (!isNaN(input)) {
  4745. marker = this.timestampToMarker(input);
  4746. }
  4747. }
  4748. else if (Array.isArray(input)) {
  4749. marker = arrayToUtcDate(input);
  4750. }
  4751. if (marker === null || !isValidDate(marker)) {
  4752. return null;
  4753. }
  4754. return { marker: marker, isTimeUnspecified: false, forcedTzo: null };
  4755. };
  4756. DateEnv.prototype.parse = function (s) {
  4757. var parts = parse(s);
  4758. if (parts === null) {
  4759. return null;
  4760. }
  4761. var marker = parts.marker;
  4762. var forcedTzo = null;
  4763. if (parts.timeZoneOffset !== null) {
  4764. if (this.canComputeOffset) {
  4765. marker = this.timestampToMarker(marker.valueOf() - parts.timeZoneOffset * 60 * 1000);
  4766. }
  4767. else {
  4768. forcedTzo = parts.timeZoneOffset;
  4769. }
  4770. }
  4771. return { marker: marker, isTimeUnspecified: parts.isTimeUnspecified, forcedTzo: forcedTzo };
  4772. };
  4773. // Accessors
  4774. DateEnv.prototype.getYear = function (marker) {
  4775. return this.calendarSystem.getMarkerYear(marker);
  4776. };
  4777. DateEnv.prototype.getMonth = function (marker) {
  4778. return this.calendarSystem.getMarkerMonth(marker);
  4779. };
  4780. // Adding / Subtracting
  4781. DateEnv.prototype.add = function (marker, dur) {
  4782. var a = this.calendarSystem.markerToArray(marker);
  4783. a[0] += dur.years;
  4784. a[1] += dur.months;
  4785. a[2] += dur.days;
  4786. a[6] += dur.milliseconds;
  4787. return this.calendarSystem.arrayToMarker(a);
  4788. };
  4789. DateEnv.prototype.subtract = function (marker, dur) {
  4790. var a = this.calendarSystem.markerToArray(marker);
  4791. a[0] -= dur.years;
  4792. a[1] -= dur.months;
  4793. a[2] -= dur.days;
  4794. a[6] -= dur.milliseconds;
  4795. return this.calendarSystem.arrayToMarker(a);
  4796. };
  4797. DateEnv.prototype.addYears = function (marker, n) {
  4798. var a = this.calendarSystem.markerToArray(marker);
  4799. a[0] += n;
  4800. return this.calendarSystem.arrayToMarker(a);
  4801. };
  4802. DateEnv.prototype.addMonths = function (marker, n) {
  4803. var a = this.calendarSystem.markerToArray(marker);
  4804. a[1] += n;
  4805. return this.calendarSystem.arrayToMarker(a);
  4806. };
  4807. // Diffing Whole Units
  4808. DateEnv.prototype.diffWholeYears = function (m0, m1) {
  4809. var calendarSystem = this.calendarSystem;
  4810. if (timeAsMs(m0) === timeAsMs(m1) &&
  4811. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1) &&
  4812. calendarSystem.getMarkerMonth(m0) === calendarSystem.getMarkerMonth(m1)) {
  4813. return calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0);
  4814. }
  4815. return null;
  4816. };
  4817. DateEnv.prototype.diffWholeMonths = function (m0, m1) {
  4818. var calendarSystem = this.calendarSystem;
  4819. if (timeAsMs(m0) === timeAsMs(m1) &&
  4820. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1)) {
  4821. return (calendarSystem.getMarkerMonth(m1) - calendarSystem.getMarkerMonth(m0)) +
  4822. (calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0)) * 12;
  4823. }
  4824. return null;
  4825. };
  4826. // Range / Duration
  4827. DateEnv.prototype.greatestWholeUnit = function (m0, m1) {
  4828. var n = this.diffWholeYears(m0, m1);
  4829. if (n !== null) {
  4830. return { unit: 'year', value: n };
  4831. }
  4832. n = this.diffWholeMonths(m0, m1);
  4833. if (n !== null) {
  4834. return { unit: 'month', value: n };
  4835. }
  4836. n = diffWholeWeeks(m0, m1);
  4837. if (n !== null) {
  4838. return { unit: 'week', value: n };
  4839. }
  4840. n = diffWholeDays(m0, m1);
  4841. if (n !== null) {
  4842. return { unit: 'day', value: n };
  4843. }
  4844. n = diffHours(m0, m1);
  4845. if (isInt(n)) {
  4846. return { unit: 'hour', value: n };
  4847. }
  4848. n = diffMinutes(m0, m1);
  4849. if (isInt(n)) {
  4850. return { unit: 'minute', value: n };
  4851. }
  4852. n = diffSeconds(m0, m1);
  4853. if (isInt(n)) {
  4854. return { unit: 'second', value: n };
  4855. }
  4856. return { unit: 'millisecond', value: m1.valueOf() - m0.valueOf() };
  4857. };
  4858. DateEnv.prototype.countDurationsBetween = function (m0, m1, d) {
  4859. // TODO: can use greatestWholeUnit
  4860. var diff;
  4861. if (d.years) {
  4862. diff = this.diffWholeYears(m0, m1);
  4863. if (diff !== null) {
  4864. return diff / asRoughYears(d);
  4865. }
  4866. }
  4867. if (d.months) {
  4868. diff = this.diffWholeMonths(m0, m1);
  4869. if (diff !== null) {
  4870. return diff / asRoughMonths(d);
  4871. }
  4872. }
  4873. if (d.days) {
  4874. diff = diffWholeDays(m0, m1);
  4875. if (diff !== null) {
  4876. return diff / asRoughDays(d);
  4877. }
  4878. }
  4879. return (m1.valueOf() - m0.valueOf()) / asRoughMs(d);
  4880. };
  4881. // Start-Of
  4882. DateEnv.prototype.startOf = function (m, unit) {
  4883. if (unit === 'year') {
  4884. return this.startOfYear(m);
  4885. }
  4886. else if (unit === 'month') {
  4887. return this.startOfMonth(m);
  4888. }
  4889. else if (unit === 'week') {
  4890. return this.startOfWeek(m);
  4891. }
  4892. else if (unit === 'day') {
  4893. return startOfDay(m);
  4894. }
  4895. else if (unit === 'hour') {
  4896. return startOfHour(m);
  4897. }
  4898. else if (unit === 'minute') {
  4899. return startOfMinute(m);
  4900. }
  4901. else if (unit === 'second') {
  4902. return startOfSecond(m);
  4903. }
  4904. };
  4905. DateEnv.prototype.startOfYear = function (m) {
  4906. return this.calendarSystem.arrayToMarker([
  4907. this.calendarSystem.getMarkerYear(m)
  4908. ]);
  4909. };
  4910. DateEnv.prototype.startOfMonth = function (m) {
  4911. return this.calendarSystem.arrayToMarker([
  4912. this.calendarSystem.getMarkerYear(m),
  4913. this.calendarSystem.getMarkerMonth(m)
  4914. ]);
  4915. };
  4916. DateEnv.prototype.startOfWeek = function (m) {
  4917. return this.calendarSystem.arrayToMarker([
  4918. this.calendarSystem.getMarkerYear(m),
  4919. this.calendarSystem.getMarkerMonth(m),
  4920. m.getUTCDate() - ((m.getUTCDay() - this.weekDow + 7) % 7)
  4921. ]);
  4922. };
  4923. // Week Number
  4924. DateEnv.prototype.computeWeekNumber = function (marker) {
  4925. if (this.weekNumberFunc) {
  4926. return this.weekNumberFunc(this.toDate(marker));
  4927. }
  4928. else {
  4929. return weekOfYear(marker, this.weekDow, this.weekDoy);
  4930. }
  4931. };
  4932. // TODO: choke on timeZoneName: long
  4933. DateEnv.prototype.format = function (marker, formatter, dateOptions) {
  4934. if (dateOptions === void 0) { dateOptions = {}; }
  4935. return formatter.format({
  4936. marker: marker,
  4937. timeZoneOffset: dateOptions.forcedTzo != null ?
  4938. dateOptions.forcedTzo :
  4939. this.offsetForMarker(marker)
  4940. }, this);
  4941. };
  4942. DateEnv.prototype.formatRange = function (start, end, formatter, dateOptions) {
  4943. if (dateOptions === void 0) { dateOptions = {}; }
  4944. if (dateOptions.isEndExclusive) {
  4945. end = addMs(end, -1);
  4946. }
  4947. return formatter.formatRange({
  4948. marker: start,
  4949. timeZoneOffset: dateOptions.forcedStartTzo != null ?
  4950. dateOptions.forcedStartTzo :
  4951. this.offsetForMarker(start)
  4952. }, {
  4953. marker: end,
  4954. timeZoneOffset: dateOptions.forcedEndTzo != null ?
  4955. dateOptions.forcedEndTzo :
  4956. this.offsetForMarker(end)
  4957. }, this);
  4958. };
  4959. DateEnv.prototype.formatIso = function (marker, extraOptions) {
  4960. if (extraOptions === void 0) { extraOptions = {}; }
  4961. var timeZoneOffset = null;
  4962. if (!extraOptions.omitTimeZoneOffset) {
  4963. if (extraOptions.forcedTzo != null) {
  4964. timeZoneOffset = extraOptions.forcedTzo;
  4965. }
  4966. else {
  4967. timeZoneOffset = this.offsetForMarker(marker);
  4968. }
  4969. }
  4970. return buildIsoString(marker, timeZoneOffset, extraOptions.omitTime);
  4971. };
  4972. // TimeZone
  4973. DateEnv.prototype.timestampToMarker = function (ms) {
  4974. if (this.timeZone === 'local') {
  4975. return arrayToUtcDate(dateToLocalArray(new Date(ms)));
  4976. }
  4977. else if (this.timeZone === 'UTC' || !this.namedTimeZoneImpl) {
  4978. return new Date(ms);
  4979. }
  4980. else {
  4981. return arrayToUtcDate(this.namedTimeZoneImpl.timestampToArray(ms));
  4982. }
  4983. };
  4984. DateEnv.prototype.offsetForMarker = function (m) {
  4985. if (this.timeZone === 'local') {
  4986. return -arrayToLocalDate(dateToUtcArray(m)).getTimezoneOffset(); // convert "inverse" offset to "normal" offset
  4987. }
  4988. else if (this.timeZone === 'UTC') {
  4989. return 0;
  4990. }
  4991. else if (this.namedTimeZoneImpl) {
  4992. return this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m));
  4993. }
  4994. return null;
  4995. };
  4996. // Conversion
  4997. DateEnv.prototype.toDate = function (m, forcedTzo) {
  4998. if (this.timeZone === 'local') {
  4999. return arrayToLocalDate(dateToUtcArray(m));
  5000. }
  5001. else if (this.timeZone === 'UTC') {
  5002. return new Date(m.valueOf()); // make sure it's a copy
  5003. }
  5004. else if (!this.namedTimeZoneImpl) {
  5005. return new Date(m.valueOf() - (forcedTzo || 0));
  5006. }
  5007. else {
  5008. return new Date(m.valueOf() -
  5009. this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m)) * 1000 * 60 // convert minutes -> ms
  5010. );
  5011. }
  5012. };
  5013. return DateEnv;
  5014. }());
  5015. var SIMPLE_SOURCE_PROPS = {
  5016. id: String,
  5017. allDayDefault: Boolean,
  5018. eventDataTransform: Function,
  5019. success: Function,
  5020. failure: Function
  5021. };
  5022. var uid$2 = 0;
  5023. function doesSourceNeedRange(eventSource, calendar) {
  5024. var defs = calendar.pluginSystem.hooks.eventSourceDefs;
  5025. return !defs[eventSource.sourceDefId].ignoreRange;
  5026. }
  5027. function parseEventSource(raw, calendar) {
  5028. var defs = calendar.pluginSystem.hooks.eventSourceDefs;
  5029. for (var i = defs.length - 1; i >= 0; i--) { // later-added plugins take precedence
  5030. var def = defs[i];
  5031. var meta = def.parseMeta(raw);
  5032. if (meta) {
  5033. var res = parseEventSourceProps(typeof raw === 'object' ? raw : {}, meta, i, calendar);
  5034. res._raw = raw;
  5035. return res;
  5036. }
  5037. }
  5038. return null;
  5039. }
  5040. function parseEventSourceProps(raw, meta, sourceDefId, calendar) {
  5041. var leftovers0 = {};
  5042. var props = refineProps(raw, SIMPLE_SOURCE_PROPS, {}, leftovers0);
  5043. var leftovers1 = {};
  5044. var ui = processUnscopedUiProps(leftovers0, calendar, leftovers1);
  5045. props.isFetching = false;
  5046. props.latestFetchId = '';
  5047. props.fetchRange = null;
  5048. props.publicId = String(raw.id || '');
  5049. props.sourceId = String(uid$2++);
  5050. props.sourceDefId = sourceDefId;
  5051. props.meta = meta;
  5052. props.ui = ui;
  5053. props.extendedProps = leftovers1;
  5054. return props;
  5055. }
  5056. function reduceEventSources (eventSources, action, dateProfile, calendar) {
  5057. switch (action.type) {
  5058. case 'ADD_EVENT_SOURCES': // already parsed
  5059. return addSources(eventSources, action.sources, dateProfile ? dateProfile.activeRange : null, calendar);
  5060. case 'REMOVE_EVENT_SOURCE':
  5061. return removeSource(eventSources, action.sourceId);
  5062. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  5063. case 'NEXT':
  5064. case 'SET_DATE':
  5065. case 'SET_VIEW_TYPE':
  5066. if (dateProfile) {
  5067. return fetchDirtySources(eventSources, dateProfile.activeRange, calendar);
  5068. }
  5069. else {
  5070. return eventSources;
  5071. }
  5072. case 'FETCH_EVENT_SOURCES':
  5073. case 'CHANGE_TIMEZONE':
  5074. return fetchSourcesByIds(eventSources, action.sourceIds ?
  5075. arrayToHash(action.sourceIds) :
  5076. excludeStaticSources(eventSources, calendar), dateProfile ? dateProfile.activeRange : null, calendar);
  5077. case 'RECEIVE_EVENTS':
  5078. case 'RECEIVE_EVENT_ERROR':
  5079. return receiveResponse(eventSources, action.sourceId, action.fetchId, action.fetchRange);
  5080. case 'REMOVE_ALL_EVENT_SOURCES':
  5081. return {};
  5082. default:
  5083. return eventSources;
  5084. }
  5085. }
  5086. var uid$3 = 0;
  5087. function addSources(eventSourceHash, sources, fetchRange, calendar) {
  5088. var hash = {};
  5089. for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
  5090. var source = sources_1[_i];
  5091. hash[source.sourceId] = source;
  5092. }
  5093. if (fetchRange) {
  5094. hash = fetchDirtySources(hash, fetchRange, calendar);
  5095. }
  5096. return __assign({}, eventSourceHash, hash);
  5097. }
  5098. function removeSource(eventSourceHash, sourceId) {
  5099. return filterHash(eventSourceHash, function (eventSource) {
  5100. return eventSource.sourceId !== sourceId;
  5101. });
  5102. }
  5103. function fetchDirtySources(sourceHash, fetchRange, calendar) {
  5104. return fetchSourcesByIds(sourceHash, filterHash(sourceHash, function (eventSource) {
  5105. return isSourceDirty(eventSource, fetchRange, calendar);
  5106. }), fetchRange, calendar);
  5107. }
  5108. function isSourceDirty(eventSource, fetchRange, calendar) {
  5109. if (!doesSourceNeedRange(eventSource, calendar)) {
  5110. return !eventSource.latestFetchId;
  5111. }
  5112. else {
  5113. return !calendar.opt('lazyFetching') ||
  5114. !eventSource.fetchRange ||
  5115. fetchRange.start < eventSource.fetchRange.start ||
  5116. fetchRange.end > eventSource.fetchRange.end;
  5117. }
  5118. }
  5119. function fetchSourcesByIds(prevSources, sourceIdHash, fetchRange, calendar) {
  5120. var nextSources = {};
  5121. for (var sourceId in prevSources) {
  5122. var source = prevSources[sourceId];
  5123. if (sourceIdHash[sourceId]) {
  5124. nextSources[sourceId] = fetchSource(source, fetchRange, calendar);
  5125. }
  5126. else {
  5127. nextSources[sourceId] = source;
  5128. }
  5129. }
  5130. return nextSources;
  5131. }
  5132. function fetchSource(eventSource, fetchRange, calendar) {
  5133. var sourceDef = calendar.pluginSystem.hooks.eventSourceDefs[eventSource.sourceDefId];
  5134. var fetchId = String(uid$3++);
  5135. sourceDef.fetch({
  5136. eventSource: eventSource,
  5137. calendar: calendar,
  5138. range: fetchRange
  5139. }, function (res) {
  5140. var rawEvents = res.rawEvents;
  5141. var calSuccess = calendar.opt('eventSourceSuccess');
  5142. var calSuccessRes;
  5143. var sourceSuccessRes;
  5144. if (eventSource.success) {
  5145. sourceSuccessRes = eventSource.success(rawEvents, res.xhr);
  5146. }
  5147. if (calSuccess) {
  5148. calSuccessRes = calSuccess(rawEvents, res.xhr);
  5149. }
  5150. rawEvents = sourceSuccessRes || calSuccessRes || rawEvents;
  5151. calendar.dispatch({
  5152. type: 'RECEIVE_EVENTS',
  5153. sourceId: eventSource.sourceId,
  5154. fetchId: fetchId,
  5155. fetchRange: fetchRange,
  5156. rawEvents: rawEvents
  5157. });
  5158. }, function (error) {
  5159. var callFailure = calendar.opt('eventSourceFailure');
  5160. console.warn(error.message, error);
  5161. if (eventSource.failure) {
  5162. eventSource.failure(error);
  5163. }
  5164. if (callFailure) {
  5165. callFailure(error);
  5166. }
  5167. calendar.dispatch({
  5168. type: 'RECEIVE_EVENT_ERROR',
  5169. sourceId: eventSource.sourceId,
  5170. fetchId: fetchId,
  5171. fetchRange: fetchRange,
  5172. error: error
  5173. });
  5174. });
  5175. return __assign({}, eventSource, { isFetching: true, latestFetchId: fetchId });
  5176. }
  5177. function receiveResponse(sourceHash, sourceId, fetchId, fetchRange) {
  5178. var _a;
  5179. var eventSource = sourceHash[sourceId];
  5180. if (eventSource && // not already removed
  5181. fetchId === eventSource.latestFetchId) {
  5182. return __assign({}, sourceHash, (_a = {}, _a[sourceId] = __assign({}, eventSource, { isFetching: false, fetchRange: fetchRange }), _a));
  5183. }
  5184. return sourceHash;
  5185. }
  5186. function excludeStaticSources(eventSources, calendar) {
  5187. return filterHash(eventSources, function (eventSource) {
  5188. return doesSourceNeedRange(eventSource, calendar);
  5189. });
  5190. }
  5191. var DateProfileGenerator = /** @class */ (function () {
  5192. function DateProfileGenerator(viewSpec, calendar) {
  5193. this.viewSpec = viewSpec;
  5194. this.options = viewSpec.options;
  5195. this.dateEnv = calendar.dateEnv;
  5196. this.calendar = calendar;
  5197. this.initHiddenDays();
  5198. }
  5199. /* Date Range Computation
  5200. ------------------------------------------------------------------------------------------------------------------*/
  5201. // Builds a structure with info about what the dates/ranges will be for the "prev" view.
  5202. DateProfileGenerator.prototype.buildPrev = function (currentDateProfile, currentDate) {
  5203. var dateEnv = this.dateEnv;
  5204. var prevDate = dateEnv.subtract(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5205. currentDateProfile.dateIncrement);
  5206. return this.build(prevDate, -1);
  5207. };
  5208. // Builds a structure with info about what the dates/ranges will be for the "next" view.
  5209. DateProfileGenerator.prototype.buildNext = function (currentDateProfile, currentDate) {
  5210. var dateEnv = this.dateEnv;
  5211. var nextDate = dateEnv.add(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5212. currentDateProfile.dateIncrement);
  5213. return this.build(nextDate, 1);
  5214. };
  5215. // Builds a structure holding dates/ranges for rendering around the given date.
  5216. // Optional direction param indicates whether the date is being incremented/decremented
  5217. // from its previous value. decremented = -1, incremented = 1 (default).
  5218. DateProfileGenerator.prototype.build = function (currentDate, direction, forceToValid) {
  5219. if (forceToValid === void 0) { forceToValid = false; }
  5220. var validRange;
  5221. var minTime = null;
  5222. var maxTime = null;
  5223. var currentInfo;
  5224. var isRangeAllDay;
  5225. var renderRange;
  5226. var activeRange;
  5227. var isValid;
  5228. validRange = this.buildValidRange();
  5229. validRange = this.trimHiddenDays(validRange);
  5230. if (forceToValid) {
  5231. currentDate = constrainMarkerToRange(currentDate, validRange);
  5232. }
  5233. currentInfo = this.buildCurrentRangeInfo(currentDate, direction);
  5234. isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit);
  5235. renderRange = this.buildRenderRange(this.trimHiddenDays(currentInfo.range), currentInfo.unit, isRangeAllDay);
  5236. renderRange = this.trimHiddenDays(renderRange);
  5237. activeRange = renderRange;
  5238. if (!this.options.showNonCurrentDates) {
  5239. activeRange = intersectRanges(activeRange, currentInfo.range);
  5240. }
  5241. minTime = createDuration(this.options.minTime);
  5242. maxTime = createDuration(this.options.maxTime);
  5243. activeRange = this.adjustActiveRange(activeRange, minTime, maxTime);
  5244. activeRange = intersectRanges(activeRange, validRange); // might return null
  5245. // it's invalid if the originally requested date is not contained,
  5246. // or if the range is completely outside of the valid range.
  5247. isValid = rangesIntersect(currentInfo.range, validRange);
  5248. return {
  5249. // constraint for where prev/next operations can go and where events can be dragged/resized to.
  5250. // an object with optional start and end properties.
  5251. validRange: validRange,
  5252. // range the view is formally responsible for.
  5253. // for example, a month view might have 1st-31st, excluding padded dates
  5254. currentRange: currentInfo.range,
  5255. // name of largest unit being displayed, like "month" or "week"
  5256. currentRangeUnit: currentInfo.unit,
  5257. isRangeAllDay: isRangeAllDay,
  5258. // dates that display events and accept drag-n-drop
  5259. // will be `null` if no dates accept events
  5260. activeRange: activeRange,
  5261. // date range with a rendered skeleton
  5262. // includes not-active days that need some sort of DOM
  5263. renderRange: renderRange,
  5264. // Duration object that denotes the first visible time of any given day
  5265. minTime: minTime,
  5266. // Duration object that denotes the exclusive visible end time of any given day
  5267. maxTime: maxTime,
  5268. isValid: isValid,
  5269. // how far the current date will move for a prev/next operation
  5270. dateIncrement: this.buildDateIncrement(currentInfo.duration)
  5271. // pass a fallback (might be null) ^
  5272. };
  5273. };
  5274. // Builds an object with optional start/end properties.
  5275. // Indicates the minimum/maximum dates to display.
  5276. // not responsible for trimming hidden days.
  5277. DateProfileGenerator.prototype.buildValidRange = function () {
  5278. return this.getRangeOption('validRange', this.calendar.getNow()) ||
  5279. { start: null, end: null }; // completely open-ended
  5280. };
  5281. // Builds a structure with info about the "current" range, the range that is
  5282. // highlighted as being the current month for example.
  5283. // See build() for a description of `direction`.
  5284. // Guaranteed to have `range` and `unit` properties. `duration` is optional.
  5285. DateProfileGenerator.prototype.buildCurrentRangeInfo = function (date, direction) {
  5286. var _a = this, viewSpec = _a.viewSpec, dateEnv = _a.dateEnv;
  5287. var duration = null;
  5288. var unit = null;
  5289. var range = null;
  5290. var dayCount;
  5291. if (viewSpec.duration) {
  5292. duration = viewSpec.duration;
  5293. unit = viewSpec.durationUnit;
  5294. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5295. }
  5296. else if ((dayCount = this.options.dayCount)) {
  5297. unit = 'day';
  5298. range = this.buildRangeFromDayCount(date, direction, dayCount);
  5299. }
  5300. else if ((range = this.buildCustomVisibleRange(date))) {
  5301. unit = dateEnv.greatestWholeUnit(range.start, range.end).unit;
  5302. }
  5303. else {
  5304. duration = this.getFallbackDuration();
  5305. unit = greatestDurationDenominator(duration).unit;
  5306. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5307. }
  5308. return { duration: duration, unit: unit, range: range };
  5309. };
  5310. DateProfileGenerator.prototype.getFallbackDuration = function () {
  5311. return createDuration({ day: 1 });
  5312. };
  5313. // Returns a new activeRange to have time values (un-ambiguate)
  5314. // minTime or maxTime causes the range to expand.
  5315. DateProfileGenerator.prototype.adjustActiveRange = function (range, minTime, maxTime) {
  5316. var dateEnv = this.dateEnv;
  5317. var start = range.start;
  5318. var end = range.end;
  5319. if (this.viewSpec.class.prototype.usesMinMaxTime) {
  5320. // expand active range if minTime is negative (why not when positive?)
  5321. if (asRoughDays(minTime) < 0) {
  5322. start = startOfDay(start); // necessary?
  5323. start = dateEnv.add(start, minTime);
  5324. }
  5325. // expand active range if maxTime is beyond one day (why not when positive?)
  5326. if (asRoughDays(maxTime) > 1) {
  5327. end = startOfDay(end); // necessary?
  5328. end = addDays(end, -1);
  5329. end = dateEnv.add(end, maxTime);
  5330. }
  5331. }
  5332. return { start: start, end: end };
  5333. };
  5334. // Builds the "current" range when it is specified as an explicit duration.
  5335. // `unit` is the already-computed greatestDurationDenominator unit of duration.
  5336. DateProfileGenerator.prototype.buildRangeFromDuration = function (date, direction, duration, unit) {
  5337. var dateEnv = this.dateEnv;
  5338. var alignment = this.options.dateAlignment;
  5339. var dateIncrementInput;
  5340. var dateIncrementDuration;
  5341. var start;
  5342. var end;
  5343. var res;
  5344. // compute what the alignment should be
  5345. if (!alignment) {
  5346. dateIncrementInput = this.options.dateIncrement;
  5347. if (dateIncrementInput) {
  5348. dateIncrementDuration = createDuration(dateIncrementInput);
  5349. // use the smaller of the two units
  5350. if (asRoughMs(dateIncrementDuration) < asRoughMs(duration)) {
  5351. alignment = greatestDurationDenominator(dateIncrementDuration, !getWeeksFromInput(dateIncrementInput)).unit;
  5352. }
  5353. else {
  5354. alignment = unit;
  5355. }
  5356. }
  5357. else {
  5358. alignment = unit;
  5359. }
  5360. }
  5361. // if the view displays a single day or smaller
  5362. if (asRoughDays(duration) <= 1) {
  5363. if (this.isHiddenDay(start)) {
  5364. start = this.skipHiddenDays(start, direction);
  5365. start = startOfDay(start);
  5366. }
  5367. }
  5368. function computeRes() {
  5369. start = dateEnv.startOf(date, alignment);
  5370. end = dateEnv.add(start, duration);
  5371. res = { start: start, end: end };
  5372. }
  5373. computeRes();
  5374. // if range is completely enveloped by hidden days, go past the hidden days
  5375. if (!this.trimHiddenDays(res)) {
  5376. date = this.skipHiddenDays(date, direction);
  5377. computeRes();
  5378. }
  5379. return res;
  5380. };
  5381. // Builds the "current" range when a dayCount is specified.
  5382. DateProfileGenerator.prototype.buildRangeFromDayCount = function (date, direction, dayCount) {
  5383. var dateEnv = this.dateEnv;
  5384. var customAlignment = this.options.dateAlignment;
  5385. var runningCount = 0;
  5386. var start = date;
  5387. var end;
  5388. if (customAlignment) {
  5389. start = dateEnv.startOf(start, customAlignment);
  5390. }
  5391. start = startOfDay(start);
  5392. start = this.skipHiddenDays(start, direction);
  5393. end = start;
  5394. do {
  5395. end = addDays(end, 1);
  5396. if (!this.isHiddenDay(end)) {
  5397. runningCount++;
  5398. }
  5399. } while (runningCount < dayCount);
  5400. return { start: start, end: end };
  5401. };
  5402. // Builds a normalized range object for the "visible" range,
  5403. // which is a way to define the currentRange and activeRange at the same time.
  5404. DateProfileGenerator.prototype.buildCustomVisibleRange = function (date) {
  5405. var dateEnv = this.dateEnv;
  5406. var visibleRange = this.getRangeOption('visibleRange', dateEnv.toDate(date));
  5407. if (visibleRange && (visibleRange.start == null || visibleRange.end == null)) {
  5408. return null;
  5409. }
  5410. return visibleRange;
  5411. };
  5412. // Computes the range that will represent the element/cells for *rendering*,
  5413. // but which may have voided days/times.
  5414. // not responsible for trimming hidden days.
  5415. DateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  5416. return currentRange;
  5417. };
  5418. // Compute the duration value that should be added/substracted to the current date
  5419. // when a prev/next operation happens.
  5420. DateProfileGenerator.prototype.buildDateIncrement = function (fallback) {
  5421. var dateIncrementInput = this.options.dateIncrement;
  5422. var customAlignment;
  5423. if (dateIncrementInput) {
  5424. return createDuration(dateIncrementInput);
  5425. }
  5426. else if ((customAlignment = this.options.dateAlignment)) {
  5427. return createDuration(1, customAlignment);
  5428. }
  5429. else if (fallback) {
  5430. return fallback;
  5431. }
  5432. else {
  5433. return createDuration({ days: 1 });
  5434. }
  5435. };
  5436. // Arguments after name will be forwarded to a hypothetical function value
  5437. // WARNING: passed-in arguments will be given to generator functions as-is and can cause side-effects.
  5438. // Always clone your objects if you fear mutation.
  5439. DateProfileGenerator.prototype.getRangeOption = function (name) {
  5440. var otherArgs = [];
  5441. for (var _i = 1; _i < arguments.length; _i++) {
  5442. otherArgs[_i - 1] = arguments[_i];
  5443. }
  5444. var val = this.options[name];
  5445. if (typeof val === 'function') {
  5446. val = val.apply(null, otherArgs);
  5447. }
  5448. if (val) {
  5449. val = parseRange(val, this.dateEnv);
  5450. }
  5451. if (val) {
  5452. val = computeVisibleDayRange(val);
  5453. }
  5454. return val;
  5455. };
  5456. /* Hidden Days
  5457. ------------------------------------------------------------------------------------------------------------------*/
  5458. // Initializes internal variables related to calculating hidden days-of-week
  5459. DateProfileGenerator.prototype.initHiddenDays = function () {
  5460. var hiddenDays = this.options.hiddenDays || []; // array of day-of-week indices that are hidden
  5461. var isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool)
  5462. var dayCnt = 0;
  5463. var i;
  5464. if (this.options.weekends === false) {
  5465. hiddenDays.push(0, 6); // 0=sunday, 6=saturday
  5466. }
  5467. for (i = 0; i < 7; i++) {
  5468. if (!(isHiddenDayHash[i] = hiddenDays.indexOf(i) !== -1)) {
  5469. dayCnt++;
  5470. }
  5471. }
  5472. if (!dayCnt) {
  5473. throw new Error('invalid hiddenDays'); // all days were hidden? bad.
  5474. }
  5475. this.isHiddenDayHash = isHiddenDayHash;
  5476. };
  5477. // Remove days from the beginning and end of the range that are computed as hidden.
  5478. // If the whole range is trimmed off, returns null
  5479. DateProfileGenerator.prototype.trimHiddenDays = function (range) {
  5480. var start = range.start;
  5481. var end = range.end;
  5482. if (start) {
  5483. start = this.skipHiddenDays(start);
  5484. }
  5485. if (end) {
  5486. end = this.skipHiddenDays(end, -1, true);
  5487. }
  5488. if (start == null || end == null || start < end) {
  5489. return { start: start, end: end };
  5490. }
  5491. return null;
  5492. };
  5493. // Is the current day hidden?
  5494. // `day` is a day-of-week index (0-6), or a Date (used for UTC)
  5495. DateProfileGenerator.prototype.isHiddenDay = function (day) {
  5496. if (day instanceof Date) {
  5497. day = day.getUTCDay();
  5498. }
  5499. return this.isHiddenDayHash[day];
  5500. };
  5501. // Incrementing the current day until it is no longer a hidden day, returning a copy.
  5502. // DOES NOT CONSIDER validRange!
  5503. // If the initial value of `date` is not a hidden day, don't do anything.
  5504. // Pass `isExclusive` as `true` if you are dealing with an end date.
  5505. // `inc` defaults to `1` (increment one day forward each time)
  5506. DateProfileGenerator.prototype.skipHiddenDays = function (date, inc, isExclusive) {
  5507. if (inc === void 0) { inc = 1; }
  5508. if (isExclusive === void 0) { isExclusive = false; }
  5509. while (this.isHiddenDayHash[(date.getUTCDay() + (isExclusive ? inc : 0) + 7) % 7]) {
  5510. date = addDays(date, inc);
  5511. }
  5512. return date;
  5513. };
  5514. return DateProfileGenerator;
  5515. }());
  5516. // TODO: find a way to avoid comparing DateProfiles. it's tedious
  5517. function isDateProfilesEqual(p0, p1) {
  5518. return rangesEqual(p0.activeRange, p1.activeRange) &&
  5519. rangesEqual(p0.validRange, p1.validRange) &&
  5520. durationsEqual(p0.minTime, p1.minTime) &&
  5521. durationsEqual(p0.maxTime, p1.maxTime);
  5522. }
  5523. function reduce (state, action, calendar) {
  5524. var viewType = reduceViewType(state.viewType, action);
  5525. var dateProfile = reduceDateProfile(state.dateProfile, action, state.currentDate, viewType, calendar);
  5526. var eventSources = reduceEventSources(state.eventSources, action, dateProfile, calendar);
  5527. var nextState = __assign({}, state, { viewType: viewType,
  5528. dateProfile: dateProfile, currentDate: reduceCurrentDate(state.currentDate, action, dateProfile), eventSources: eventSources, eventStore: reduceEventStore(state.eventStore, action, eventSources, dateProfile, calendar), dateSelection: reduceDateSelection(state.dateSelection, action, calendar), eventSelection: reduceSelectedEvent(state.eventSelection, action), eventDrag: reduceEventDrag(state.eventDrag, action, eventSources, calendar), eventResize: reduceEventResize(state.eventResize, action, eventSources, calendar), eventSourceLoadingLevel: computeLoadingLevel(eventSources), loadingLevel: computeLoadingLevel(eventSources) });
  5529. for (var _i = 0, _a = calendar.pluginSystem.hooks.reducers; _i < _a.length; _i++) {
  5530. var reducerFunc = _a[_i];
  5531. nextState = reducerFunc(nextState, action, calendar);
  5532. }
  5533. // console.log(action.type, nextState)
  5534. return nextState;
  5535. }
  5536. function reduceViewType(currentViewType, action) {
  5537. switch (action.type) {
  5538. case 'SET_VIEW_TYPE':
  5539. return action.viewType;
  5540. default:
  5541. return currentViewType;
  5542. }
  5543. }
  5544. function reduceDateProfile(currentDateProfile, action, currentDate, viewType, calendar) {
  5545. var newDateProfile;
  5546. switch (action.type) {
  5547. case 'PREV':
  5548. newDateProfile = calendar.dateProfileGenerators[viewType].buildPrev(currentDateProfile, currentDate);
  5549. break;
  5550. case 'NEXT':
  5551. newDateProfile = calendar.dateProfileGenerators[viewType].buildNext(currentDateProfile, currentDate);
  5552. break;
  5553. case 'SET_DATE':
  5554. if (!currentDateProfile.activeRange ||
  5555. !rangeContainsMarker(currentDateProfile.currentRange, action.dateMarker)) {
  5556. newDateProfile = calendar.dateProfileGenerators[viewType].build(action.dateMarker, undefined, true // forceToValid
  5557. );
  5558. }
  5559. break;
  5560. case 'SET_VIEW_TYPE':
  5561. var generator = calendar.dateProfileGenerators[viewType];
  5562. if (!generator) {
  5563. throw new Error(viewType ?
  5564. 'The FullCalendar view "' + viewType + '" does not exist. Make sure your plugins are loaded correctly.' :
  5565. 'No available FullCalendar view plugins.');
  5566. }
  5567. newDateProfile = generator.build(action.dateMarker || currentDate, undefined, true // forceToValid
  5568. );
  5569. break;
  5570. }
  5571. if (newDateProfile &&
  5572. newDateProfile.isValid &&
  5573. !(currentDateProfile && isDateProfilesEqual(currentDateProfile, newDateProfile))) {
  5574. return newDateProfile;
  5575. }
  5576. else {
  5577. return currentDateProfile;
  5578. }
  5579. }
  5580. function reduceCurrentDate(currentDate, action, dateProfile) {
  5581. switch (action.type) {
  5582. case 'PREV':
  5583. case 'NEXT':
  5584. if (!rangeContainsMarker(dateProfile.currentRange, currentDate)) {
  5585. return dateProfile.currentRange.start;
  5586. }
  5587. else {
  5588. return currentDate;
  5589. }
  5590. case 'SET_DATE':
  5591. case 'SET_VIEW_TYPE':
  5592. var newDate = action.dateMarker || currentDate;
  5593. if (dateProfile.activeRange && !rangeContainsMarker(dateProfile.activeRange, newDate)) {
  5594. return dateProfile.currentRange.start;
  5595. }
  5596. else {
  5597. return newDate;
  5598. }
  5599. default:
  5600. return currentDate;
  5601. }
  5602. }
  5603. function reduceDateSelection(currentSelection, action, calendar) {
  5604. switch (action.type) {
  5605. case 'SELECT_DATES':
  5606. return action.selection;
  5607. case 'UNSELECT_DATES':
  5608. return null;
  5609. default:
  5610. return currentSelection;
  5611. }
  5612. }
  5613. function reduceSelectedEvent(currentInstanceId, action) {
  5614. switch (action.type) {
  5615. case 'SELECT_EVENT':
  5616. return action.eventInstanceId;
  5617. case 'UNSELECT_EVENT':
  5618. return '';
  5619. default:
  5620. return currentInstanceId;
  5621. }
  5622. }
  5623. function reduceEventDrag(currentDrag, action, sources, calendar) {
  5624. switch (action.type) {
  5625. case 'SET_EVENT_DRAG':
  5626. var newDrag = action.state;
  5627. return {
  5628. affectedEvents: newDrag.affectedEvents,
  5629. mutatedEvents: newDrag.mutatedEvents,
  5630. isEvent: newDrag.isEvent,
  5631. origSeg: newDrag.origSeg
  5632. };
  5633. case 'UNSET_EVENT_DRAG':
  5634. return null;
  5635. default:
  5636. return currentDrag;
  5637. }
  5638. }
  5639. function reduceEventResize(currentResize, action, sources, calendar) {
  5640. switch (action.type) {
  5641. case 'SET_EVENT_RESIZE':
  5642. var newResize = action.state;
  5643. return {
  5644. affectedEvents: newResize.affectedEvents,
  5645. mutatedEvents: newResize.mutatedEvents,
  5646. isEvent: newResize.isEvent,
  5647. origSeg: newResize.origSeg
  5648. };
  5649. case 'UNSET_EVENT_RESIZE':
  5650. return null;
  5651. default:
  5652. return currentResize;
  5653. }
  5654. }
  5655. function computeLoadingLevel(eventSources) {
  5656. var cnt = 0;
  5657. for (var sourceId in eventSources) {
  5658. if (eventSources[sourceId].isFetching) {
  5659. cnt++;
  5660. }
  5661. }
  5662. return cnt;
  5663. }
  5664. var STANDARD_PROPS = {
  5665. start: null,
  5666. end: null,
  5667. allDay: Boolean
  5668. };
  5669. function parseDateSpan(raw, dateEnv, defaultDuration) {
  5670. var span = parseOpenDateSpan(raw, dateEnv);
  5671. var range = span.range;
  5672. if (!range.start) {
  5673. return null;
  5674. }
  5675. if (!range.end) {
  5676. if (defaultDuration == null) {
  5677. return null;
  5678. }
  5679. else {
  5680. range.end = dateEnv.add(range.start, defaultDuration);
  5681. }
  5682. }
  5683. return span;
  5684. }
  5685. /*
  5686. TODO: somehow combine with parseRange?
  5687. Will return null if the start/end props were present but parsed invalidly.
  5688. */
  5689. function parseOpenDateSpan(raw, dateEnv) {
  5690. var leftovers = {};
  5691. var standardProps = refineProps(raw, STANDARD_PROPS, {}, leftovers);
  5692. var startMeta = standardProps.start ? dateEnv.createMarkerMeta(standardProps.start) : null;
  5693. var endMeta = standardProps.end ? dateEnv.createMarkerMeta(standardProps.end) : null;
  5694. var allDay = standardProps.allDay;
  5695. if (allDay == null) {
  5696. allDay = (startMeta && startMeta.isTimeUnspecified) &&
  5697. (!endMeta || endMeta.isTimeUnspecified);
  5698. }
  5699. // use this leftover object as the selection object
  5700. leftovers.range = {
  5701. start: startMeta ? startMeta.marker : null,
  5702. end: endMeta ? endMeta.marker : null
  5703. };
  5704. leftovers.allDay = allDay;
  5705. return leftovers;
  5706. }
  5707. function isDateSpansEqual(span0, span1) {
  5708. return rangesEqual(span0.range, span1.range) &&
  5709. span0.allDay === span1.allDay &&
  5710. isSpanPropsEqual(span0, span1);
  5711. }
  5712. // the NON-DATE-RELATED props
  5713. function isSpanPropsEqual(span0, span1) {
  5714. for (var propName in span1) {
  5715. if (propName !== 'range' && propName !== 'allDay') {
  5716. if (span0[propName] !== span1[propName]) {
  5717. return false;
  5718. }
  5719. }
  5720. }
  5721. // are there any props that span0 has that span1 DOESN'T have?
  5722. // both have range/allDay, so no need to special-case.
  5723. for (var propName in span0) {
  5724. if (!(propName in span1)) {
  5725. return false;
  5726. }
  5727. }
  5728. return true;
  5729. }
  5730. function buildDateSpanApi(span, dateEnv) {
  5731. return {
  5732. start: dateEnv.toDate(span.range.start),
  5733. end: dateEnv.toDate(span.range.end),
  5734. startStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  5735. endStr: dateEnv.formatIso(span.range.end, { omitTime: span.allDay }),
  5736. allDay: span.allDay
  5737. };
  5738. }
  5739. function buildDatePointApi(span, dateEnv) {
  5740. return {
  5741. date: dateEnv.toDate(span.range.start),
  5742. dateStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  5743. allDay: span.allDay
  5744. };
  5745. }
  5746. function fabricateEventRange(dateSpan, eventUiBases, calendar) {
  5747. var def = parseEventDef({ editable: false }, '', // sourceId
  5748. dateSpan.allDay, true, // hasEnd
  5749. calendar);
  5750. return {
  5751. def: def,
  5752. ui: compileEventUi(def, eventUiBases),
  5753. instance: createEventInstance(def.defId, dateSpan.range),
  5754. range: dateSpan.range,
  5755. isStart: true,
  5756. isEnd: true
  5757. };
  5758. }
  5759. function compileViewDefs(defaultConfigs, overrideConfigs) {
  5760. var hash = {};
  5761. var viewType;
  5762. for (viewType in defaultConfigs) {
  5763. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5764. }
  5765. for (viewType in overrideConfigs) {
  5766. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5767. }
  5768. return hash;
  5769. }
  5770. function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5771. if (hash[viewType]) {
  5772. return hash[viewType];
  5773. }
  5774. var viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5775. if (viewDef) {
  5776. hash[viewType] = viewDef;
  5777. }
  5778. return viewDef;
  5779. }
  5780. function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5781. var defaultConfig = defaultConfigs[viewType];
  5782. var overrideConfig = overrideConfigs[viewType];
  5783. var queryProp = function (name) {
  5784. return (defaultConfig && defaultConfig[name] !== null) ? defaultConfig[name] :
  5785. ((overrideConfig && overrideConfig[name] !== null) ? overrideConfig[name] : null);
  5786. };
  5787. var theClass = queryProp('class');
  5788. var superType = queryProp('superType');
  5789. if (!superType && theClass) {
  5790. superType =
  5791. findViewNameBySubclass(theClass, overrideConfigs) ||
  5792. findViewNameBySubclass(theClass, defaultConfigs);
  5793. }
  5794. var superDef = superType ? ensureViewDef(superType, hash, defaultConfigs, overrideConfigs) : null;
  5795. if (!theClass && superDef) {
  5796. theClass = superDef.class;
  5797. }
  5798. if (!theClass) {
  5799. return null; // don't throw a warning, might be settings for a single-unit view
  5800. }
  5801. return {
  5802. type: viewType,
  5803. class: theClass,
  5804. defaults: __assign({}, (superDef ? superDef.defaults : {}), (defaultConfig ? defaultConfig.options : {})),
  5805. overrides: __assign({}, (superDef ? superDef.overrides : {}), (overrideConfig ? overrideConfig.options : {}))
  5806. };
  5807. }
  5808. function findViewNameBySubclass(viewSubclass, configs) {
  5809. var superProto = Object.getPrototypeOf(viewSubclass.prototype);
  5810. for (var viewType in configs) {
  5811. var parsed = configs[viewType];
  5812. // need DIRECT subclass, so instanceof won't do it
  5813. if (parsed.class && parsed.class.prototype === superProto) {
  5814. return viewType;
  5815. }
  5816. }
  5817. return '';
  5818. }
  5819. function parseViewConfigs(inputs) {
  5820. return mapHash(inputs, parseViewConfig);
  5821. }
  5822. var VIEW_DEF_PROPS = {
  5823. type: String,
  5824. class: null
  5825. };
  5826. function parseViewConfig(input) {
  5827. if (typeof input === 'function') {
  5828. input = { class: input };
  5829. }
  5830. var options = {};
  5831. var props = refineProps(input, VIEW_DEF_PROPS, {}, options);
  5832. return {
  5833. superType: props.type,
  5834. class: props.class,
  5835. options: options
  5836. };
  5837. }
  5838. function buildViewSpecs(defaultInputs, optionsManager) {
  5839. var defaultConfigs = parseViewConfigs(defaultInputs);
  5840. var overrideConfigs = parseViewConfigs(optionsManager.overrides.views);
  5841. var viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
  5842. return mapHash(viewDefs, function (viewDef) {
  5843. return buildViewSpec(viewDef, overrideConfigs, optionsManager);
  5844. });
  5845. }
  5846. function buildViewSpec(viewDef, overrideConfigs, optionsManager) {
  5847. var durationInput = viewDef.overrides.duration ||
  5848. viewDef.defaults.duration ||
  5849. optionsManager.dynamicOverrides.duration ||
  5850. optionsManager.overrides.duration;
  5851. var duration = null;
  5852. var durationUnit = '';
  5853. var singleUnit = '';
  5854. var singleUnitOverrides = {};
  5855. if (durationInput) {
  5856. duration = createDuration(durationInput);
  5857. if (duration) { // valid?
  5858. var denom = greatestDurationDenominator(duration, !getWeeksFromInput(durationInput));
  5859. durationUnit = denom.unit;
  5860. if (denom.value === 1) {
  5861. singleUnit = durationUnit;
  5862. singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].options : {};
  5863. }
  5864. }
  5865. }
  5866. var queryButtonText = function (options) {
  5867. var buttonTextMap = options.buttonText || {};
  5868. var buttonTextKey = viewDef.defaults.buttonTextKey;
  5869. if (buttonTextKey != null && buttonTextMap[buttonTextKey] != null) {
  5870. return buttonTextMap[buttonTextKey];
  5871. }
  5872. if (buttonTextMap[viewDef.type] != null) {
  5873. return buttonTextMap[viewDef.type];
  5874. }
  5875. if (buttonTextMap[singleUnit] != null) {
  5876. return buttonTextMap[singleUnit];
  5877. }
  5878. };
  5879. return {
  5880. type: viewDef.type,
  5881. class: viewDef.class,
  5882. duration: duration,
  5883. durationUnit: durationUnit,
  5884. singleUnit: singleUnit,
  5885. options: __assign({}, globalDefaults, viewDef.defaults, optionsManager.dirDefaults, optionsManager.localeDefaults, optionsManager.overrides, singleUnitOverrides, viewDef.overrides, optionsManager.dynamicOverrides),
  5886. buttonTextOverride: queryButtonText(optionsManager.dynamicOverrides) ||
  5887. queryButtonText(optionsManager.overrides) || // constructor-specified buttonText lookup hash takes precedence
  5888. viewDef.overrides.buttonText,
  5889. buttonTextDefault: queryButtonText(optionsManager.localeDefaults) ||
  5890. queryButtonText(optionsManager.dirDefaults) ||
  5891. viewDef.defaults.buttonText ||
  5892. queryButtonText(globalDefaults) ||
  5893. viewDef.type // fall back to given view name
  5894. };
  5895. }
  5896. var Toolbar = /** @class */ (function (_super) {
  5897. __extends(Toolbar, _super);
  5898. function Toolbar(context, extraClassName) {
  5899. var _this = _super.call(this, context) || this;
  5900. _this._renderLayout = memoizeRendering(_this.renderLayout, _this.unrenderLayout);
  5901. _this._updateTitle = memoizeRendering(_this.updateTitle, null, [_this._renderLayout]);
  5902. _this._updateActiveButton = memoizeRendering(_this.updateActiveButton, null, [_this._renderLayout]);
  5903. _this._updateToday = memoizeRendering(_this.updateToday, null, [_this._renderLayout]);
  5904. _this._updatePrev = memoizeRendering(_this.updatePrev, null, [_this._renderLayout]);
  5905. _this._updateNext = memoizeRendering(_this.updateNext, null, [_this._renderLayout]);
  5906. _this.el = createElement('div', { className: 'fc-toolbar ' + extraClassName });
  5907. return _this;
  5908. }
  5909. Toolbar.prototype.destroy = function () {
  5910. _super.prototype.destroy.call(this);
  5911. this._renderLayout.unrender(); // should unrender everything else
  5912. removeElement(this.el);
  5913. };
  5914. Toolbar.prototype.render = function (props) {
  5915. this._renderLayout(props.layout);
  5916. this._updateTitle(props.title);
  5917. this._updateActiveButton(props.activeButton);
  5918. this._updateToday(props.isTodayEnabled);
  5919. this._updatePrev(props.isPrevEnabled);
  5920. this._updateNext(props.isNextEnabled);
  5921. };
  5922. Toolbar.prototype.renderLayout = function (layout) {
  5923. var el = this.el;
  5924. this.viewsWithButtons = [];
  5925. appendToElement(el, this.renderSection('left', layout.left));
  5926. appendToElement(el, this.renderSection('center', layout.center));
  5927. appendToElement(el, this.renderSection('right', layout.right));
  5928. };
  5929. Toolbar.prototype.unrenderLayout = function () {
  5930. this.el.innerHTML = '';
  5931. };
  5932. Toolbar.prototype.renderSection = function (position, buttonStr) {
  5933. var _this = this;
  5934. var _a = this, theme = _a.theme, calendar = _a.calendar;
  5935. var optionsManager = calendar.optionsManager;
  5936. var viewSpecs = calendar.viewSpecs;
  5937. var sectionEl = createElement('div', { className: 'fc-' + position });
  5938. var calendarCustomButtons = optionsManager.computed.customButtons || {};
  5939. var calendarButtonTextOverrides = optionsManager.overrides.buttonText || {};
  5940. var calendarButtonText = optionsManager.computed.buttonText || {};
  5941. if (buttonStr) {
  5942. buttonStr.split(' ').forEach(function (buttonGroupStr, i) {
  5943. var groupChildren = [];
  5944. var isOnlyButtons = true;
  5945. var groupEl;
  5946. buttonGroupStr.split(',').forEach(function (buttonName, j) {
  5947. var customButtonProps;
  5948. var viewSpec;
  5949. var buttonClick;
  5950. var buttonIcon; // only one of these will be set
  5951. var buttonText; // "
  5952. var buttonInnerHtml;
  5953. var buttonClasses;
  5954. var buttonEl;
  5955. var buttonAriaAttr;
  5956. if (buttonName === 'title') {
  5957. groupChildren.push(htmlToElement('<h2>&nbsp;</h2>')); // we always want it to take up height
  5958. isOnlyButtons = false;
  5959. }
  5960. else {
  5961. if ((customButtonProps = calendarCustomButtons[buttonName])) {
  5962. buttonClick = function (ev) {
  5963. if (customButtonProps.click) {
  5964. customButtonProps.click.call(buttonEl, ev);
  5965. }
  5966. };
  5967. (buttonIcon = theme.getCustomButtonIconClass(customButtonProps)) ||
  5968. (buttonIcon = theme.getIconClass(buttonName)) ||
  5969. (buttonText = customButtonProps.text);
  5970. }
  5971. else if ((viewSpec = viewSpecs[buttonName])) {
  5972. _this.viewsWithButtons.push(buttonName);
  5973. buttonClick = function () {
  5974. calendar.changeView(buttonName);
  5975. };
  5976. (buttonText = viewSpec.buttonTextOverride) ||
  5977. (buttonIcon = theme.getIconClass(buttonName)) ||
  5978. (buttonText = viewSpec.buttonTextDefault);
  5979. }
  5980. else if (calendar[buttonName]) { // a calendar method
  5981. buttonClick = function () {
  5982. calendar[buttonName]();
  5983. };
  5984. (buttonText = calendarButtonTextOverrides[buttonName]) ||
  5985. (buttonIcon = theme.getIconClass(buttonName)) ||
  5986. (buttonText = calendarButtonText[buttonName]);
  5987. // ^ everything else is considered default
  5988. }
  5989. if (buttonClick) {
  5990. buttonClasses = [
  5991. 'fc-' + buttonName + '-button',
  5992. theme.getClass('button')
  5993. ];
  5994. if (buttonText) {
  5995. buttonInnerHtml = htmlEscape(buttonText);
  5996. buttonAriaAttr = '';
  5997. }
  5998. else if (buttonIcon) {
  5999. buttonInnerHtml = "<span class='" + buttonIcon + "'></span>";
  6000. buttonAriaAttr = ' aria-label="' + buttonName + '"';
  6001. }
  6002. buttonEl = htmlToElement(// type="button" so that it doesn't submit a form
  6003. '<button type="button" class="' + buttonClasses.join(' ') + '"' +
  6004. buttonAriaAttr +
  6005. '>' + buttonInnerHtml + '</button>');
  6006. buttonEl.addEventListener('click', buttonClick);
  6007. groupChildren.push(buttonEl);
  6008. }
  6009. }
  6010. });
  6011. if (groupChildren.length > 1) {
  6012. groupEl = document.createElement('div');
  6013. var buttonGroupClassName = theme.getClass('buttonGroup');
  6014. if (isOnlyButtons && buttonGroupClassName) {
  6015. groupEl.classList.add(buttonGroupClassName);
  6016. }
  6017. appendToElement(groupEl, groupChildren);
  6018. sectionEl.appendChild(groupEl);
  6019. }
  6020. else {
  6021. appendToElement(sectionEl, groupChildren); // 1 or 0 children
  6022. }
  6023. });
  6024. }
  6025. return sectionEl;
  6026. };
  6027. Toolbar.prototype.updateToday = function (isTodayEnabled) {
  6028. this.toggleButtonEnabled('today', isTodayEnabled);
  6029. };
  6030. Toolbar.prototype.updatePrev = function (isPrevEnabled) {
  6031. this.toggleButtonEnabled('prev', isPrevEnabled);
  6032. };
  6033. Toolbar.prototype.updateNext = function (isNextEnabled) {
  6034. this.toggleButtonEnabled('next', isNextEnabled);
  6035. };
  6036. Toolbar.prototype.updateTitle = function (text) {
  6037. findElements(this.el, 'h2').forEach(function (titleEl) {
  6038. titleEl.innerText = text;
  6039. });
  6040. };
  6041. Toolbar.prototype.updateActiveButton = function (buttonName) {
  6042. var className = this.theme.getClass('buttonActive');
  6043. findElements(this.el, 'button').forEach(function (buttonEl) {
  6044. if (buttonName && buttonEl.classList.contains('fc-' + buttonName + '-button')) {
  6045. buttonEl.classList.add(className);
  6046. }
  6047. else {
  6048. buttonEl.classList.remove(className);
  6049. }
  6050. });
  6051. };
  6052. Toolbar.prototype.toggleButtonEnabled = function (buttonName, bool) {
  6053. findElements(this.el, '.fc-' + buttonName + '-button').forEach(function (buttonEl) {
  6054. buttonEl.disabled = !bool;
  6055. });
  6056. };
  6057. return Toolbar;
  6058. }(Component));
  6059. var CalendarComponent = /** @class */ (function (_super) {
  6060. __extends(CalendarComponent, _super);
  6061. function CalendarComponent(context, el) {
  6062. var _this = _super.call(this, context) || this;
  6063. _this._renderToolbars = memoizeRendering(_this.renderToolbars);
  6064. _this.buildViewPropTransformers = memoize(buildViewPropTransformers);
  6065. _this.el = el;
  6066. prependToElement(el, _this.contentEl = createElement('div', { className: 'fc-view-container' }));
  6067. var calendar = _this.calendar;
  6068. for (var _i = 0, _a = calendar.pluginSystem.hooks.viewContainerModifiers; _i < _a.length; _i++) {
  6069. var modifyViewContainer = _a[_i];
  6070. modifyViewContainer(_this.contentEl, calendar);
  6071. }
  6072. _this.toggleElClassNames(true);
  6073. _this.computeTitle = memoize(computeTitle);
  6074. _this.parseBusinessHours = memoize(function (input) {
  6075. return parseBusinessHours(input, _this.calendar);
  6076. });
  6077. return _this;
  6078. }
  6079. CalendarComponent.prototype.destroy = function () {
  6080. if (this.header) {
  6081. this.header.destroy();
  6082. }
  6083. if (this.footer) {
  6084. this.footer.destroy();
  6085. }
  6086. if (this.view) {
  6087. this.view.destroy();
  6088. }
  6089. removeElement(this.contentEl);
  6090. this.toggleElClassNames(false);
  6091. _super.prototype.destroy.call(this);
  6092. };
  6093. CalendarComponent.prototype.toggleElClassNames = function (bool) {
  6094. var classList = this.el.classList;
  6095. var dirClassName = 'fc-' + this.opt('dir');
  6096. var themeClassName = this.theme.getClass('widget');
  6097. if (bool) {
  6098. classList.add('fc');
  6099. classList.add(dirClassName);
  6100. classList.add(themeClassName);
  6101. }
  6102. else {
  6103. classList.remove('fc');
  6104. classList.remove(dirClassName);
  6105. classList.remove(themeClassName);
  6106. }
  6107. };
  6108. CalendarComponent.prototype.render = function (props) {
  6109. this.freezeHeight();
  6110. var title = this.computeTitle(props.dateProfile, props.viewSpec.options);
  6111. this._renderToolbars(props.viewSpec, props.dateProfile, props.currentDate, props.dateProfileGenerator, title);
  6112. this.renderView(props, title);
  6113. this.updateSize();
  6114. this.thawHeight();
  6115. };
  6116. CalendarComponent.prototype.renderToolbars = function (viewSpec, dateProfile, currentDate, dateProfileGenerator, title) {
  6117. var headerLayout = this.opt('header');
  6118. var footerLayout = this.opt('footer');
  6119. var now = this.calendar.getNow();
  6120. var todayInfo = dateProfileGenerator.build(now);
  6121. var prevInfo = dateProfileGenerator.buildPrev(dateProfile, currentDate);
  6122. var nextInfo = dateProfileGenerator.buildNext(dateProfile, currentDate);
  6123. var toolbarProps = {
  6124. title: title,
  6125. activeButton: viewSpec.type,
  6126. isTodayEnabled: todayInfo.isValid && !rangeContainsMarker(dateProfile.currentRange, now),
  6127. isPrevEnabled: prevInfo.isValid,
  6128. isNextEnabled: nextInfo.isValid
  6129. };
  6130. if (headerLayout) {
  6131. if (!this.header) {
  6132. this.header = new Toolbar(this.context, 'fc-header-toolbar');
  6133. prependToElement(this.el, this.header.el);
  6134. }
  6135. this.header.receiveProps(__assign({ layout: headerLayout }, toolbarProps));
  6136. }
  6137. else if (this.header) {
  6138. this.header.destroy();
  6139. this.header = null;
  6140. }
  6141. if (footerLayout) {
  6142. if (!this.footer) {
  6143. this.footer = new Toolbar(this.context, 'fc-footer-toolbar');
  6144. appendToElement(this.el, this.footer.el);
  6145. }
  6146. this.footer.receiveProps(__assign({ layout: footerLayout }, toolbarProps));
  6147. }
  6148. else if (this.footer) {
  6149. this.footer.destroy();
  6150. this.footer = null;
  6151. }
  6152. };
  6153. CalendarComponent.prototype.renderView = function (props, title) {
  6154. var view = this.view;
  6155. var viewSpec = props.viewSpec, dateProfileGenerator = props.dateProfileGenerator;
  6156. if (!view || view.viewSpec !== viewSpec) {
  6157. if (view) {
  6158. view.destroy();
  6159. }
  6160. view = this.view = new viewSpec['class']({
  6161. calendar: this.calendar,
  6162. view: null,
  6163. dateEnv: this.dateEnv,
  6164. theme: this.theme,
  6165. options: viewSpec.options
  6166. }, viewSpec, dateProfileGenerator, this.contentEl);
  6167. }
  6168. else {
  6169. view.addScroll(view.queryScroll());
  6170. }
  6171. view.title = title; // for the API
  6172. var viewProps = {
  6173. dateProfile: props.dateProfile,
  6174. businessHours: this.parseBusinessHours(viewSpec.options.businessHours),
  6175. eventStore: props.eventStore,
  6176. eventUiBases: props.eventUiBases,
  6177. dateSelection: props.dateSelection,
  6178. eventSelection: props.eventSelection,
  6179. eventDrag: props.eventDrag,
  6180. eventResize: props.eventResize
  6181. };
  6182. var transformers = this.buildViewPropTransformers(this.calendar.pluginSystem.hooks.viewPropsTransformers);
  6183. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  6184. var transformer = transformers_1[_i];
  6185. __assign(viewProps, transformer.transform(viewProps, viewSpec, props, view));
  6186. }
  6187. view.receiveProps(viewProps);
  6188. };
  6189. // Sizing
  6190. // -----------------------------------------------------------------------------------------------------------------
  6191. CalendarComponent.prototype.updateSize = function (isResize) {
  6192. if (isResize === void 0) { isResize = false; }
  6193. var view = this.view;
  6194. if (isResize) {
  6195. view.addScroll(view.queryScroll());
  6196. }
  6197. if (isResize || this.isHeightAuto == null) {
  6198. this.computeHeightVars();
  6199. }
  6200. view.updateSize(isResize, this.viewHeight, this.isHeightAuto);
  6201. view.updateNowIndicator(); // we need to guarantee this will run after updateSize
  6202. view.popScroll(isResize);
  6203. };
  6204. CalendarComponent.prototype.computeHeightVars = function () {
  6205. var calendar = this.calendar; // yuck. need to handle dynamic options
  6206. var heightInput = calendar.opt('height');
  6207. var contentHeightInput = calendar.opt('contentHeight');
  6208. this.isHeightAuto = heightInput === 'auto' || contentHeightInput === 'auto';
  6209. if (typeof contentHeightInput === 'number') { // exists and not 'auto'
  6210. this.viewHeight = contentHeightInput;
  6211. }
  6212. else if (typeof contentHeightInput === 'function') { // exists and is a function
  6213. this.viewHeight = contentHeightInput();
  6214. }
  6215. else if (typeof heightInput === 'number') { // exists and not 'auto'
  6216. this.viewHeight = heightInput - this.queryToolbarsHeight();
  6217. }
  6218. else if (typeof heightInput === 'function') { // exists and is a function
  6219. this.viewHeight = heightInput() - this.queryToolbarsHeight();
  6220. }
  6221. else if (heightInput === 'parent') { // set to height of parent element
  6222. this.viewHeight = this.el.parentNode.offsetHeight - this.queryToolbarsHeight();
  6223. }
  6224. else {
  6225. this.viewHeight = Math.round(this.contentEl.offsetWidth /
  6226. Math.max(calendar.opt('aspectRatio'), .5));
  6227. }
  6228. };
  6229. CalendarComponent.prototype.queryToolbarsHeight = function () {
  6230. var height = 0;
  6231. if (this.header) {
  6232. height += computeHeightAndMargins(this.header.el);
  6233. }
  6234. if (this.footer) {
  6235. height += computeHeightAndMargins(this.footer.el);
  6236. }
  6237. return height;
  6238. };
  6239. // Height "Freezing"
  6240. // -----------------------------------------------------------------------------------------------------------------
  6241. CalendarComponent.prototype.freezeHeight = function () {
  6242. applyStyle(this.el, {
  6243. height: this.el.offsetHeight,
  6244. overflow: 'hidden'
  6245. });
  6246. };
  6247. CalendarComponent.prototype.thawHeight = function () {
  6248. applyStyle(this.el, {
  6249. height: '',
  6250. overflow: ''
  6251. });
  6252. };
  6253. return CalendarComponent;
  6254. }(Component));
  6255. // Title and Date Formatting
  6256. // -----------------------------------------------------------------------------------------------------------------
  6257. // Computes what the title at the top of the calendar should be for this view
  6258. function computeTitle(dateProfile, viewOptions) {
  6259. var range;
  6260. // for views that span a large unit of time, show the proper interval, ignoring stray days before and after
  6261. if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) {
  6262. range = dateProfile.currentRange;
  6263. }
  6264. else { // for day units or smaller, use the actual day range
  6265. range = dateProfile.activeRange;
  6266. }
  6267. return this.dateEnv.formatRange(range.start, range.end, createFormatter(viewOptions.titleFormat || computeTitleFormat(dateProfile), viewOptions.titleRangeSeparator), { isEndExclusive: dateProfile.isRangeAllDay });
  6268. }
  6269. // Generates the format string that should be used to generate the title for the current date range.
  6270. // Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`.
  6271. function computeTitleFormat(dateProfile) {
  6272. var currentRangeUnit = dateProfile.currentRangeUnit;
  6273. if (currentRangeUnit === 'year') {
  6274. return { year: 'numeric' };
  6275. }
  6276. else if (currentRangeUnit === 'month') {
  6277. return { year: 'numeric', month: 'long' }; // like "September 2014"
  6278. }
  6279. else {
  6280. var days = diffWholeDays(dateProfile.currentRange.start, dateProfile.currentRange.end);
  6281. if (days !== null && days > 1) {
  6282. // multi-day range. shorter, like "Sep 9 - 10 2014"
  6283. return { year: 'numeric', month: 'short', day: 'numeric' };
  6284. }
  6285. else {
  6286. // one day. longer, like "September 9 2014"
  6287. return { year: 'numeric', month: 'long', day: 'numeric' };
  6288. }
  6289. }
  6290. }
  6291. // Plugin
  6292. // -----------------------------------------------------------------------------------------------------------------
  6293. function buildViewPropTransformers(theClasses) {
  6294. return theClasses.map(function (theClass) {
  6295. return new theClass();
  6296. });
  6297. }
  6298. var Interaction = /** @class */ (function () {
  6299. function Interaction(settings) {
  6300. this.component = settings.component;
  6301. }
  6302. Interaction.prototype.destroy = function () {
  6303. };
  6304. return Interaction;
  6305. }());
  6306. function parseInteractionSettings(component, input) {
  6307. return {
  6308. component: component,
  6309. el: input.el,
  6310. useEventCenter: input.useEventCenter != null ? input.useEventCenter : true
  6311. };
  6312. }
  6313. function interactionSettingsToStore(settings) {
  6314. var _a;
  6315. return _a = {},
  6316. _a[settings.component.uid] = settings,
  6317. _a;
  6318. }
  6319. // global state
  6320. var interactionSettingsStore = {};
  6321. /*
  6322. Detects when the user clicks on an event within a DateComponent
  6323. */
  6324. var EventClicking = /** @class */ (function (_super) {
  6325. __extends(EventClicking, _super);
  6326. function EventClicking(settings) {
  6327. var _this = _super.call(this, settings) || this;
  6328. _this.handleSegClick = function (ev, segEl) {
  6329. var component = _this.component;
  6330. var seg = getElSeg(segEl);
  6331. if (seg && // might be the <div> surrounding the more link
  6332. component.isValidSegDownEl(ev.target)) {
  6333. // our way to simulate a link click for elements that can't be <a> tags
  6334. // grab before trigger fired in case trigger trashes DOM thru rerendering
  6335. var hasUrlContainer = elementClosest(ev.target, '.fc-has-url');
  6336. var url = hasUrlContainer ? hasUrlContainer.querySelector('a[href]').href : '';
  6337. component.publiclyTrigger('eventClick', [
  6338. {
  6339. el: segEl,
  6340. event: new EventApi(component.calendar, seg.eventRange.def, seg.eventRange.instance),
  6341. jsEvent: ev,
  6342. view: component.view
  6343. }
  6344. ]);
  6345. if (url && !ev.defaultPrevented) {
  6346. window.location.href = url;
  6347. }
  6348. }
  6349. };
  6350. var component = settings.component;
  6351. _this.destroy = listenBySelector(component.el, 'click', component.fgSegSelector + ',' + component.bgSegSelector, _this.handleSegClick);
  6352. return _this;
  6353. }
  6354. return EventClicking;
  6355. }(Interaction));
  6356. /*
  6357. Triggers events and adds/removes core classNames when the user's pointer
  6358. enters/leaves event-elements of a component.
  6359. */
  6360. var EventHovering = /** @class */ (function (_super) {
  6361. __extends(EventHovering, _super);
  6362. function EventHovering(settings) {
  6363. var _this = _super.call(this, settings) || this;
  6364. // for simulating an eventMouseLeave when the event el is destroyed while mouse is over it
  6365. _this.handleEventElRemove = function (el) {
  6366. if (el === _this.currentSegEl) {
  6367. _this.handleSegLeave(null, _this.currentSegEl);
  6368. }
  6369. };
  6370. _this.handleSegEnter = function (ev, segEl) {
  6371. if (getElSeg(segEl)) { // TODO: better way to make sure not hovering over more+ link or its wrapper
  6372. segEl.classList.add('fc-allow-mouse-resize');
  6373. _this.currentSegEl = segEl;
  6374. _this.triggerEvent('eventMouseEnter', ev, segEl);
  6375. }
  6376. };
  6377. _this.handleSegLeave = function (ev, segEl) {
  6378. if (_this.currentSegEl) {
  6379. segEl.classList.remove('fc-allow-mouse-resize');
  6380. _this.currentSegEl = null;
  6381. _this.triggerEvent('eventMouseLeave', ev, segEl);
  6382. }
  6383. };
  6384. var component = settings.component;
  6385. _this.removeHoverListeners = listenToHoverBySelector(component.el, component.fgSegSelector + ',' + component.bgSegSelector, _this.handleSegEnter, _this.handleSegLeave);
  6386. component.calendar.on('eventElRemove', _this.handleEventElRemove);
  6387. return _this;
  6388. }
  6389. EventHovering.prototype.destroy = function () {
  6390. this.removeHoverListeners();
  6391. this.component.calendar.off('eventElRemove', this.handleEventElRemove);
  6392. };
  6393. EventHovering.prototype.triggerEvent = function (publicEvName, ev, segEl) {
  6394. var component = this.component;
  6395. var seg = getElSeg(segEl);
  6396. if (!ev || component.isValidSegDownEl(ev.target)) {
  6397. component.publiclyTrigger(publicEvName, [
  6398. {
  6399. el: segEl,
  6400. event: new EventApi(this.component.calendar, seg.eventRange.def, seg.eventRange.instance),
  6401. jsEvent: ev,
  6402. view: component.view
  6403. }
  6404. ]);
  6405. }
  6406. };
  6407. return EventHovering;
  6408. }(Interaction));
  6409. var StandardTheme = /** @class */ (function (_super) {
  6410. __extends(StandardTheme, _super);
  6411. function StandardTheme() {
  6412. return _super !== null && _super.apply(this, arguments) || this;
  6413. }
  6414. return StandardTheme;
  6415. }(Theme));
  6416. StandardTheme.prototype.classes = {
  6417. widget: 'fc-unthemed',
  6418. widgetHeader: 'fc-widget-header',
  6419. widgetContent: 'fc-widget-content',
  6420. buttonGroup: 'fc-button-group',
  6421. button: 'fc-button fc-button-primary',
  6422. buttonActive: 'fc-button-active',
  6423. popoverHeader: 'fc-widget-header',
  6424. popoverContent: 'fc-widget-content',
  6425. // day grid
  6426. headerRow: 'fc-widget-header',
  6427. dayRow: 'fc-widget-content',
  6428. // list view
  6429. listView: 'fc-widget-content'
  6430. };
  6431. StandardTheme.prototype.baseIconClass = 'fc-icon';
  6432. StandardTheme.prototype.iconClasses = {
  6433. close: 'fc-icon-x',
  6434. prev: 'fc-icon-chevron-left',
  6435. next: 'fc-icon-chevron-right',
  6436. prevYear: 'fc-icon-chevrons-left',
  6437. nextYear: 'fc-icon-chevrons-right'
  6438. };
  6439. StandardTheme.prototype.iconOverrideOption = 'buttonIcons';
  6440. StandardTheme.prototype.iconOverrideCustomButtonOption = 'icon';
  6441. StandardTheme.prototype.iconOverridePrefix = 'fc-icon-';
  6442. var Calendar = /** @class */ (function () {
  6443. function Calendar(el, overrides) {
  6444. var _this = this;
  6445. this.parseRawLocales = memoize(parseRawLocales);
  6446. this.buildLocale = memoize(buildLocale);
  6447. this.buildDateEnv = memoize(buildDateEnv);
  6448. this.buildTheme = memoize(buildTheme);
  6449. this.buildEventUiSingleBase = memoize(this._buildEventUiSingleBase);
  6450. this.buildSelectionConfig = memoize(this._buildSelectionConfig);
  6451. this.buildEventUiBySource = memoizeOutput(buildEventUiBySource, isPropsEqual);
  6452. this.buildEventUiBases = memoize(buildEventUiBases);
  6453. this.interactionsStore = {};
  6454. this.actionQueue = [];
  6455. this.isReducing = false;
  6456. // isDisplaying: boolean = false // installed in DOM? accepting renders?
  6457. this.needsRerender = false; // needs a render?
  6458. this.needsFullRerender = false;
  6459. this.isRendering = false; // currently in the executeRender function?
  6460. this.renderingPauseDepth = 0;
  6461. this.buildDelayedRerender = memoize(buildDelayedRerender);
  6462. this.afterSizingTriggers = {};
  6463. this.isViewUpdated = false;
  6464. this.isDatesUpdated = false;
  6465. this.isEventsUpdated = false;
  6466. this.el = el;
  6467. this.optionsManager = new OptionsManager(overrides || {});
  6468. this.pluginSystem = new PluginSystem();
  6469. // only do once. don't do in handleOptions. because can't remove plugins
  6470. this.addPluginInputs(this.optionsManager.computed.plugins || []);
  6471. this.handleOptions(this.optionsManager.computed);
  6472. this.publiclyTrigger('_init'); // for tests
  6473. this.hydrate();
  6474. this.calendarInteractions = this.pluginSystem.hooks.calendarInteractions
  6475. .map(function (calendarInteractionClass) {
  6476. return new calendarInteractionClass(_this);
  6477. });
  6478. }
  6479. Calendar.prototype.addPluginInputs = function (pluginInputs) {
  6480. var pluginDefs = refinePluginDefs(pluginInputs);
  6481. for (var _i = 0, pluginDefs_1 = pluginDefs; _i < pluginDefs_1.length; _i++) {
  6482. var pluginDef = pluginDefs_1[_i];
  6483. this.pluginSystem.add(pluginDef);
  6484. }
  6485. };
  6486. Object.defineProperty(Calendar.prototype, "view", {
  6487. // public API
  6488. get: function () {
  6489. return this.component ? this.component.view : null;
  6490. },
  6491. enumerable: true,
  6492. configurable: true
  6493. });
  6494. // Public API for rendering
  6495. // -----------------------------------------------------------------------------------------------------------------
  6496. Calendar.prototype.render = function () {
  6497. if (!this.component) {
  6498. this.renderableEventStore = createEmptyEventStore();
  6499. this.bindHandlers();
  6500. this.executeRender();
  6501. }
  6502. else {
  6503. this.requestRerender(true);
  6504. }
  6505. };
  6506. Calendar.prototype.destroy = function () {
  6507. if (this.component) {
  6508. this.unbindHandlers();
  6509. this.component.destroy(); // don't null-out. in case API needs access
  6510. this.component = null; // umm ???
  6511. for (var _i = 0, _a = this.calendarInteractions; _i < _a.length; _i++) {
  6512. var interaction = _a[_i];
  6513. interaction.destroy();
  6514. }
  6515. this.publiclyTrigger('_destroyed');
  6516. }
  6517. };
  6518. // Handlers
  6519. // -----------------------------------------------------------------------------------------------------------------
  6520. Calendar.prototype.bindHandlers = function () {
  6521. var _this = this;
  6522. // event delegation for nav links
  6523. this.removeNavLinkListener = listenBySelector(this.el, 'click', 'a[data-goto]', function (ev, anchorEl) {
  6524. var gotoOptions = anchorEl.getAttribute('data-goto');
  6525. gotoOptions = gotoOptions ? JSON.parse(gotoOptions) : {};
  6526. var dateEnv = _this.dateEnv;
  6527. var dateMarker = dateEnv.createMarker(gotoOptions.date);
  6528. var viewType = gotoOptions.type;
  6529. // property like "navLinkDayClick". might be a string or a function
  6530. var customAction = _this.viewOpt('navLink' + capitaliseFirstLetter(viewType) + 'Click');
  6531. if (typeof customAction === 'function') {
  6532. customAction(dateEnv.toDate(dateMarker), ev);
  6533. }
  6534. else {
  6535. if (typeof customAction === 'string') {
  6536. viewType = customAction;
  6537. }
  6538. _this.zoomTo(dateMarker, viewType);
  6539. }
  6540. });
  6541. if (this.opt('handleWindowResize')) {
  6542. window.addEventListener('resize', this.windowResizeProxy = debounce(// prevents rapid calls
  6543. this.windowResize.bind(this), this.opt('windowResizeDelay')));
  6544. }
  6545. };
  6546. Calendar.prototype.unbindHandlers = function () {
  6547. this.removeNavLinkListener();
  6548. if (this.windowResizeProxy) {
  6549. window.removeEventListener('resize', this.windowResizeProxy);
  6550. this.windowResizeProxy = null;
  6551. }
  6552. };
  6553. // Dispatcher
  6554. // -----------------------------------------------------------------------------------------------------------------
  6555. Calendar.prototype.hydrate = function () {
  6556. var _this = this;
  6557. this.state = this.buildInitialState();
  6558. var rawSources = this.opt('eventSources') || [];
  6559. var singleRawSource = this.opt('events');
  6560. var sources = []; // parsed
  6561. if (singleRawSource) {
  6562. rawSources.unshift(singleRawSource);
  6563. }
  6564. for (var _i = 0, rawSources_1 = rawSources; _i < rawSources_1.length; _i++) {
  6565. var rawSource = rawSources_1[_i];
  6566. var source = parseEventSource(rawSource, this);
  6567. if (source) {
  6568. sources.push(source);
  6569. }
  6570. }
  6571. this.batchRendering(function () {
  6572. _this.dispatch({ type: 'INIT' }); // pass in sources here?
  6573. _this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: sources });
  6574. _this.dispatch({
  6575. type: 'SET_VIEW_TYPE',
  6576. viewType: _this.opt('defaultView') || _this.pluginSystem.hooks.defaultView
  6577. });
  6578. });
  6579. };
  6580. Calendar.prototype.buildInitialState = function () {
  6581. return {
  6582. viewType: null,
  6583. loadingLevel: 0,
  6584. eventSourceLoadingLevel: 0,
  6585. currentDate: this.getInitialDate(),
  6586. dateProfile: null,
  6587. eventSources: {},
  6588. eventStore: createEmptyEventStore(),
  6589. dateSelection: null,
  6590. eventSelection: '',
  6591. eventDrag: null,
  6592. eventResize: null
  6593. };
  6594. };
  6595. Calendar.prototype.dispatch = function (action) {
  6596. this.actionQueue.push(action);
  6597. if (!this.isReducing) {
  6598. this.isReducing = true;
  6599. var oldState = this.state;
  6600. while (this.actionQueue.length) {
  6601. this.state = this.reduce(this.state, this.actionQueue.shift(), this);
  6602. }
  6603. var newState = this.state;
  6604. this.isReducing = false;
  6605. if (!oldState.loadingLevel && newState.loadingLevel) {
  6606. this.publiclyTrigger('loading', [true]);
  6607. }
  6608. else if (oldState.loadingLevel && !newState.loadingLevel) {
  6609. this.publiclyTrigger('loading', [false]);
  6610. }
  6611. var view = this.component && this.component.view;
  6612. if (oldState.eventStore !== newState.eventStore || this.needsFullRerender) {
  6613. if (oldState.eventStore) {
  6614. this.isEventsUpdated = true;
  6615. }
  6616. }
  6617. if (oldState.dateProfile !== newState.dateProfile || this.needsFullRerender) {
  6618. if (oldState.dateProfile && view) { // why would view be null!?
  6619. this.publiclyTrigger('datesDestroy', [
  6620. {
  6621. view: view,
  6622. el: view.el
  6623. }
  6624. ]);
  6625. }
  6626. this.isDatesUpdated = true;
  6627. }
  6628. if (oldState.viewType !== newState.viewType || this.needsFullRerender) {
  6629. if (oldState.viewType && view) { // why would view be null!?
  6630. this.publiclyTrigger('viewSkeletonDestroy', [
  6631. {
  6632. view: view,
  6633. el: view.el
  6634. }
  6635. ]);
  6636. }
  6637. this.isViewUpdated = true;
  6638. }
  6639. this.requestRerender();
  6640. }
  6641. };
  6642. Calendar.prototype.reduce = function (state, action, calendar) {
  6643. return reduce(state, action, calendar);
  6644. };
  6645. // Render Queue
  6646. // -----------------------------------------------------------------------------------------------------------------
  6647. Calendar.prototype.requestRerender = function (needsFull) {
  6648. if (needsFull === void 0) { needsFull = false; }
  6649. this.needsRerender = true;
  6650. this.needsFullRerender = this.needsFullRerender || needsFull;
  6651. this.delayedRerender(); // will call a debounced-version of tryRerender
  6652. };
  6653. Calendar.prototype.tryRerender = function () {
  6654. if (this.component && // must be accepting renders
  6655. this.needsRerender && // indicates that a rerender was requested
  6656. !this.renderingPauseDepth && // not paused
  6657. !this.isRendering // not currently in the render loop
  6658. ) {
  6659. this.executeRender();
  6660. }
  6661. };
  6662. Calendar.prototype.batchRendering = function (func) {
  6663. this.renderingPauseDepth++;
  6664. func();
  6665. this.renderingPauseDepth--;
  6666. if (this.needsRerender) {
  6667. this.requestRerender();
  6668. }
  6669. };
  6670. // Rendering
  6671. // -----------------------------------------------------------------------------------------------------------------
  6672. Calendar.prototype.executeRender = function () {
  6673. var needsFullRerender = this.needsFullRerender; // save before clearing
  6674. // clear these BEFORE the render so that new values will accumulate during render
  6675. this.needsRerender = false;
  6676. this.needsFullRerender = false;
  6677. this.isRendering = true;
  6678. this.renderComponent(needsFullRerender);
  6679. this.isRendering = false;
  6680. // received a rerender request while rendering
  6681. if (this.needsRerender) {
  6682. this.delayedRerender();
  6683. }
  6684. };
  6685. /*
  6686. don't call this directly. use executeRender instead
  6687. */
  6688. Calendar.prototype.renderComponent = function (needsFull) {
  6689. var _a = this, state = _a.state, component = _a.component;
  6690. var viewType = state.viewType;
  6691. var viewSpec = this.viewSpecs[viewType];
  6692. var savedScroll = (needsFull && component) ? component.view.queryScroll() : null;
  6693. if (!viewSpec) {
  6694. throw new Error("View type \"" + viewType + "\" is not valid");
  6695. }
  6696. // if event sources are still loading and progressive rendering hasn't been enabled,
  6697. // keep rendering the last fully loaded set of events
  6698. var renderableEventStore = this.renderableEventStore =
  6699. (state.eventSourceLoadingLevel && !this.opt('progressiveEventRendering')) ?
  6700. this.renderableEventStore :
  6701. state.eventStore;
  6702. var eventUiSingleBase = this.buildEventUiSingleBase(viewSpec.options);
  6703. var eventUiBySource = this.buildEventUiBySource(state.eventSources);
  6704. var eventUiBases = this.eventUiBases = this.buildEventUiBases(renderableEventStore.defs, eventUiSingleBase, eventUiBySource);
  6705. if (needsFull || !component) {
  6706. if (component) {
  6707. component.freezeHeight(); // next component will unfreeze it
  6708. component.destroy();
  6709. }
  6710. component = this.component = new CalendarComponent({
  6711. calendar: this,
  6712. view: null,
  6713. dateEnv: this.dateEnv,
  6714. theme: this.theme,
  6715. options: this.optionsManager.computed
  6716. }, this.el);
  6717. }
  6718. component.receiveProps(__assign({}, state, { viewSpec: viewSpec, dateProfile: state.dateProfile, dateProfileGenerator: this.dateProfileGenerators[viewType], eventStore: renderableEventStore, eventUiBases: eventUiBases, dateSelection: state.dateSelection, eventSelection: state.eventSelection, eventDrag: state.eventDrag, eventResize: state.eventResize }));
  6719. if (savedScroll) {
  6720. component.view.applyScroll(savedScroll, false);
  6721. }
  6722. if (this.isViewUpdated) {
  6723. this.isViewUpdated = false;
  6724. this.publiclyTrigger('viewSkeletonRender', [
  6725. {
  6726. view: component.view,
  6727. el: component.view.el
  6728. }
  6729. ]);
  6730. }
  6731. if (this.isDatesUpdated) {
  6732. this.isDatesUpdated = false;
  6733. this.publiclyTrigger('datesRender', [
  6734. {
  6735. view: component.view,
  6736. el: component.view.el
  6737. }
  6738. ]);
  6739. }
  6740. if (this.isEventsUpdated) {
  6741. this.isEventsUpdated = false;
  6742. }
  6743. this.releaseAfterSizingTriggers();
  6744. };
  6745. // Options
  6746. // -----------------------------------------------------------------------------------------------------------------
  6747. Calendar.prototype.setOption = function (name, val) {
  6748. var _a;
  6749. this.mutateOptions((_a = {}, _a[name] = val, _a), [], true);
  6750. };
  6751. Calendar.prototype.getOption = function (name) {
  6752. return this.optionsManager.computed[name];
  6753. };
  6754. Calendar.prototype.opt = function (name) {
  6755. return this.optionsManager.computed[name];
  6756. };
  6757. Calendar.prototype.viewOpt = function (name) {
  6758. return this.viewOpts()[name];
  6759. };
  6760. Calendar.prototype.viewOpts = function () {
  6761. return this.viewSpecs[this.state.viewType].options;
  6762. };
  6763. /*
  6764. handles option changes (like a diff)
  6765. */
  6766. Calendar.prototype.mutateOptions = function (updates, removals, isDynamic, deepEquals) {
  6767. var _this = this;
  6768. var changeHandlers = this.pluginSystem.hooks.optionChangeHandlers;
  6769. var normalUpdates = {};
  6770. var specialUpdates = {};
  6771. var oldDateEnv = this.dateEnv; // do this before handleOptions
  6772. var isTimeZoneDirty = false;
  6773. var isSizeDirty = false;
  6774. var anyDifficultOptions = Boolean(removals.length);
  6775. for (var name_1 in updates) {
  6776. if (changeHandlers[name_1]) {
  6777. specialUpdates[name_1] = updates[name_1];
  6778. }
  6779. else {
  6780. normalUpdates[name_1] = updates[name_1];
  6781. }
  6782. }
  6783. for (var name_2 in normalUpdates) {
  6784. if (/^(height|contentHeight|aspectRatio)$/.test(name_2)) {
  6785. isSizeDirty = true;
  6786. }
  6787. else if (/^(defaultDate|defaultView)$/.test(name_2)) ;
  6788. else {
  6789. anyDifficultOptions = true;
  6790. if (name_2 === 'timeZone') {
  6791. isTimeZoneDirty = true;
  6792. }
  6793. }
  6794. }
  6795. this.optionsManager.mutate(normalUpdates, removals, isDynamic);
  6796. if (anyDifficultOptions) {
  6797. this.handleOptions(this.optionsManager.computed);
  6798. this.needsFullRerender = true;
  6799. }
  6800. this.batchRendering(function () {
  6801. if (anyDifficultOptions) {
  6802. if (isTimeZoneDirty) {
  6803. _this.dispatch({
  6804. type: 'CHANGE_TIMEZONE',
  6805. oldDateEnv: oldDateEnv
  6806. });
  6807. }
  6808. /* HACK
  6809. has the same effect as calling this.requestRerender(true)
  6810. but recomputes the state's dateProfile
  6811. */
  6812. _this.dispatch({
  6813. type: 'SET_VIEW_TYPE',
  6814. viewType: _this.state.viewType
  6815. });
  6816. }
  6817. else if (isSizeDirty) {
  6818. _this.updateSize();
  6819. }
  6820. // special updates
  6821. if (deepEquals) {
  6822. for (var name_3 in specialUpdates) {
  6823. changeHandlers[name_3](specialUpdates[name_3], _this, deepEquals);
  6824. }
  6825. }
  6826. });
  6827. };
  6828. /*
  6829. rebuilds things based off of a complete set of refined options
  6830. */
  6831. Calendar.prototype.handleOptions = function (options) {
  6832. var _this = this;
  6833. var pluginHooks = this.pluginSystem.hooks;
  6834. this.defaultAllDayEventDuration = createDuration(options.defaultAllDayEventDuration);
  6835. this.defaultTimedEventDuration = createDuration(options.defaultTimedEventDuration);
  6836. this.delayedRerender = this.buildDelayedRerender(options.rerenderDelay);
  6837. this.theme = this.buildTheme(options);
  6838. var available = this.parseRawLocales(options.locales);
  6839. this.availableRawLocales = available.map;
  6840. var locale = this.buildLocale(options.locale || available.defaultCode, available.map);
  6841. this.dateEnv = this.buildDateEnv(locale, options.timeZone, pluginHooks.namedTimeZonedImpl, options.firstDay, options.weekNumberCalculation, options.weekLabel, pluginHooks.cmdFormatter);
  6842. this.selectionConfig = this.buildSelectionConfig(options); // needs dateEnv. do after :(
  6843. // ineffecient to do every time?
  6844. this.viewSpecs = buildViewSpecs(pluginHooks.views, this.optionsManager);
  6845. // ineffecient to do every time?
  6846. this.dateProfileGenerators = mapHash(this.viewSpecs, function (viewSpec) {
  6847. return new viewSpec.class.prototype.dateProfileGeneratorClass(viewSpec, _this);
  6848. });
  6849. };
  6850. Calendar.prototype.getAvailableLocaleCodes = function () {
  6851. return Object.keys(this.availableRawLocales);
  6852. };
  6853. Calendar.prototype._buildSelectionConfig = function (rawOpts) {
  6854. return processScopedUiProps('select', rawOpts, this);
  6855. };
  6856. Calendar.prototype._buildEventUiSingleBase = function (rawOpts) {
  6857. if (rawOpts.editable) { // so 'editable' affected events
  6858. rawOpts = __assign({}, rawOpts, { eventEditable: true });
  6859. }
  6860. return processScopedUiProps('event', rawOpts, this);
  6861. };
  6862. // Trigger
  6863. // -----------------------------------------------------------------------------------------------------------------
  6864. Calendar.prototype.hasPublicHandlers = function (name) {
  6865. return this.hasHandlers(name) ||
  6866. this.opt(name); // handler specified in options
  6867. };
  6868. Calendar.prototype.publiclyTrigger = function (name, args) {
  6869. var optHandler = this.opt(name);
  6870. this.triggerWith(name, this, args);
  6871. if (optHandler) {
  6872. return optHandler.apply(this, args);
  6873. }
  6874. };
  6875. Calendar.prototype.publiclyTriggerAfterSizing = function (name, args) {
  6876. var afterSizingTriggers = this.afterSizingTriggers;
  6877. (afterSizingTriggers[name] || (afterSizingTriggers[name] = [])).push(args);
  6878. };
  6879. Calendar.prototype.releaseAfterSizingTriggers = function () {
  6880. var afterSizingTriggers = this.afterSizingTriggers;
  6881. for (var name_4 in afterSizingTriggers) {
  6882. for (var _i = 0, _a = afterSizingTriggers[name_4]; _i < _a.length; _i++) {
  6883. var args = _a[_i];
  6884. this.publiclyTrigger(name_4, args);
  6885. }
  6886. }
  6887. this.afterSizingTriggers = {};
  6888. };
  6889. // View
  6890. // -----------------------------------------------------------------------------------------------------------------
  6891. // Returns a boolean about whether the view is okay to instantiate at some point
  6892. Calendar.prototype.isValidViewType = function (viewType) {
  6893. return Boolean(this.viewSpecs[viewType]);
  6894. };
  6895. Calendar.prototype.changeView = function (viewType, dateOrRange) {
  6896. var dateMarker = null;
  6897. if (dateOrRange) {
  6898. if (dateOrRange.start && dateOrRange.end) { // a range
  6899. this.optionsManager.mutate({ visibleRange: dateOrRange }, []); // will not rerender
  6900. this.handleOptions(this.optionsManager.computed); // ...but yuck
  6901. }
  6902. else { // a date
  6903. dateMarker = this.dateEnv.createMarker(dateOrRange); // just like gotoDate
  6904. }
  6905. }
  6906. this.unselect();
  6907. this.dispatch({
  6908. type: 'SET_VIEW_TYPE',
  6909. viewType: viewType,
  6910. dateMarker: dateMarker
  6911. });
  6912. };
  6913. // Forces navigation to a view for the given date.
  6914. // `viewType` can be a specific view name or a generic one like "week" or "day".
  6915. // needs to change
  6916. Calendar.prototype.zoomTo = function (dateMarker, viewType) {
  6917. var spec;
  6918. viewType = viewType || 'day'; // day is default zoom
  6919. spec = this.viewSpecs[viewType] ||
  6920. this.getUnitViewSpec(viewType);
  6921. this.unselect();
  6922. if (spec) {
  6923. this.dispatch({
  6924. type: 'SET_VIEW_TYPE',
  6925. viewType: spec.type,
  6926. dateMarker: dateMarker
  6927. });
  6928. }
  6929. else {
  6930. this.dispatch({
  6931. type: 'SET_DATE',
  6932. dateMarker: dateMarker
  6933. });
  6934. }
  6935. };
  6936. // Given a duration singular unit, like "week" or "day", finds a matching view spec.
  6937. // Preference is given to views that have corresponding buttons.
  6938. Calendar.prototype.getUnitViewSpec = function (unit) {
  6939. var component = this.component;
  6940. var viewTypes = [];
  6941. var i;
  6942. var spec;
  6943. // put views that have buttons first. there will be duplicates, but oh
  6944. if (component.header) {
  6945. viewTypes.push.apply(viewTypes, component.header.viewsWithButtons);
  6946. }
  6947. if (component.footer) {
  6948. viewTypes.push.apply(viewTypes, component.footer.viewsWithButtons);
  6949. }
  6950. for (var viewType in this.viewSpecs) {
  6951. viewTypes.push(viewType);
  6952. }
  6953. for (i = 0; i < viewTypes.length; i++) {
  6954. spec = this.viewSpecs[viewTypes[i]];
  6955. if (spec) {
  6956. if (spec.singleUnit === unit) {
  6957. return spec;
  6958. }
  6959. }
  6960. }
  6961. };
  6962. // Current Date
  6963. // -----------------------------------------------------------------------------------------------------------------
  6964. Calendar.prototype.getInitialDate = function () {
  6965. var defaultDateInput = this.opt('defaultDate');
  6966. // compute the initial ambig-timezone date
  6967. if (defaultDateInput != null) {
  6968. return this.dateEnv.createMarker(defaultDateInput);
  6969. }
  6970. else {
  6971. return this.getNow(); // getNow already returns unzoned
  6972. }
  6973. };
  6974. Calendar.prototype.prev = function () {
  6975. this.unselect();
  6976. this.dispatch({ type: 'PREV' });
  6977. };
  6978. Calendar.prototype.next = function () {
  6979. this.unselect();
  6980. this.dispatch({ type: 'NEXT' });
  6981. };
  6982. Calendar.prototype.prevYear = function () {
  6983. this.unselect();
  6984. this.dispatch({
  6985. type: 'SET_DATE',
  6986. dateMarker: this.dateEnv.addYears(this.state.currentDate, -1)
  6987. });
  6988. };
  6989. Calendar.prototype.nextYear = function () {
  6990. this.unselect();
  6991. this.dispatch({
  6992. type: 'SET_DATE',
  6993. dateMarker: this.dateEnv.addYears(this.state.currentDate, 1)
  6994. });
  6995. };
  6996. Calendar.prototype.today = function () {
  6997. this.unselect();
  6998. this.dispatch({
  6999. type: 'SET_DATE',
  7000. dateMarker: this.getNow()
  7001. });
  7002. };
  7003. Calendar.prototype.gotoDate = function (zonedDateInput) {
  7004. this.unselect();
  7005. this.dispatch({
  7006. type: 'SET_DATE',
  7007. dateMarker: this.dateEnv.createMarker(zonedDateInput)
  7008. });
  7009. };
  7010. Calendar.prototype.incrementDate = function (deltaInput) {
  7011. var delta = createDuration(deltaInput);
  7012. if (delta) { // else, warn about invalid input?
  7013. this.unselect();
  7014. this.dispatch({
  7015. type: 'SET_DATE',
  7016. dateMarker: this.dateEnv.add(this.state.currentDate, delta)
  7017. });
  7018. }
  7019. };
  7020. // for external API
  7021. Calendar.prototype.getDate = function () {
  7022. return this.dateEnv.toDate(this.state.currentDate);
  7023. };
  7024. // Date Formatting Utils
  7025. // -----------------------------------------------------------------------------------------------------------------
  7026. Calendar.prototype.formatDate = function (d, formatter) {
  7027. var dateEnv = this.dateEnv;
  7028. return dateEnv.format(dateEnv.createMarker(d), createFormatter(formatter));
  7029. };
  7030. // `settings` is for formatter AND isEndExclusive
  7031. Calendar.prototype.formatRange = function (d0, d1, settings) {
  7032. var dateEnv = this.dateEnv;
  7033. return dateEnv.formatRange(dateEnv.createMarker(d0), dateEnv.createMarker(d1), createFormatter(settings, this.opt('defaultRangeSeparator')), settings);
  7034. };
  7035. Calendar.prototype.formatIso = function (d, omitTime) {
  7036. var dateEnv = this.dateEnv;
  7037. return dateEnv.formatIso(dateEnv.createMarker(d), { omitTime: omitTime });
  7038. };
  7039. // Sizing
  7040. // -----------------------------------------------------------------------------------------------------------------
  7041. Calendar.prototype.windowResize = function (ev) {
  7042. if (!this.isHandlingWindowResize &&
  7043. this.component && // why?
  7044. ev.target === window // not a jqui resize event
  7045. ) {
  7046. this.isHandlingWindowResize = true;
  7047. this.updateSize();
  7048. this.publiclyTrigger('windowResize', [this.view]);
  7049. this.isHandlingWindowResize = false;
  7050. }
  7051. };
  7052. Calendar.prototype.updateSize = function () {
  7053. if (this.component) { // when?
  7054. this.component.updateSize(true);
  7055. }
  7056. };
  7057. // Component Registration
  7058. // -----------------------------------------------------------------------------------------------------------------
  7059. Calendar.prototype.registerInteractiveComponent = function (component, settingsInput) {
  7060. var settings = parseInteractionSettings(component, settingsInput);
  7061. var DEFAULT_INTERACTIONS = [
  7062. EventClicking,
  7063. EventHovering
  7064. ];
  7065. var interactionClasses = DEFAULT_INTERACTIONS.concat(this.pluginSystem.hooks.componentInteractions);
  7066. var interactions = interactionClasses.map(function (interactionClass) {
  7067. return new interactionClass(settings);
  7068. });
  7069. this.interactionsStore[component.uid] = interactions;
  7070. interactionSettingsStore[component.uid] = settings;
  7071. };
  7072. Calendar.prototype.unregisterInteractiveComponent = function (component) {
  7073. for (var _i = 0, _a = this.interactionsStore[component.uid]; _i < _a.length; _i++) {
  7074. var listener = _a[_i];
  7075. listener.destroy();
  7076. }
  7077. delete this.interactionsStore[component.uid];
  7078. delete interactionSettingsStore[component.uid];
  7079. };
  7080. // Date Selection / Event Selection / DayClick
  7081. // -----------------------------------------------------------------------------------------------------------------
  7082. // this public method receives start/end dates in any format, with any timezone
  7083. // NOTE: args were changed from v3
  7084. Calendar.prototype.select = function (dateOrObj, endDate) {
  7085. var selectionInput;
  7086. if (endDate == null) {
  7087. if (dateOrObj.start != null) {
  7088. selectionInput = dateOrObj;
  7089. }
  7090. else {
  7091. selectionInput = {
  7092. start: dateOrObj,
  7093. end: null
  7094. };
  7095. }
  7096. }
  7097. else {
  7098. selectionInput = {
  7099. start: dateOrObj,
  7100. end: endDate
  7101. };
  7102. }
  7103. var selection = parseDateSpan(selectionInput, this.dateEnv, createDuration({ days: 1 }) // TODO: cache this?
  7104. );
  7105. if (selection) { // throw parse error otherwise?
  7106. this.dispatch({ type: 'SELECT_DATES', selection: selection });
  7107. this.triggerDateSelect(selection);
  7108. }
  7109. };
  7110. // public method
  7111. Calendar.prototype.unselect = function (pev) {
  7112. if (this.state.dateSelection) {
  7113. this.dispatch({ type: 'UNSELECT_DATES' });
  7114. this.triggerDateUnselect(pev);
  7115. }
  7116. };
  7117. Calendar.prototype.triggerDateSelect = function (selection, pev) {
  7118. var arg = __assign({}, this.buildDateSpanApi(selection), { jsEvent: pev ? pev.origEvent : null, view: this.view });
  7119. this.publiclyTrigger('select', [arg]);
  7120. };
  7121. Calendar.prototype.triggerDateUnselect = function (pev) {
  7122. this.publiclyTrigger('unselect', [
  7123. {
  7124. jsEvent: pev ? pev.origEvent : null,
  7125. view: this.view
  7126. }
  7127. ]);
  7128. };
  7129. // TODO: receive pev?
  7130. Calendar.prototype.triggerDateClick = function (dateSpan, dayEl, view, ev) {
  7131. var arg = __assign({}, this.buildDatePointApi(dateSpan), { dayEl: dayEl, jsEvent: ev, // Is this always a mouse event? See #4655
  7132. view: view });
  7133. this.publiclyTrigger('dateClick', [arg]);
  7134. };
  7135. Calendar.prototype.buildDatePointApi = function (dateSpan) {
  7136. var props = {};
  7137. for (var _i = 0, _a = this.pluginSystem.hooks.datePointTransforms; _i < _a.length; _i++) {
  7138. var transform = _a[_i];
  7139. __assign(props, transform(dateSpan, this));
  7140. }
  7141. __assign(props, buildDatePointApi(dateSpan, this.dateEnv));
  7142. return props;
  7143. };
  7144. Calendar.prototype.buildDateSpanApi = function (dateSpan) {
  7145. var props = {};
  7146. for (var _i = 0, _a = this.pluginSystem.hooks.dateSpanTransforms; _i < _a.length; _i++) {
  7147. var transform = _a[_i];
  7148. __assign(props, transform(dateSpan, this));
  7149. }
  7150. __assign(props, buildDateSpanApi(dateSpan, this.dateEnv));
  7151. return props;
  7152. };
  7153. // Date Utils
  7154. // -----------------------------------------------------------------------------------------------------------------
  7155. // Returns a DateMarker for the current date, as defined by the client's computer or from the `now` option
  7156. Calendar.prototype.getNow = function () {
  7157. var now = this.opt('now');
  7158. if (typeof now === 'function') {
  7159. now = now();
  7160. }
  7161. if (now == null) {
  7162. return this.dateEnv.createNowMarker();
  7163. }
  7164. return this.dateEnv.createMarker(now);
  7165. };
  7166. // Event-Date Utilities
  7167. // -----------------------------------------------------------------------------------------------------------------
  7168. // Given an event's allDay status and start date, return what its fallback end date should be.
  7169. // TODO: rename to computeDefaultEventEnd
  7170. Calendar.prototype.getDefaultEventEnd = function (allDay, marker) {
  7171. var end = marker;
  7172. if (allDay) {
  7173. end = startOfDay(end);
  7174. end = this.dateEnv.add(end, this.defaultAllDayEventDuration);
  7175. }
  7176. else {
  7177. end = this.dateEnv.add(end, this.defaultTimedEventDuration);
  7178. }
  7179. return end;
  7180. };
  7181. // Public Events API
  7182. // -----------------------------------------------------------------------------------------------------------------
  7183. Calendar.prototype.addEvent = function (eventInput, sourceInput) {
  7184. if (eventInput instanceof EventApi) {
  7185. var def = eventInput._def;
  7186. var instance = eventInput._instance;
  7187. // not already present? don't want to add an old snapshot
  7188. if (!this.state.eventStore.defs[def.defId]) {
  7189. this.dispatch({
  7190. type: 'ADD_EVENTS',
  7191. eventStore: eventTupleToStore({ def: def, instance: instance }) // TODO: better util for two args?
  7192. });
  7193. }
  7194. return eventInput;
  7195. }
  7196. var sourceId;
  7197. if (sourceInput instanceof EventSourceApi) {
  7198. sourceId = sourceInput.internalEventSource.sourceId;
  7199. }
  7200. else if (sourceInput != null) {
  7201. var sourceApi = this.getEventSourceById(sourceInput); // TODO: use an internal function
  7202. if (!sourceApi) {
  7203. console.warn('Could not find an event source with ID "' + sourceInput + '"'); // TODO: test
  7204. return null;
  7205. }
  7206. else {
  7207. sourceId = sourceApi.internalEventSource.sourceId;
  7208. }
  7209. }
  7210. var tuple = parseEvent(eventInput, sourceId, this);
  7211. if (tuple) {
  7212. this.dispatch({
  7213. type: 'ADD_EVENTS',
  7214. eventStore: eventTupleToStore(tuple)
  7215. });
  7216. return new EventApi(this, tuple.def, tuple.def.recurringDef ? null : tuple.instance);
  7217. }
  7218. return null;
  7219. };
  7220. // TODO: optimize
  7221. Calendar.prototype.getEventById = function (id) {
  7222. var _a = this.state.eventStore, defs = _a.defs, instances = _a.instances;
  7223. id = String(id);
  7224. for (var defId in defs) {
  7225. var def = defs[defId];
  7226. if (def.publicId === id) {
  7227. if (def.recurringDef) {
  7228. return new EventApi(this, def, null);
  7229. }
  7230. else {
  7231. for (var instanceId in instances) {
  7232. var instance = instances[instanceId];
  7233. if (instance.defId === def.defId) {
  7234. return new EventApi(this, def, instance);
  7235. }
  7236. }
  7237. }
  7238. }
  7239. }
  7240. return null;
  7241. };
  7242. Calendar.prototype.getEvents = function () {
  7243. var _a = this.state.eventStore, defs = _a.defs, instances = _a.instances;
  7244. var eventApis = [];
  7245. for (var id in instances) {
  7246. var instance = instances[id];
  7247. var def = defs[instance.defId];
  7248. eventApis.push(new EventApi(this, def, instance));
  7249. }
  7250. return eventApis;
  7251. };
  7252. Calendar.prototype.removeAllEvents = function () {
  7253. this.dispatch({ type: 'REMOVE_ALL_EVENTS' });
  7254. };
  7255. Calendar.prototype.rerenderEvents = function () {
  7256. this.dispatch({ type: 'RESET_EVENTS' });
  7257. };
  7258. // Public Event Sources API
  7259. // -----------------------------------------------------------------------------------------------------------------
  7260. Calendar.prototype.getEventSources = function () {
  7261. var sourceHash = this.state.eventSources;
  7262. var sourceApis = [];
  7263. for (var internalId in sourceHash) {
  7264. sourceApis.push(new EventSourceApi(this, sourceHash[internalId]));
  7265. }
  7266. return sourceApis;
  7267. };
  7268. Calendar.prototype.getEventSourceById = function (id) {
  7269. var sourceHash = this.state.eventSources;
  7270. id = String(id);
  7271. for (var sourceId in sourceHash) {
  7272. if (sourceHash[sourceId].publicId === id) {
  7273. return new EventSourceApi(this, sourceHash[sourceId]);
  7274. }
  7275. }
  7276. return null;
  7277. };
  7278. Calendar.prototype.addEventSource = function (sourceInput) {
  7279. if (sourceInput instanceof EventSourceApi) {
  7280. // not already present? don't want to add an old snapshot
  7281. if (!this.state.eventSources[sourceInput.internalEventSource.sourceId]) {
  7282. this.dispatch({
  7283. type: 'ADD_EVENT_SOURCES',
  7284. sources: [sourceInput.internalEventSource]
  7285. });
  7286. }
  7287. return sourceInput;
  7288. }
  7289. var eventSource = parseEventSource(sourceInput, this);
  7290. if (eventSource) { // TODO: error otherwise?
  7291. this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: [eventSource] });
  7292. return new EventSourceApi(this, eventSource);
  7293. }
  7294. return null;
  7295. };
  7296. Calendar.prototype.removeAllEventSources = function () {
  7297. this.dispatch({ type: 'REMOVE_ALL_EVENT_SOURCES' });
  7298. };
  7299. Calendar.prototype.refetchEvents = function () {
  7300. this.dispatch({ type: 'FETCH_EVENT_SOURCES' });
  7301. };
  7302. // Scroll
  7303. // -----------------------------------------------------------------------------------------------------------------
  7304. Calendar.prototype.scrollToTime = function (timeInput) {
  7305. var time = createDuration(timeInput);
  7306. if (time) {
  7307. this.component.view.scrollToTime(time);
  7308. }
  7309. };
  7310. return Calendar;
  7311. }());
  7312. EmitterMixin.mixInto(Calendar);
  7313. // for memoizers
  7314. // -----------------------------------------------------------------------------------------------------------------
  7315. function buildDateEnv(locale, timeZone, namedTimeZoneImpl, firstDay, weekNumberCalculation, weekLabel, cmdFormatter) {
  7316. return new DateEnv({
  7317. calendarSystem: 'gregory',
  7318. timeZone: timeZone,
  7319. namedTimeZoneImpl: namedTimeZoneImpl,
  7320. locale: locale,
  7321. weekNumberCalculation: weekNumberCalculation,
  7322. firstDay: firstDay,
  7323. weekLabel: weekLabel,
  7324. cmdFormatter: cmdFormatter
  7325. });
  7326. }
  7327. function buildTheme(calendarOptions) {
  7328. var themeClass = this.pluginSystem.hooks.themeClasses[calendarOptions.themeSystem] || StandardTheme;
  7329. return new themeClass(calendarOptions);
  7330. }
  7331. function buildDelayedRerender(wait) {
  7332. var func = this.tryRerender.bind(this);
  7333. if (wait != null) {
  7334. func = debounce(func, wait);
  7335. }
  7336. return func;
  7337. }
  7338. function buildEventUiBySource(eventSources) {
  7339. return mapHash(eventSources, function (eventSource) {
  7340. return eventSource.ui;
  7341. });
  7342. }
  7343. function buildEventUiBases(eventDefs, eventUiSingleBase, eventUiBySource) {
  7344. var eventUiBases = { '': eventUiSingleBase };
  7345. for (var defId in eventDefs) {
  7346. var def = eventDefs[defId];
  7347. if (def.sourceId && eventUiBySource[def.sourceId]) {
  7348. eventUiBases[defId] = eventUiBySource[def.sourceId];
  7349. }
  7350. }
  7351. return eventUiBases;
  7352. }
  7353. var View = /** @class */ (function (_super) {
  7354. __extends(View, _super);
  7355. function View(context, viewSpec, dateProfileGenerator, parentEl) {
  7356. var _this = _super.call(this, context, createElement('div', { className: 'fc-view fc-' + viewSpec.type + '-view' }), true // isView (HACK)
  7357. ) || this;
  7358. _this.renderDatesMem = memoizeRendering(_this.renderDatesWrap, _this.unrenderDatesWrap);
  7359. _this.renderBusinessHoursMem = memoizeRendering(_this.renderBusinessHours, _this.unrenderBusinessHours, [_this.renderDatesMem]);
  7360. _this.renderDateSelectionMem = memoizeRendering(_this.renderDateSelectionWrap, _this.unrenderDateSelectionWrap, [_this.renderDatesMem]);
  7361. _this.renderEventsMem = memoizeRendering(_this.renderEvents, _this.unrenderEvents, [_this.renderDatesMem]);
  7362. _this.renderEventSelectionMem = memoizeRendering(_this.renderEventSelectionWrap, _this.unrenderEventSelectionWrap, [_this.renderEventsMem]);
  7363. _this.renderEventDragMem = memoizeRendering(_this.renderEventDragWrap, _this.unrenderEventDragWrap, [_this.renderDatesMem]);
  7364. _this.renderEventResizeMem = memoizeRendering(_this.renderEventResizeWrap, _this.unrenderEventResizeWrap, [_this.renderDatesMem]);
  7365. _this.viewSpec = viewSpec;
  7366. _this.dateProfileGenerator = dateProfileGenerator;
  7367. _this.type = viewSpec.type;
  7368. _this.eventOrderSpecs = parseFieldSpecs(_this.opt('eventOrder'));
  7369. _this.nextDayThreshold = createDuration(_this.opt('nextDayThreshold'));
  7370. parentEl.appendChild(_this.el);
  7371. _this.initialize();
  7372. return _this;
  7373. }
  7374. View.prototype.initialize = function () {
  7375. };
  7376. Object.defineProperty(View.prototype, "activeStart", {
  7377. // Date Setting/Unsetting
  7378. // -----------------------------------------------------------------------------------------------------------------
  7379. get: function () {
  7380. return this.dateEnv.toDate(this.props.dateProfile.activeRange.start);
  7381. },
  7382. enumerable: true,
  7383. configurable: true
  7384. });
  7385. Object.defineProperty(View.prototype, "activeEnd", {
  7386. get: function () {
  7387. return this.dateEnv.toDate(this.props.dateProfile.activeRange.end);
  7388. },
  7389. enumerable: true,
  7390. configurable: true
  7391. });
  7392. Object.defineProperty(View.prototype, "currentStart", {
  7393. get: function () {
  7394. return this.dateEnv.toDate(this.props.dateProfile.currentRange.start);
  7395. },
  7396. enumerable: true,
  7397. configurable: true
  7398. });
  7399. Object.defineProperty(View.prototype, "currentEnd", {
  7400. get: function () {
  7401. return this.dateEnv.toDate(this.props.dateProfile.currentRange.end);
  7402. },
  7403. enumerable: true,
  7404. configurable: true
  7405. });
  7406. // General Rendering
  7407. // -----------------------------------------------------------------------------------------------------------------
  7408. View.prototype.render = function (props) {
  7409. this.renderDatesMem(props.dateProfile);
  7410. this.renderBusinessHoursMem(props.businessHours);
  7411. this.renderDateSelectionMem(props.dateSelection);
  7412. this.renderEventsMem(props.eventStore);
  7413. this.renderEventSelectionMem(props.eventSelection);
  7414. this.renderEventDragMem(props.eventDrag);
  7415. this.renderEventResizeMem(props.eventResize);
  7416. };
  7417. View.prototype.destroy = function () {
  7418. _super.prototype.destroy.call(this);
  7419. this.renderDatesMem.unrender(); // should unrender everything else
  7420. };
  7421. // Sizing
  7422. // -----------------------------------------------------------------------------------------------------------------
  7423. View.prototype.updateSize = function (isResize, viewHeight, isAuto) {
  7424. var calendar = this.calendar;
  7425. if (isResize || calendar.isViewUpdated || calendar.isDatesUpdated || calendar.isEventsUpdated) {
  7426. // sort of the catch-all sizing
  7427. // anything that might cause dimension changes
  7428. this.updateBaseSize(isResize, viewHeight, isAuto);
  7429. }
  7430. };
  7431. View.prototype.updateBaseSize = function (isResize, viewHeight, isAuto) {
  7432. };
  7433. // Date Rendering
  7434. // -----------------------------------------------------------------------------------------------------------------
  7435. View.prototype.renderDatesWrap = function (dateProfile) {
  7436. this.renderDates(dateProfile);
  7437. this.addScroll({
  7438. timeMs: createDuration(this.opt('scrollTime')).milliseconds
  7439. });
  7440. this.startNowIndicator(dateProfile); // shouldn't render yet because updateSize will be called soon
  7441. };
  7442. View.prototype.unrenderDatesWrap = function () {
  7443. this.stopNowIndicator();
  7444. this.unrenderDates();
  7445. };
  7446. View.prototype.renderDates = function (dateProfile) { };
  7447. View.prototype.unrenderDates = function () { };
  7448. // Business Hours
  7449. // -----------------------------------------------------------------------------------------------------------------
  7450. View.prototype.renderBusinessHours = function (businessHours) { };
  7451. View.prototype.unrenderBusinessHours = function () { };
  7452. // Date Selection
  7453. // -----------------------------------------------------------------------------------------------------------------
  7454. View.prototype.renderDateSelectionWrap = function (selection) {
  7455. if (selection) {
  7456. this.renderDateSelection(selection);
  7457. }
  7458. };
  7459. View.prototype.unrenderDateSelectionWrap = function (selection) {
  7460. if (selection) {
  7461. this.unrenderDateSelection(selection);
  7462. }
  7463. };
  7464. View.prototype.renderDateSelection = function (selection) { };
  7465. View.prototype.unrenderDateSelection = function (selection) { };
  7466. // Event Rendering
  7467. // -----------------------------------------------------------------------------------------------------------------
  7468. View.prototype.renderEvents = function (eventStore) { };
  7469. View.prototype.unrenderEvents = function () { };
  7470. // util for subclasses
  7471. View.prototype.sliceEvents = function (eventStore, allDay) {
  7472. var props = this.props;
  7473. return sliceEventStore(eventStore, props.eventUiBases, props.dateProfile.activeRange, allDay ? this.nextDayThreshold : null).fg;
  7474. };
  7475. // Event Selection
  7476. // -----------------------------------------------------------------------------------------------------------------
  7477. View.prototype.renderEventSelectionWrap = function (instanceId) {
  7478. if (instanceId) {
  7479. this.renderEventSelection(instanceId);
  7480. }
  7481. };
  7482. View.prototype.unrenderEventSelectionWrap = function (instanceId) {
  7483. if (instanceId) {
  7484. this.unrenderEventSelection(instanceId);
  7485. }
  7486. };
  7487. View.prototype.renderEventSelection = function (instanceId) { };
  7488. View.prototype.unrenderEventSelection = function (instanceId) { };
  7489. // Event Drag
  7490. // -----------------------------------------------------------------------------------------------------------------
  7491. View.prototype.renderEventDragWrap = function (state) {
  7492. if (state) {
  7493. this.renderEventDrag(state);
  7494. }
  7495. };
  7496. View.prototype.unrenderEventDragWrap = function (state) {
  7497. if (state) {
  7498. this.unrenderEventDrag(state);
  7499. }
  7500. };
  7501. View.prototype.renderEventDrag = function (state) { };
  7502. View.prototype.unrenderEventDrag = function (state) { };
  7503. // Event Resize
  7504. // -----------------------------------------------------------------------------------------------------------------
  7505. View.prototype.renderEventResizeWrap = function (state) {
  7506. if (state) {
  7507. this.renderEventResize(state);
  7508. }
  7509. };
  7510. View.prototype.unrenderEventResizeWrap = function (state) {
  7511. if (state) {
  7512. this.unrenderEventResize(state);
  7513. }
  7514. };
  7515. View.prototype.renderEventResize = function (state) { };
  7516. View.prototype.unrenderEventResize = function (state) { };
  7517. /* Now Indicator
  7518. ------------------------------------------------------------------------------------------------------------------*/
  7519. // Immediately render the current time indicator and begins re-rendering it at an interval,
  7520. // which is defined by this.getNowIndicatorUnit().
  7521. // TODO: somehow do this for the current whole day's background too
  7522. View.prototype.startNowIndicator = function (dateProfile) {
  7523. var _this = this;
  7524. var dateEnv = this.dateEnv;
  7525. var unit;
  7526. var update;
  7527. var delay; // ms wait value
  7528. if (this.opt('nowIndicator')) {
  7529. unit = this.getNowIndicatorUnit(dateProfile);
  7530. if (unit) {
  7531. update = this.updateNowIndicator.bind(this);
  7532. this.initialNowDate = this.calendar.getNow();
  7533. this.initialNowQueriedMs = new Date().valueOf();
  7534. // wait until the beginning of the next interval
  7535. delay = dateEnv.add(dateEnv.startOf(this.initialNowDate, unit), createDuration(1, unit)).valueOf() - this.initialNowDate.valueOf();
  7536. // TODO: maybe always use setTimeout, waiting until start of next unit
  7537. this.nowIndicatorTimeoutID = setTimeout(function () {
  7538. _this.nowIndicatorTimeoutID = null;
  7539. update();
  7540. if (unit === 'second') {
  7541. delay = 1000; // every second
  7542. }
  7543. else {
  7544. delay = 1000 * 60; // otherwise, every minute
  7545. }
  7546. _this.nowIndicatorIntervalID = setInterval(update, delay); // update every interval
  7547. }, delay);
  7548. }
  7549. // rendering will be initiated in updateSize
  7550. }
  7551. };
  7552. // rerenders the now indicator, computing the new current time from the amount of time that has passed
  7553. // since the initial getNow call.
  7554. View.prototype.updateNowIndicator = function () {
  7555. if (this.props.dateProfile && // a way to determine if dates were rendered yet
  7556. this.initialNowDate // activated before?
  7557. ) {
  7558. this.unrenderNowIndicator(); // won't unrender if unnecessary
  7559. this.renderNowIndicator(addMs(this.initialNowDate, new Date().valueOf() - this.initialNowQueriedMs));
  7560. this.isNowIndicatorRendered = true;
  7561. }
  7562. };
  7563. // Immediately unrenders the view's current time indicator and stops any re-rendering timers.
  7564. // Won't cause side effects if indicator isn't rendered.
  7565. View.prototype.stopNowIndicator = function () {
  7566. if (this.isNowIndicatorRendered) {
  7567. if (this.nowIndicatorTimeoutID) {
  7568. clearTimeout(this.nowIndicatorTimeoutID);
  7569. this.nowIndicatorTimeoutID = null;
  7570. }
  7571. if (this.nowIndicatorIntervalID) {
  7572. clearInterval(this.nowIndicatorIntervalID);
  7573. this.nowIndicatorIntervalID = null;
  7574. }
  7575. this.unrenderNowIndicator();
  7576. this.isNowIndicatorRendered = false;
  7577. }
  7578. };
  7579. View.prototype.getNowIndicatorUnit = function (dateProfile) {
  7580. // subclasses should implement
  7581. };
  7582. // Renders a current time indicator at the given datetime
  7583. View.prototype.renderNowIndicator = function (date) {
  7584. // SUBCLASSES MUST PASS TO CHILDREN!
  7585. };
  7586. // Undoes the rendering actions from renderNowIndicator
  7587. View.prototype.unrenderNowIndicator = function () {
  7588. // SUBCLASSES MUST PASS TO CHILDREN!
  7589. };
  7590. /* Scroller
  7591. ------------------------------------------------------------------------------------------------------------------*/
  7592. View.prototype.addScroll = function (scroll) {
  7593. var queuedScroll = this.queuedScroll || (this.queuedScroll = {});
  7594. __assign(queuedScroll, scroll);
  7595. };
  7596. View.prototype.popScroll = function (isResize) {
  7597. this.applyQueuedScroll(isResize);
  7598. this.queuedScroll = null;
  7599. };
  7600. View.prototype.applyQueuedScroll = function (isResize) {
  7601. this.applyScroll(this.queuedScroll || {}, isResize);
  7602. };
  7603. View.prototype.queryScroll = function () {
  7604. var scroll = {};
  7605. if (this.props.dateProfile) { // dates rendered yet?
  7606. __assign(scroll, this.queryDateScroll());
  7607. }
  7608. return scroll;
  7609. };
  7610. View.prototype.applyScroll = function (scroll, isResize) {
  7611. var timeMs = scroll.timeMs;
  7612. if (timeMs != null) {
  7613. delete scroll.timeMs;
  7614. if (this.props.dateProfile) { // dates rendered yet?
  7615. __assign(scroll, this.computeDateScroll(timeMs));
  7616. }
  7617. }
  7618. if (this.props.dateProfile) { // dates rendered yet?
  7619. this.applyDateScroll(scroll);
  7620. }
  7621. };
  7622. View.prototype.computeDateScroll = function (timeMs) {
  7623. return {}; // subclasses must implement
  7624. };
  7625. View.prototype.queryDateScroll = function () {
  7626. return {}; // subclasses must implement
  7627. };
  7628. View.prototype.applyDateScroll = function (scroll) {
  7629. // subclasses must implement
  7630. };
  7631. // for API
  7632. View.prototype.scrollToTime = function (time) {
  7633. this.applyScroll({
  7634. timeMs: time.milliseconds
  7635. }, false);
  7636. };
  7637. return View;
  7638. }(DateComponent));
  7639. EmitterMixin.mixInto(View);
  7640. View.prototype.usesMinMaxTime = false;
  7641. View.prototype.dateProfileGeneratorClass = DateProfileGenerator;
  7642. var FgEventRenderer = /** @class */ (function () {
  7643. function FgEventRenderer(context) {
  7644. this.segs = [];
  7645. this.isSizeDirty = false;
  7646. this.context = context;
  7647. }
  7648. FgEventRenderer.prototype.renderSegs = function (segs, mirrorInfo) {
  7649. this.rangeUpdated(); // called too frequently :(
  7650. // render an `.el` on each seg
  7651. // returns a subset of the segs. segs that were actually rendered
  7652. segs = this.renderSegEls(segs, mirrorInfo);
  7653. this.segs = segs;
  7654. this.attachSegs(segs, mirrorInfo);
  7655. this.isSizeDirty = true;
  7656. this.context.view.triggerRenderedSegs(this.segs, Boolean(mirrorInfo));
  7657. };
  7658. FgEventRenderer.prototype.unrender = function (_segs, mirrorInfo) {
  7659. this.context.view.triggerWillRemoveSegs(this.segs, Boolean(mirrorInfo));
  7660. this.detachSegs(this.segs);
  7661. this.segs = [];
  7662. };
  7663. // Updates values that rely on options and also relate to range
  7664. FgEventRenderer.prototype.rangeUpdated = function () {
  7665. var options = this.context.options;
  7666. var displayEventTime;
  7667. var displayEventEnd;
  7668. this.eventTimeFormat = createFormatter(options.eventTimeFormat || this.computeEventTimeFormat(), options.defaultRangeSeparator);
  7669. displayEventTime = options.displayEventTime;
  7670. if (displayEventTime == null) {
  7671. displayEventTime = this.computeDisplayEventTime(); // might be based off of range
  7672. }
  7673. displayEventEnd = options.displayEventEnd;
  7674. if (displayEventEnd == null) {
  7675. displayEventEnd = this.computeDisplayEventEnd(); // might be based off of range
  7676. }
  7677. this.displayEventTime = displayEventTime;
  7678. this.displayEventEnd = displayEventEnd;
  7679. };
  7680. // Renders and assigns an `el` property for each foreground event segment.
  7681. // Only returns segments that successfully rendered.
  7682. FgEventRenderer.prototype.renderSegEls = function (segs, mirrorInfo) {
  7683. var html = '';
  7684. var i;
  7685. if (segs.length) { // don't build an empty html string
  7686. // build a large concatenation of event segment HTML
  7687. for (i = 0; i < segs.length; i++) {
  7688. html += this.renderSegHtml(segs[i], mirrorInfo);
  7689. }
  7690. // Grab individual elements from the combined HTML string. Use each as the default rendering.
  7691. // Then, compute the 'el' for each segment. An el might be null if the eventRender callback returned false.
  7692. htmlToElements(html).forEach(function (el, i) {
  7693. var seg = segs[i];
  7694. if (el) {
  7695. seg.el = el;
  7696. }
  7697. });
  7698. segs = filterSegsViaEls(this.context.view, segs, Boolean(mirrorInfo));
  7699. }
  7700. return segs;
  7701. };
  7702. // Generic utility for generating the HTML classNames for an event segment's element
  7703. FgEventRenderer.prototype.getSegClasses = function (seg, isDraggable, isResizable, mirrorInfo) {
  7704. var classes = [
  7705. 'fc-event',
  7706. seg.isStart ? 'fc-start' : 'fc-not-start',
  7707. seg.isEnd ? 'fc-end' : 'fc-not-end'
  7708. ].concat(seg.eventRange.ui.classNames);
  7709. if (isDraggable) {
  7710. classes.push('fc-draggable');
  7711. }
  7712. if (isResizable) {
  7713. classes.push('fc-resizable');
  7714. }
  7715. if (mirrorInfo) {
  7716. classes.push('fc-mirror');
  7717. if (mirrorInfo.isDragging) {
  7718. classes.push('fc-dragging');
  7719. }
  7720. if (mirrorInfo.isResizing) {
  7721. classes.push('fc-resizing');
  7722. }
  7723. }
  7724. return classes;
  7725. };
  7726. // Compute the text that should be displayed on an event's element.
  7727. // `range` can be the Event object itself, or something range-like, with at least a `start`.
  7728. // If event times are disabled, or the event has no time, will return a blank string.
  7729. // If not specified, formatter will default to the eventTimeFormat setting,
  7730. // and displayEnd will default to the displayEventEnd setting.
  7731. FgEventRenderer.prototype.getTimeText = function (eventRange, formatter, displayEnd) {
  7732. var def = eventRange.def, instance = eventRange.instance;
  7733. return this._getTimeText(instance.range.start, def.hasEnd ? instance.range.end : null, def.allDay, formatter, displayEnd, instance.forcedStartTzo, instance.forcedEndTzo);
  7734. };
  7735. FgEventRenderer.prototype._getTimeText = function (start, end, allDay, formatter, displayEnd, forcedStartTzo, forcedEndTzo) {
  7736. var dateEnv = this.context.dateEnv;
  7737. if (formatter == null) {
  7738. formatter = this.eventTimeFormat;
  7739. }
  7740. if (displayEnd == null) {
  7741. displayEnd = this.displayEventEnd;
  7742. }
  7743. if (this.displayEventTime && !allDay) {
  7744. if (displayEnd && end) {
  7745. return dateEnv.formatRange(start, end, formatter, {
  7746. forcedStartTzo: forcedStartTzo,
  7747. forcedEndTzo: forcedEndTzo
  7748. });
  7749. }
  7750. else {
  7751. return dateEnv.format(start, formatter, {
  7752. forcedTzo: forcedStartTzo
  7753. });
  7754. }
  7755. }
  7756. return '';
  7757. };
  7758. FgEventRenderer.prototype.computeEventTimeFormat = function () {
  7759. return {
  7760. hour: 'numeric',
  7761. minute: '2-digit',
  7762. omitZeroMinute: true
  7763. };
  7764. };
  7765. FgEventRenderer.prototype.computeDisplayEventTime = function () {
  7766. return true;
  7767. };
  7768. FgEventRenderer.prototype.computeDisplayEventEnd = function () {
  7769. return true;
  7770. };
  7771. // Utility for generating event skin-related CSS properties
  7772. FgEventRenderer.prototype.getSkinCss = function (ui) {
  7773. return {
  7774. 'background-color': ui.backgroundColor,
  7775. 'border-color': ui.borderColor,
  7776. color: ui.textColor
  7777. };
  7778. };
  7779. FgEventRenderer.prototype.sortEventSegs = function (segs) {
  7780. var specs = this.context.view.eventOrderSpecs;
  7781. var objs = segs.map(buildSegCompareObj);
  7782. objs.sort(function (obj0, obj1) {
  7783. return compareByFieldSpecs(obj0, obj1, specs);
  7784. });
  7785. return objs.map(function (c) {
  7786. return c._seg;
  7787. });
  7788. };
  7789. FgEventRenderer.prototype.computeSizes = function (force) {
  7790. if (force || this.isSizeDirty) {
  7791. this.computeSegSizes(this.segs);
  7792. }
  7793. };
  7794. FgEventRenderer.prototype.assignSizes = function (force) {
  7795. if (force || this.isSizeDirty) {
  7796. this.assignSegSizes(this.segs);
  7797. this.isSizeDirty = false;
  7798. }
  7799. };
  7800. FgEventRenderer.prototype.computeSegSizes = function (segs) {
  7801. };
  7802. FgEventRenderer.prototype.assignSegSizes = function (segs) {
  7803. };
  7804. // Manipulation on rendered segs
  7805. FgEventRenderer.prototype.hideByHash = function (hash) {
  7806. if (hash) {
  7807. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7808. var seg = _a[_i];
  7809. if (hash[seg.eventRange.instance.instanceId]) {
  7810. seg.el.style.visibility = 'hidden';
  7811. }
  7812. }
  7813. }
  7814. };
  7815. FgEventRenderer.prototype.showByHash = function (hash) {
  7816. if (hash) {
  7817. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7818. var seg = _a[_i];
  7819. if (hash[seg.eventRange.instance.instanceId]) {
  7820. seg.el.style.visibility = '';
  7821. }
  7822. }
  7823. }
  7824. };
  7825. FgEventRenderer.prototype.selectByInstanceId = function (instanceId) {
  7826. if (instanceId) {
  7827. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7828. var seg = _a[_i];
  7829. var eventInstance = seg.eventRange.instance;
  7830. if (eventInstance && eventInstance.instanceId === instanceId &&
  7831. seg.el // necessary?
  7832. ) {
  7833. seg.el.classList.add('fc-selected');
  7834. }
  7835. }
  7836. }
  7837. };
  7838. FgEventRenderer.prototype.unselectByInstanceId = function (instanceId) {
  7839. if (instanceId) {
  7840. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7841. var seg = _a[_i];
  7842. if (seg.el) { // necessary?
  7843. seg.el.classList.remove('fc-selected');
  7844. }
  7845. }
  7846. }
  7847. };
  7848. return FgEventRenderer;
  7849. }());
  7850. // returns a object with all primitive props that can be compared
  7851. function buildSegCompareObj(seg) {
  7852. var eventDef = seg.eventRange.def;
  7853. var range = seg.eventRange.instance.range;
  7854. var start = range.start ? range.start.valueOf() : 0; // TODO: better support for open-range events
  7855. var end = range.end ? range.end.valueOf() : 0; // "
  7856. return __assign({}, eventDef.extendedProps, eventDef, { id: eventDef.publicId, start: start,
  7857. end: end, duration: end - start, allDay: Number(eventDef.allDay), _seg: seg // for later retrieval
  7858. });
  7859. }
  7860. var FillRenderer = /** @class */ (function () {
  7861. function FillRenderer(context) {
  7862. this.fillSegTag = 'div';
  7863. this.dirtySizeFlags = {};
  7864. this.context = context;
  7865. this.containerElsByType = {};
  7866. this.segsByType = {};
  7867. }
  7868. FillRenderer.prototype.getSegsByType = function (type) {
  7869. return this.segsByType[type] || [];
  7870. };
  7871. FillRenderer.prototype.renderSegs = function (type, segs) {
  7872. var _a;
  7873. var renderedSegs = this.renderSegEls(type, segs); // assignes `.el` to each seg. returns successfully rendered segs
  7874. var containerEls = this.attachSegs(type, renderedSegs);
  7875. if (containerEls) {
  7876. (_a = (this.containerElsByType[type] || (this.containerElsByType[type] = []))).push.apply(_a, containerEls);
  7877. }
  7878. this.segsByType[type] = renderedSegs;
  7879. if (type === 'bgEvent') {
  7880. this.context.view.triggerRenderedSegs(renderedSegs, false); // isMirror=false
  7881. }
  7882. this.dirtySizeFlags[type] = true;
  7883. };
  7884. // Unrenders a specific type of fill that is currently rendered on the grid
  7885. FillRenderer.prototype.unrender = function (type) {
  7886. var segs = this.segsByType[type];
  7887. if (segs) {
  7888. if (type === 'bgEvent') {
  7889. this.context.view.triggerWillRemoveSegs(segs, false); // isMirror=false
  7890. }
  7891. this.detachSegs(type, segs);
  7892. }
  7893. };
  7894. // Renders and assigns an `el` property for each fill segment. Generic enough to work with different types.
  7895. // Only returns segments that successfully rendered.
  7896. FillRenderer.prototype.renderSegEls = function (type, segs) {
  7897. var _this = this;
  7898. var html = '';
  7899. var i;
  7900. if (segs.length) {
  7901. // build a large concatenation of segment HTML
  7902. for (i = 0; i < segs.length; i++) {
  7903. html += this.renderSegHtml(type, segs[i]);
  7904. }
  7905. // Grab individual elements from the combined HTML string. Use each as the default rendering.
  7906. // Then, compute the 'el' for each segment.
  7907. htmlToElements(html).forEach(function (el, i) {
  7908. var seg = segs[i];
  7909. if (el) {
  7910. seg.el = el;
  7911. }
  7912. });
  7913. if (type === 'bgEvent') {
  7914. segs = filterSegsViaEls(this.context.view, segs, false // isMirror. background events can never be mirror elements
  7915. );
  7916. }
  7917. // correct element type? (would be bad if a non-TD were inserted into a table for example)
  7918. segs = segs.filter(function (seg) {
  7919. return elementMatches(seg.el, _this.fillSegTag);
  7920. });
  7921. }
  7922. return segs;
  7923. };
  7924. // Builds the HTML needed for one fill segment. Generic enough to work with different types.
  7925. FillRenderer.prototype.renderSegHtml = function (type, seg) {
  7926. var css = null;
  7927. var classNames = [];
  7928. if (type !== 'highlight' && type !== 'businessHours') {
  7929. css = {
  7930. 'background-color': seg.eventRange.ui.backgroundColor
  7931. };
  7932. }
  7933. if (type !== 'highlight') {
  7934. classNames = classNames.concat(seg.eventRange.ui.classNames);
  7935. }
  7936. if (type === 'businessHours') {
  7937. classNames.push('fc-bgevent');
  7938. }
  7939. else {
  7940. classNames.push('fc-' + type.toLowerCase());
  7941. }
  7942. return '<' + this.fillSegTag +
  7943. (classNames.length ? ' class="' + classNames.join(' ') + '"' : '') +
  7944. (css ? ' style="' + cssToStr(css) + '"' : '') +
  7945. '></' + this.fillSegTag + '>';
  7946. };
  7947. FillRenderer.prototype.detachSegs = function (type, segs) {
  7948. var containerEls = this.containerElsByType[type];
  7949. if (containerEls) {
  7950. containerEls.forEach(removeElement);
  7951. delete this.containerElsByType[type];
  7952. }
  7953. };
  7954. FillRenderer.prototype.computeSizes = function (force) {
  7955. for (var type in this.segsByType) {
  7956. if (force || this.dirtySizeFlags[type]) {
  7957. this.computeSegSizes(this.segsByType[type]);
  7958. }
  7959. }
  7960. };
  7961. FillRenderer.prototype.assignSizes = function (force) {
  7962. for (var type in this.segsByType) {
  7963. if (force || this.dirtySizeFlags[type]) {
  7964. this.assignSegSizes(this.segsByType[type]);
  7965. }
  7966. }
  7967. this.dirtySizeFlags = {};
  7968. };
  7969. FillRenderer.prototype.computeSegSizes = function (segs) {
  7970. };
  7971. FillRenderer.prototype.assignSegSizes = function (segs) {
  7972. };
  7973. return FillRenderer;
  7974. }());
  7975. var NamedTimeZoneImpl = /** @class */ (function () {
  7976. function NamedTimeZoneImpl(timeZoneName) {
  7977. this.timeZoneName = timeZoneName;
  7978. }
  7979. return NamedTimeZoneImpl;
  7980. }());
  7981. /*
  7982. An abstraction for a dragging interaction originating on an event.
  7983. Does higher-level things than PointerDragger, such as possibly:
  7984. - a "mirror" that moves with the pointer
  7985. - a minimum number of pixels or other criteria for a true drag to begin
  7986. subclasses must emit:
  7987. - pointerdown
  7988. - dragstart
  7989. - dragmove
  7990. - pointerup
  7991. - dragend
  7992. */
  7993. var ElementDragging = /** @class */ (function () {
  7994. function ElementDragging(el) {
  7995. this.emitter = new EmitterMixin();
  7996. }
  7997. ElementDragging.prototype.destroy = function () {
  7998. };
  7999. ElementDragging.prototype.setMirrorIsVisible = function (bool) {
  8000. // optional if subclass doesn't want to support a mirror
  8001. };
  8002. ElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  8003. // optional if subclass doesn't want to support a mirror
  8004. };
  8005. ElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  8006. // optional
  8007. };
  8008. return ElementDragging;
  8009. }());
  8010. function formatDate(dateInput, settings) {
  8011. if (settings === void 0) { settings = {}; }
  8012. var dateEnv = buildDateEnv$1(settings);
  8013. var formatter = createFormatter(settings);
  8014. var dateMeta = dateEnv.createMarkerMeta(dateInput);
  8015. if (!dateMeta) { // TODO: warning?
  8016. return '';
  8017. }
  8018. return dateEnv.format(dateMeta.marker, formatter, {
  8019. forcedTzo: dateMeta.forcedTzo
  8020. });
  8021. }
  8022. function formatRange(startInput, endInput, settings // mixture of env and formatter settings
  8023. ) {
  8024. var dateEnv = buildDateEnv$1(typeof settings === 'object' && settings ? settings : {}); // pass in if non-null object
  8025. var formatter = createFormatter(settings, globalDefaults.defaultRangeSeparator);
  8026. var startMeta = dateEnv.createMarkerMeta(startInput);
  8027. var endMeta = dateEnv.createMarkerMeta(endInput);
  8028. if (!startMeta || !endMeta) { // TODO: warning?
  8029. return '';
  8030. }
  8031. return dateEnv.formatRange(startMeta.marker, endMeta.marker, formatter, {
  8032. forcedStartTzo: startMeta.forcedTzo,
  8033. forcedEndTzo: endMeta.forcedTzo,
  8034. isEndExclusive: settings.isEndExclusive
  8035. });
  8036. }
  8037. // TODO: more DRY and optimized
  8038. function buildDateEnv$1(settings) {
  8039. var locale = buildLocale(settings.locale || 'en', parseRawLocales([]).map); // TODO: don't hardcode 'en' everywhere
  8040. // ensure required settings
  8041. settings = __assign({ timeZone: globalDefaults.timeZone, calendarSystem: 'gregory' }, settings, { locale: locale });
  8042. return new DateEnv(settings);
  8043. }
  8044. var DRAG_META_PROPS = {
  8045. startTime: createDuration,
  8046. duration: createDuration,
  8047. create: Boolean,
  8048. sourceId: String
  8049. };
  8050. var DRAG_META_DEFAULTS = {
  8051. create: true
  8052. };
  8053. function parseDragMeta(raw) {
  8054. var leftoverProps = {};
  8055. var refined = refineProps(raw, DRAG_META_PROPS, DRAG_META_DEFAULTS, leftoverProps);
  8056. refined.leftoverProps = leftoverProps;
  8057. return refined;
  8058. }
  8059. // Computes a default column header formatting string if `colFormat` is not explicitly defined
  8060. function computeFallbackHeaderFormat(datesRepDistinctDays, dayCnt) {
  8061. // if more than one week row, or if there are a lot of columns with not much space,
  8062. // put just the day numbers will be in each cell
  8063. if (!datesRepDistinctDays || dayCnt > 10) {
  8064. return { weekday: 'short' }; // "Sat"
  8065. }
  8066. else if (dayCnt > 1) {
  8067. return { weekday: 'short', month: 'numeric', day: 'numeric', omitCommas: true }; // "Sat 11/12"
  8068. }
  8069. else {
  8070. return { weekday: 'long' }; // "Saturday"
  8071. }
  8072. }
  8073. function renderDateCell(dateMarker, dateProfile, datesRepDistinctDays, colCnt, colHeadFormat, context, colspan, otherAttrs) {
  8074. var view = context.view, dateEnv = context.dateEnv, theme = context.theme, options = context.options;
  8075. var isDateValid = rangeContainsMarker(dateProfile.activeRange, dateMarker); // TODO: called too frequently. cache somehow.
  8076. var classNames = [
  8077. 'fc-day-header',
  8078. theme.getClass('widgetHeader')
  8079. ];
  8080. var innerHtml;
  8081. if (typeof options.columnHeaderHtml === 'function') {
  8082. innerHtml = options.columnHeaderHtml(dateEnv.toDate(dateMarker));
  8083. }
  8084. else if (typeof options.columnHeaderText === 'function') {
  8085. innerHtml = htmlEscape(options.columnHeaderText(dateEnv.toDate(dateMarker)));
  8086. }
  8087. else {
  8088. innerHtml = htmlEscape(dateEnv.format(dateMarker, colHeadFormat));
  8089. }
  8090. // if only one row of days, the classNames on the header can represent the specific days beneath
  8091. if (datesRepDistinctDays) {
  8092. classNames = classNames.concat(
  8093. // includes the day-of-week class
  8094. // noThemeHighlight=true (don't highlight the header)
  8095. getDayClasses(dateMarker, dateProfile, context, true));
  8096. }
  8097. else {
  8098. classNames.push('fc-' + DAY_IDS[dateMarker.getUTCDay()]); // only add the day-of-week class
  8099. }
  8100. return '' +
  8101. '<th class="' + classNames.join(' ') + '"' +
  8102. ((isDateValid && datesRepDistinctDays) ?
  8103. ' data-date="' + dateEnv.formatIso(dateMarker, { omitTime: true }) + '"' :
  8104. '') +
  8105. (colspan > 1 ?
  8106. ' colspan="' + colspan + '"' :
  8107. '') +
  8108. (otherAttrs ?
  8109. ' ' + otherAttrs :
  8110. '') +
  8111. '>' +
  8112. (isDateValid ?
  8113. // don't make a link if the heading could represent multiple days, or if there's only one day (forceOff)
  8114. buildGotoAnchorHtml(view, { date: dateMarker, forceOff: !datesRepDistinctDays || colCnt === 1 }, innerHtml) :
  8115. // if not valid, display text, but no link
  8116. innerHtml) +
  8117. '</th>';
  8118. }
  8119. var DayHeader = /** @class */ (function (_super) {
  8120. __extends(DayHeader, _super);
  8121. function DayHeader(context, parentEl) {
  8122. var _this = _super.call(this, context) || this;
  8123. parentEl.innerHTML = ''; // because might be nbsp
  8124. parentEl.appendChild(_this.el = htmlToElement('<div class="fc-row ' + _this.theme.getClass('headerRow') + '">' +
  8125. '<table class="' + _this.theme.getClass('tableGrid') + '">' +
  8126. '<thead></thead>' +
  8127. '</table>' +
  8128. '</div>'));
  8129. _this.thead = _this.el.querySelector('thead');
  8130. return _this;
  8131. }
  8132. DayHeader.prototype.destroy = function () {
  8133. removeElement(this.el);
  8134. };
  8135. DayHeader.prototype.render = function (props) {
  8136. var dates = props.dates, datesRepDistinctDays = props.datesRepDistinctDays;
  8137. var parts = [];
  8138. if (props.renderIntroHtml) {
  8139. parts.push(props.renderIntroHtml());
  8140. }
  8141. var colHeadFormat = createFormatter(this.opt('columnHeaderFormat') ||
  8142. computeFallbackHeaderFormat(datesRepDistinctDays, dates.length));
  8143. for (var _i = 0, dates_1 = dates; _i < dates_1.length; _i++) {
  8144. var date = dates_1[_i];
  8145. parts.push(renderDateCell(date, props.dateProfile, datesRepDistinctDays, dates.length, colHeadFormat, this.context));
  8146. }
  8147. if (this.isRtl) {
  8148. parts.reverse();
  8149. }
  8150. this.thead.innerHTML = '<tr>' + parts.join('') + '</tr>';
  8151. };
  8152. return DayHeader;
  8153. }(Component));
  8154. var DaySeries = /** @class */ (function () {
  8155. function DaySeries(range, dateProfileGenerator) {
  8156. var date = range.start;
  8157. var end = range.end;
  8158. var indices = [];
  8159. var dates = [];
  8160. var dayIndex = -1;
  8161. while (date < end) { // loop each day from start to end
  8162. if (dateProfileGenerator.isHiddenDay(date)) {
  8163. indices.push(dayIndex + 0.5); // mark that it's between indices
  8164. }
  8165. else {
  8166. dayIndex++;
  8167. indices.push(dayIndex);
  8168. dates.push(date);
  8169. }
  8170. date = addDays(date, 1);
  8171. }
  8172. this.dates = dates;
  8173. this.indices = indices;
  8174. this.cnt = dates.length;
  8175. }
  8176. DaySeries.prototype.sliceRange = function (range) {
  8177. var firstIndex = this.getDateDayIndex(range.start); // inclusive first index
  8178. var lastIndex = this.getDateDayIndex(addDays(range.end, -1)); // inclusive last index
  8179. var clippedFirstIndex = Math.max(0, firstIndex);
  8180. var clippedLastIndex = Math.min(this.cnt - 1, lastIndex);
  8181. // deal with in-between indices
  8182. clippedFirstIndex = Math.ceil(clippedFirstIndex); // in-between starts round to next cell
  8183. clippedLastIndex = Math.floor(clippedLastIndex); // in-between ends round to prev cell
  8184. if (clippedFirstIndex <= clippedLastIndex) {
  8185. return {
  8186. firstIndex: clippedFirstIndex,
  8187. lastIndex: clippedLastIndex,
  8188. isStart: firstIndex === clippedFirstIndex,
  8189. isEnd: lastIndex === clippedLastIndex
  8190. };
  8191. }
  8192. else {
  8193. return null;
  8194. }
  8195. };
  8196. // Given a date, returns its chronolocial cell-index from the first cell of the grid.
  8197. // If the date lies between cells (because of hiddenDays), returns a floating-point value between offsets.
  8198. // If before the first offset, returns a negative number.
  8199. // If after the last offset, returns an offset past the last cell offset.
  8200. // Only works for *start* dates of cells. Will not work for exclusive end dates for cells.
  8201. DaySeries.prototype.getDateDayIndex = function (date) {
  8202. var indices = this.indices;
  8203. var dayOffset = Math.floor(diffDays(this.dates[0], date));
  8204. if (dayOffset < 0) {
  8205. return indices[0] - 1;
  8206. }
  8207. else if (dayOffset >= indices.length) {
  8208. return indices[indices.length - 1] + 1;
  8209. }
  8210. else {
  8211. return indices[dayOffset];
  8212. }
  8213. };
  8214. return DaySeries;
  8215. }());
  8216. var DayTable = /** @class */ (function () {
  8217. function DayTable(daySeries, breakOnWeeks) {
  8218. var dates = daySeries.dates;
  8219. var daysPerRow;
  8220. var firstDay;
  8221. var rowCnt;
  8222. if (breakOnWeeks) {
  8223. // count columns until the day-of-week repeats
  8224. firstDay = dates[0].getUTCDay();
  8225. for (daysPerRow = 1; daysPerRow < dates.length; daysPerRow++) {
  8226. if (dates[daysPerRow].getUTCDay() === firstDay) {
  8227. break;
  8228. }
  8229. }
  8230. rowCnt = Math.ceil(dates.length / daysPerRow);
  8231. }
  8232. else {
  8233. rowCnt = 1;
  8234. daysPerRow = dates.length;
  8235. }
  8236. this.rowCnt = rowCnt;
  8237. this.colCnt = daysPerRow;
  8238. this.daySeries = daySeries;
  8239. this.cells = this.buildCells();
  8240. this.headerDates = this.buildHeaderDates();
  8241. }
  8242. DayTable.prototype.buildCells = function () {
  8243. var rows = [];
  8244. for (var row = 0; row < this.rowCnt; row++) {
  8245. var cells = [];
  8246. for (var col = 0; col < this.colCnt; col++) {
  8247. cells.push(this.buildCell(row, col));
  8248. }
  8249. rows.push(cells);
  8250. }
  8251. return rows;
  8252. };
  8253. DayTable.prototype.buildCell = function (row, col) {
  8254. return {
  8255. date: this.daySeries.dates[row * this.colCnt + col]
  8256. };
  8257. };
  8258. DayTable.prototype.buildHeaderDates = function () {
  8259. var dates = [];
  8260. for (var col = 0; col < this.colCnt; col++) {
  8261. dates.push(this.cells[0][col].date);
  8262. }
  8263. return dates;
  8264. };
  8265. DayTable.prototype.sliceRange = function (range) {
  8266. var colCnt = this.colCnt;
  8267. var seriesSeg = this.daySeries.sliceRange(range);
  8268. var segs = [];
  8269. if (seriesSeg) {
  8270. var firstIndex = seriesSeg.firstIndex, lastIndex = seriesSeg.lastIndex;
  8271. var index = firstIndex;
  8272. while (index <= lastIndex) {
  8273. var row = Math.floor(index / colCnt);
  8274. var nextIndex = Math.min((row + 1) * colCnt, lastIndex + 1);
  8275. segs.push({
  8276. row: row,
  8277. firstCol: index % colCnt,
  8278. lastCol: (nextIndex - 1) % colCnt,
  8279. isStart: seriesSeg.isStart && index === firstIndex,
  8280. isEnd: seriesSeg.isEnd && (nextIndex - 1) === lastIndex
  8281. });
  8282. index = nextIndex;
  8283. }
  8284. }
  8285. return segs;
  8286. };
  8287. return DayTable;
  8288. }());
  8289. var Slicer = /** @class */ (function () {
  8290. function Slicer() {
  8291. this.sliceBusinessHours = memoize(this._sliceBusinessHours);
  8292. this.sliceDateSelection = memoize(this._sliceDateSpan);
  8293. this.sliceEventStore = memoize(this._sliceEventStore);
  8294. this.sliceEventDrag = memoize(this._sliceInteraction);
  8295. this.sliceEventResize = memoize(this._sliceInteraction);
  8296. }
  8297. Slicer.prototype.sliceProps = function (props, dateProfile, nextDayThreshold, component) {
  8298. var extraArgs = [];
  8299. for (var _i = 4; _i < arguments.length; _i++) {
  8300. extraArgs[_i - 4] = arguments[_i];
  8301. }
  8302. var eventUiBases = props.eventUiBases;
  8303. var eventSegs = this.sliceEventStore.apply(this, [props.eventStore, eventUiBases, dateProfile, nextDayThreshold, component].concat(extraArgs));
  8304. return {
  8305. dateSelectionSegs: this.sliceDateSelection.apply(this, [props.dateSelection, eventUiBases, component].concat(extraArgs)),
  8306. businessHourSegs: this.sliceBusinessHours.apply(this, [props.businessHours, dateProfile, nextDayThreshold, component].concat(extraArgs)),
  8307. fgEventSegs: eventSegs.fg,
  8308. bgEventSegs: eventSegs.bg,
  8309. eventDrag: this.sliceEventDrag.apply(this, [props.eventDrag, eventUiBases, dateProfile, nextDayThreshold, component].concat(extraArgs)),
  8310. eventResize: this.sliceEventResize.apply(this, [props.eventResize, eventUiBases, dateProfile, nextDayThreshold, component].concat(extraArgs)),
  8311. eventSelection: props.eventSelection
  8312. }; // TODO: give interactionSegs?
  8313. };
  8314. Slicer.prototype.sliceNowDate = function (// does not memoize
  8315. date, component) {
  8316. var extraArgs = [];
  8317. for (var _i = 2; _i < arguments.length; _i++) {
  8318. extraArgs[_i - 2] = arguments[_i];
  8319. }
  8320. return this._sliceDateSpan.apply(this, [{ range: { start: date, end: addMs(date, 1) }, allDay: false },
  8321. {},
  8322. component].concat(extraArgs));
  8323. };
  8324. Slicer.prototype._sliceBusinessHours = function (businessHours, dateProfile, nextDayThreshold, component) {
  8325. var extraArgs = [];
  8326. for (var _i = 4; _i < arguments.length; _i++) {
  8327. extraArgs[_i - 4] = arguments[_i];
  8328. }
  8329. if (!businessHours) {
  8330. return [];
  8331. }
  8332. return this._sliceEventStore.apply(this, [expandRecurring(businessHours, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), component.calendar),
  8333. {},
  8334. dateProfile,
  8335. nextDayThreshold,
  8336. component].concat(extraArgs)).bg;
  8337. };
  8338. Slicer.prototype._sliceEventStore = function (eventStore, eventUiBases, dateProfile, nextDayThreshold, component) {
  8339. var extraArgs = [];
  8340. for (var _i = 5; _i < arguments.length; _i++) {
  8341. extraArgs[_i - 5] = arguments[_i];
  8342. }
  8343. if (eventStore) {
  8344. var rangeRes = sliceEventStore(eventStore, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8345. return {
  8346. bg: this.sliceEventRanges(rangeRes.bg, component, extraArgs),
  8347. fg: this.sliceEventRanges(rangeRes.fg, component, extraArgs)
  8348. };
  8349. }
  8350. else {
  8351. return { bg: [], fg: [] };
  8352. }
  8353. };
  8354. Slicer.prototype._sliceInteraction = function (interaction, eventUiBases, dateProfile, nextDayThreshold, component) {
  8355. var extraArgs = [];
  8356. for (var _i = 5; _i < arguments.length; _i++) {
  8357. extraArgs[_i - 5] = arguments[_i];
  8358. }
  8359. if (!interaction) {
  8360. return null;
  8361. }
  8362. var rangeRes = sliceEventStore(interaction.mutatedEvents, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8363. return {
  8364. segs: this.sliceEventRanges(rangeRes.fg, component, extraArgs),
  8365. affectedInstances: interaction.affectedEvents.instances,
  8366. isEvent: interaction.isEvent,
  8367. sourceSeg: interaction.origSeg
  8368. };
  8369. };
  8370. Slicer.prototype._sliceDateSpan = function (dateSpan, eventUiBases, component) {
  8371. var extraArgs = [];
  8372. for (var _i = 3; _i < arguments.length; _i++) {
  8373. extraArgs[_i - 3] = arguments[_i];
  8374. }
  8375. if (!dateSpan) {
  8376. return [];
  8377. }
  8378. var eventRange = fabricateEventRange(dateSpan, eventUiBases, component.calendar);
  8379. var segs = this.sliceRange.apply(this, [dateSpan.range].concat(extraArgs));
  8380. for (var _a = 0, segs_1 = segs; _a < segs_1.length; _a++) {
  8381. var seg = segs_1[_a];
  8382. seg.component = component;
  8383. seg.eventRange = eventRange;
  8384. }
  8385. return segs;
  8386. };
  8387. /*
  8388. "complete" seg means it has component and eventRange
  8389. */
  8390. Slicer.prototype.sliceEventRanges = function (eventRanges, component, // TODO: kill
  8391. extraArgs) {
  8392. var segs = [];
  8393. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  8394. var eventRange = eventRanges_1[_i];
  8395. segs.push.apply(segs, this.sliceEventRange(eventRange, component, extraArgs));
  8396. }
  8397. return segs;
  8398. };
  8399. /*
  8400. "complete" seg means it has component and eventRange
  8401. */
  8402. Slicer.prototype.sliceEventRange = function (eventRange, component, // TODO: kill
  8403. extraArgs) {
  8404. var segs = this.sliceRange.apply(this, [eventRange.range].concat(extraArgs));
  8405. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  8406. var seg = segs_2[_i];
  8407. seg.component = component;
  8408. seg.eventRange = eventRange;
  8409. seg.isStart = eventRange.isStart && seg.isStart;
  8410. seg.isEnd = eventRange.isEnd && seg.isEnd;
  8411. }
  8412. return segs;
  8413. };
  8414. return Slicer;
  8415. }());
  8416. /*
  8417. for incorporating minTime/maxTime if appropriate
  8418. TODO: should be part of DateProfile!
  8419. TimelineDateProfile already does this btw
  8420. */
  8421. function computeActiveRange(dateProfile, isComponentAllDay) {
  8422. var range = dateProfile.activeRange;
  8423. if (isComponentAllDay) {
  8424. return range;
  8425. }
  8426. return {
  8427. start: addMs(range.start, dateProfile.minTime.milliseconds),
  8428. end: addMs(range.end, dateProfile.maxTime.milliseconds - 864e5) // 864e5 = ms in a day
  8429. };
  8430. }
  8431. // exports
  8432. // --------------------------------------------------------------------------------------------------
  8433. var version = '4.2.0';
  8434. exports.Calendar = Calendar;
  8435. exports.Component = Component;
  8436. exports.DateComponent = DateComponent;
  8437. exports.DateEnv = DateEnv;
  8438. exports.DateProfileGenerator = DateProfileGenerator;
  8439. exports.DayHeader = DayHeader;
  8440. exports.DaySeries = DaySeries;
  8441. exports.DayTable = DayTable;
  8442. exports.ElementDragging = ElementDragging;
  8443. exports.ElementScrollController = ElementScrollController;
  8444. exports.EmitterMixin = EmitterMixin;
  8445. exports.EventApi = EventApi;
  8446. exports.FgEventRenderer = FgEventRenderer;
  8447. exports.FillRenderer = FillRenderer;
  8448. exports.Interaction = Interaction;
  8449. exports.Mixin = Mixin;
  8450. exports.NamedTimeZoneImpl = NamedTimeZoneImpl;
  8451. exports.PositionCache = PositionCache;
  8452. exports.ScrollComponent = ScrollComponent;
  8453. exports.ScrollController = ScrollController;
  8454. exports.Slicer = Slicer;
  8455. exports.Splitter = Splitter;
  8456. exports.Theme = Theme;
  8457. exports.View = View;
  8458. exports.WindowScrollController = WindowScrollController;
  8459. exports.addDays = addDays;
  8460. exports.addDurations = addDurations;
  8461. exports.addMs = addMs;
  8462. exports.addWeeks = addWeeks;
  8463. exports.allowContextMenu = allowContextMenu;
  8464. exports.allowSelection = allowSelection;
  8465. exports.appendToElement = appendToElement;
  8466. exports.applyAll = applyAll;
  8467. exports.applyMutationToEventStore = applyMutationToEventStore;
  8468. exports.applyStyle = applyStyle;
  8469. exports.applyStyleProp = applyStyleProp;
  8470. exports.asRoughMinutes = asRoughMinutes;
  8471. exports.asRoughMs = asRoughMs;
  8472. exports.asRoughSeconds = asRoughSeconds;
  8473. exports.buildGotoAnchorHtml = buildGotoAnchorHtml;
  8474. exports.buildSegCompareObj = buildSegCompareObj;
  8475. exports.capitaliseFirstLetter = capitaliseFirstLetter;
  8476. exports.combineEventUis = combineEventUis;
  8477. exports.compareByFieldSpec = compareByFieldSpec;
  8478. exports.compareByFieldSpecs = compareByFieldSpecs;
  8479. exports.compareNumbers = compareNumbers;
  8480. exports.compensateScroll = compensateScroll;
  8481. exports.computeClippingRect = computeClippingRect;
  8482. exports.computeEdges = computeEdges;
  8483. exports.computeFallbackHeaderFormat = computeFallbackHeaderFormat;
  8484. exports.computeHeightAndMargins = computeHeightAndMargins;
  8485. exports.computeInnerRect = computeInnerRect;
  8486. exports.computeRect = computeRect;
  8487. exports.computeVisibleDayRange = computeVisibleDayRange;
  8488. exports.config = config;
  8489. exports.constrainPoint = constrainPoint;
  8490. exports.createDuration = createDuration;
  8491. exports.createElement = createElement;
  8492. exports.createEmptyEventStore = createEmptyEventStore;
  8493. exports.createEventInstance = createEventInstance;
  8494. exports.createFormatter = createFormatter;
  8495. exports.createPlugin = createPlugin;
  8496. exports.cssToStr = cssToStr;
  8497. exports.debounce = debounce;
  8498. exports.diffDates = diffDates;
  8499. exports.diffDayAndTime = diffDayAndTime;
  8500. exports.diffDays = diffDays;
  8501. exports.diffPoints = diffPoints;
  8502. exports.diffWeeks = diffWeeks;
  8503. exports.diffWholeDays = diffWholeDays;
  8504. exports.diffWholeWeeks = diffWholeWeeks;
  8505. exports.disableCursor = disableCursor;
  8506. exports.distributeHeight = distributeHeight;
  8507. exports.elementClosest = elementClosest;
  8508. exports.elementMatches = elementMatches;
  8509. exports.enableCursor = enableCursor;
  8510. exports.eventTupleToStore = eventTupleToStore;
  8511. exports.filterEventStoreDefs = filterEventStoreDefs;
  8512. exports.filterHash = filterHash;
  8513. exports.findChildren = findChildren;
  8514. exports.findElements = findElements;
  8515. exports.flexibleCompare = flexibleCompare;
  8516. exports.forceClassName = forceClassName;
  8517. exports.formatDate = formatDate;
  8518. exports.formatIsoTimeString = formatIsoTimeString;
  8519. exports.formatRange = formatRange;
  8520. exports.getAllDayHtml = getAllDayHtml;
  8521. exports.getClippingParents = getClippingParents;
  8522. exports.getDayClasses = getDayClasses;
  8523. exports.getElSeg = getElSeg;
  8524. exports.getRectCenter = getRectCenter;
  8525. exports.getRelevantEvents = getRelevantEvents;
  8526. exports.globalDefaults = globalDefaults;
  8527. exports.greatestDurationDenominator = greatestDurationDenominator;
  8528. exports.hasBgRendering = hasBgRendering;
  8529. exports.htmlEscape = htmlEscape;
  8530. exports.htmlToElement = htmlToElement;
  8531. exports.insertAfterElement = insertAfterElement;
  8532. exports.interactionSettingsStore = interactionSettingsStore;
  8533. exports.interactionSettingsToStore = interactionSettingsToStore;
  8534. exports.intersectRanges = intersectRanges;
  8535. exports.intersectRects = intersectRects;
  8536. exports.isArraysEqual = isArraysEqual;
  8537. exports.isDateSpansEqual = isDateSpansEqual;
  8538. exports.isInt = isInt;
  8539. exports.isInteractionValid = isInteractionValid;
  8540. exports.isMultiDayRange = isMultiDayRange;
  8541. exports.isPropsEqual = isPropsEqual;
  8542. exports.isPropsValid = isPropsValid;
  8543. exports.isSingleDay = isSingleDay;
  8544. exports.isValidDate = isValidDate;
  8545. exports.listenBySelector = listenBySelector;
  8546. exports.mapHash = mapHash;
  8547. exports.matchCellWidths = matchCellWidths;
  8548. exports.memoize = memoize;
  8549. exports.memoizeOutput = memoizeOutput;
  8550. exports.memoizeRendering = memoizeRendering;
  8551. exports.mergeEventStores = mergeEventStores;
  8552. exports.multiplyDuration = multiplyDuration;
  8553. exports.padStart = padStart;
  8554. exports.parseBusinessHours = parseBusinessHours;
  8555. exports.parseDragMeta = parseDragMeta;
  8556. exports.parseEventDef = parseEventDef;
  8557. exports.parseFieldSpecs = parseFieldSpecs;
  8558. exports.parseMarker = parse;
  8559. exports.pointInsideRect = pointInsideRect;
  8560. exports.prependToElement = prependToElement;
  8561. exports.preventContextMenu = preventContextMenu;
  8562. exports.preventDefault = preventDefault;
  8563. exports.preventSelection = preventSelection;
  8564. exports.processScopedUiProps = processScopedUiProps;
  8565. exports.rangeContainsMarker = rangeContainsMarker;
  8566. exports.rangeContainsRange = rangeContainsRange;
  8567. exports.rangesEqual = rangesEqual;
  8568. exports.rangesIntersect = rangesIntersect;
  8569. exports.refineProps = refineProps;
  8570. exports.removeElement = removeElement;
  8571. exports.removeExact = removeExact;
  8572. exports.renderDateCell = renderDateCell;
  8573. exports.requestJson = requestJson;
  8574. exports.sliceEventStore = sliceEventStore;
  8575. exports.startOfDay = startOfDay;
  8576. exports.subtractInnerElHeight = subtractInnerElHeight;
  8577. exports.translateRect = translateRect;
  8578. exports.uncompensateScroll = uncompensateScroll;
  8579. exports.undistributeHeight = undistributeHeight;
  8580. exports.unpromisify = unpromisify;
  8581. exports.version = version;
  8582. exports.whenTransitionDone = whenTransitionDone;
  8583. exports.wholeDivideDurations = wholeDivideDurations;
  8584. Object.defineProperty(exports, '__esModule', { value: true });
  8585. }));