@fullcalendar/interaction 7.0.0-beta.3 → 7.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -33,7 +33,7 @@ class PointerDragging {
33
33
  // internal states
34
34
  this.isDragging = false;
35
35
  this.isTouchDragging = false;
36
- this.wasTouchScroll = false;
36
+ this.wasTouchScroll = false; // HACK public
37
37
  // Mouse
38
38
  // ----------------------------------------------------------------------------------------------------
39
39
  this.handleMouseDown = (ev) => {
@@ -83,9 +83,11 @@ class PointerDragging {
83
83
  }
84
84
  };
85
85
  this.handleTouchMove = (ev) => {
86
- let pev = this.createEventFromTouch(ev);
87
- this.recordCoords(pev);
88
- this.emitter.trigger('pointermove', pev);
86
+ if (this.isDragging) {
87
+ let pev = this.createEventFromTouch(ev);
88
+ this.recordCoords(pev);
89
+ this.emitter.trigger('pointermove', pev);
90
+ }
89
91
  };
90
92
  this.handleTouchEnd = (ev) => {
91
93
  if (this.isDragging) { // done to guard against touchend followed by touchcancel
@@ -129,6 +131,11 @@ class PointerDragging {
129
131
  this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
130
132
  listenerDestroyed();
131
133
  }
134
+ cancel() {
135
+ if (this.isDragging) {
136
+ this.cleanup();
137
+ }
138
+ }
132
139
  tryStart(ev) {
133
140
  let subjectEl = this.querySubjectEl(ev);
134
141
  let downEl = ev.target;
@@ -712,17 +719,16 @@ class FeaturefulElementDragging extends internal_cjs.ElementDragging {
712
719
  this.isInteracting = true;
713
720
  this.isDelayEnded = false;
714
721
  this.isDistanceSurpassed = false;
715
- internal_cjs.preventSelection(document.body);
716
- internal_cjs.preventContextMenu(document.body);
717
- // prevent links from being visited if there's an eventual drag.
718
- // also prevents selection in older browsers (maybe?).
719
- // not necessary for touch, besides, browser would complain about passiveness.
720
- if (!ev.isTouch) {
721
- ev.origEvent.preventDefault();
722
- }
723
722
  this.emitter.trigger('pointerdown', ev);
724
- if (this.isInteracting && // not destroyed via pointerdown handler
725
- !this.pointer.shouldIgnoreMove) {
723
+ if (this.isInteracting) { // not cancelled?
724
+ internal_cjs.preventSelection(document.body);
725
+ internal_cjs.preventContextMenu(document.body);
726
+ // prevent links from being visited if there's an eventual drag.
727
+ // also prevents selection in older browsers (maybe?).
728
+ // not necessary for touch, besides, browser would complain about passiveness.
729
+ if (!ev.isTouch) {
730
+ ev.origEvent.preventDefault();
731
+ }
726
732
  // actions related to initiating dragstart+dragmove+dragend...
727
733
  this.mirror.setIsVisible(false); // reset. caller must set-visible
728
734
  this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
@@ -829,8 +835,14 @@ class FeaturefulElementDragging extends internal_cjs.ElementDragging {
829
835
  this.emitter.trigger('dragend', ev);
830
836
  }
831
837
  // fill in the implementations...
832
- setIgnoreMove(bool) {
833
- this.pointer.shouldIgnoreMove = bool;
838
+ /*
839
+ Can only be called by pointerdown to prevent drag
840
+ */
841
+ cancel() {
842
+ if (this.isInteracting) {
843
+ this.isInteracting = false;
844
+ this.pointer.cancel();
845
+ }
834
846
  }
835
847
  setMirrorIsVisible(bool) {
836
848
  this.mirror.setIsVisible(bool);
@@ -925,12 +937,11 @@ class HitDragging {
925
937
  this.prepareHits();
926
938
  this.processFirstCoord(ev);
927
939
  if (this.initialHit || !this.requireInitial) {
928
- dragging.setIgnoreMove(false);
929
940
  // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
930
941
  this.emitter.trigger('pointerdown', ev);
931
942
  }
932
943
  else {
933
- dragging.setIgnoreMove(true);
944
+ dragging.cancel();
934
945
  }
935
946
  };
936
947
  this.handleDragStart = (ev) => {
@@ -1089,8 +1100,14 @@ class DateClicking extends internal_cjs.Interaction {
1089
1100
  this.handlePointerDown = (pev) => {
1090
1101
  let { dragging } = this;
1091
1102
  let downEl = pev.origEvent.target;
1092
- // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
1093
- dragging.setIgnoreMove(!this.component.isValidDateDownEl(downEl));
1103
+ /*
1104
+ If no dateClick, allow text on dates to be text-selectable
1105
+ */
1106
+ const canDateClick = this.component.context.emitter.hasHandlers('dateClick') &&
1107
+ this.component.isValidDateDownEl(downEl);
1108
+ if (!canDateClick) {
1109
+ dragging.cancel();
1110
+ }
1094
1111
  };
1095
1112
  // won't even fire if moving was ignored
1096
1113
  this.handleDragEnd = (ev) => {
@@ -1100,7 +1117,7 @@ class DateClicking extends internal_cjs.Interaction {
1100
1117
  let { initialHit, finalHit } = this.hitDragging;
1101
1118
  if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
1102
1119
  let { context } = component;
1103
- let arg = Object.assign(Object.assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.dayEl, jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
1120
+ let arg = Object.assign(Object.assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.getDayEl(), jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
1104
1121
  context.emitter.trigger('dateClick', arg);
1105
1122
  }
1106
1123
  }
@@ -1128,12 +1145,15 @@ class DateSelecting extends internal_cjs.Interaction {
1128
1145
  this.handlePointerDown = (ev) => {
1129
1146
  let { component, dragging } = this;
1130
1147
  let { options } = component.context;
1131
- let canSelect = options.selectable &&
1148
+ let canDateSelect = options.selectable &&
1132
1149
  component.isValidDateDownEl(ev.origEvent.target);
1133
- // don't bother to watch expensive moves if component won't do selection
1134
- dragging.setIgnoreMove(!canSelect);
1135
- // if touch, require user to hold down
1136
- dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
1150
+ if (!canDateSelect) {
1151
+ dragging.cancel();
1152
+ }
1153
+ else {
1154
+ // if touch, require user to hold down
1155
+ dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
1156
+ }
1137
1157
  };
1138
1158
  this.handleDragStart = (ev) => {
1139
1159
  this.component.context.calendarApi.unselect(ev); // unselect previous selections
@@ -1263,11 +1283,15 @@ class EventDragging extends internal_cjs.Interaction {
1263
1283
  mirror.revertDuration = options.dragRevertDuration;
1264
1284
  let isValid = component.isValidSegDownEl(origTarget) &&
1265
1285
  !origTarget.closest('.fc-event-resizer'); // NOT on a resizer
1266
- dragging.setIgnoreMove(!isValid);
1267
- // disable dragging for elements that are resizable (ie, selectable)
1268
- // but are not draggable
1269
- this.isDragging = isValid &&
1270
- ev.subjectEl.classList.contains('fc-event-draggable');
1286
+ if (!isValid) {
1287
+ dragging.cancel();
1288
+ }
1289
+ else {
1290
+ // disable dragging for elements that are resizable (ie, selectable)
1291
+ // but are not draggable
1292
+ // TODO: merge this with .cancel() ?
1293
+ this.isDragging = ev.subjectEl.classList.contains('fc-event-draggable');
1294
+ }
1271
1295
  };
1272
1296
  this.handleDragStart = (ev) => {
1273
1297
  let initialContext = this.component.context;
@@ -1580,9 +1604,11 @@ class EventResizing extends internal_cjs.Interaction {
1580
1604
  let segEl = this.querySegEl(ev);
1581
1605
  let eventRange = this.eventRange = internal_cjs.getElEventRange(segEl);
1582
1606
  this.dragging.minDistance = component.context.options.eventDragMinDistance;
1583
- // if touch, need to be working with a selected event
1584
- this.dragging.setIgnoreMove(!this.component.isValidSegDownEl(ev.origEvent.target) ||
1585
- (ev.isTouch && this.component.props.eventSelection !== eventRange.instance.instanceId));
1607
+ const isValid = this.component.isValidSegDownEl(ev.origEvent.target) &&
1608
+ !(ev.isTouch && this.component.props.eventSelection !== eventRange.instance.instanceId);
1609
+ if (!isValid) {
1610
+ this.dragging.cancel();
1611
+ }
1586
1612
  };
1587
1613
  this.handleDragStart = (ev) => {
1588
1614
  let { context } = this.component;
@@ -2052,8 +2078,8 @@ class InferredElementDragging extends internal_cjs.ElementDragging {
2052
2078
  destroy() {
2053
2079
  this.pointer.destroy();
2054
2080
  }
2055
- setIgnoreMove(bool) {
2056
- this.shouldIgnoreMove = bool;
2081
+ cancel() {
2082
+ this.shouldIgnoreMove = true;
2057
2083
  }
2058
2084
  setMirrorIsVisible(bool) {
2059
2085
  if (bool) {
package/index.d.ts CHANGED
@@ -9,17 +9,18 @@ declare class PointerDragging {
9
9
  handleSelector: string;
10
10
  shouldIgnoreMove: boolean;
11
11
  shouldWatchScroll: boolean;
12
- isDragging: boolean;
13
- isTouchDragging: boolean;
12
+ private isDragging;
13
+ private isTouchDragging;
14
14
  wasTouchScroll: boolean;
15
- origPageX: number;
16
- origPageY: number;
17
- prevPageX: number;
18
- prevPageY: number;
19
- prevScrollX: number;
20
- prevScrollY: number;
15
+ private origPageX;
16
+ private origPageY;
17
+ private prevPageX;
18
+ private prevPageY;
19
+ private prevScrollX;
20
+ private prevScrollY;
21
21
  constructor(containerEl: EventTarget);
22
22
  destroy(): void;
23
+ cancel(): void;
23
24
  tryStart(ev: UIEvent): boolean;
24
25
  cleanup(): void;
25
26
  querySubjectEl(ev: UIEvent): HTMLElement;
@@ -123,12 +124,12 @@ declare class FeaturefulElementDragging extends ElementDragging {
123
124
  delay: number | null;
124
125
  minDistance: number;
125
126
  touchScrollAllowed: boolean;
126
- mirrorNeedsRevert: boolean;
127
- isInteracting: boolean;
128
- isDragging: boolean;
129
- isDelayEnded: boolean;
130
- isDistanceSurpassed: boolean;
131
- delayTimeoutId: number | null;
127
+ private mirrorNeedsRevert;
128
+ private isInteracting;
129
+ private isDragging;
130
+ private isDelayEnded;
131
+ private isDistanceSurpassed;
132
+ private delayTimeoutId;
132
133
  constructor(containerEl: HTMLElement, selector?: string);
133
134
  destroy(): void;
134
135
  onPointerDown: (ev: PointerDragEvent) => void;
@@ -140,7 +141,7 @@ declare class FeaturefulElementDragging extends ElementDragging {
140
141
  tryStartDrag(ev: PointerDragEvent): void;
141
142
  tryStopDrag(ev: PointerDragEvent): void;
142
143
  stopDrag(ev: PointerDragEvent): void;
143
- setIgnoreMove(bool: boolean): void;
144
+ cancel(): void;
144
145
  setMirrorIsVisible(bool: boolean): void;
145
146
  setMirrorNeedsRevert(bool: boolean): void;
146
147
  setAutoScrollEnabled(bool: boolean): void;
@@ -246,7 +247,7 @@ declare class InferredElementDragging extends ElementDragging {
246
247
  handlePointerDown: (ev: PointerDragEvent) => void;
247
248
  handlePointerMove: (ev: PointerDragEvent) => void;
248
249
  handlePointerUp: (ev: PointerDragEvent) => void;
249
- setIgnoreMove(bool: boolean): void;
250
+ cancel(): void;
250
251
  setMirrorIsVisible(bool: boolean): void;
251
252
  }
252
253
 
package/index.global.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- FullCalendar Interaction Plugin v7.0.0-beta.3
2
+ FullCalendar Interaction Plugin v7.0.0-rc.0
3
3
  Docs & License: https://fullcalendar.io/docs/editable
4
4
  (c) 2024 Adam Shaw
5
5
  */
@@ -34,7 +34,7 @@ FullCalendar.Interaction = (function (exports, core, internal) {
34
34
  // internal states
35
35
  this.isDragging = false;
36
36
  this.isTouchDragging = false;
37
- this.wasTouchScroll = false;
37
+ this.wasTouchScroll = false; // HACK public
38
38
  // Mouse
39
39
  // ----------------------------------------------------------------------------------------------------
40
40
  this.handleMouseDown = (ev) => {
@@ -84,9 +84,11 @@ FullCalendar.Interaction = (function (exports, core, internal) {
84
84
  }
85
85
  };
86
86
  this.handleTouchMove = (ev) => {
87
- let pev = this.createEventFromTouch(ev);
88
- this.recordCoords(pev);
89
- this.emitter.trigger('pointermove', pev);
87
+ if (this.isDragging) {
88
+ let pev = this.createEventFromTouch(ev);
89
+ this.recordCoords(pev);
90
+ this.emitter.trigger('pointermove', pev);
91
+ }
90
92
  };
91
93
  this.handleTouchEnd = (ev) => {
92
94
  if (this.isDragging) { // done to guard against touchend followed by touchcancel
@@ -130,6 +132,11 @@ FullCalendar.Interaction = (function (exports, core, internal) {
130
132
  this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
131
133
  listenerDestroyed();
132
134
  }
135
+ cancel() {
136
+ if (this.isDragging) {
137
+ this.cleanup();
138
+ }
139
+ }
133
140
  tryStart(ev) {
134
141
  let subjectEl = this.querySubjectEl(ev);
135
142
  let downEl = ev.target;
@@ -713,17 +720,16 @@ FullCalendar.Interaction = (function (exports, core, internal) {
713
720
  this.isInteracting = true;
714
721
  this.isDelayEnded = false;
715
722
  this.isDistanceSurpassed = false;
716
- internal.preventSelection(document.body);
717
- internal.preventContextMenu(document.body);
718
- // prevent links from being visited if there's an eventual drag.
719
- // also prevents selection in older browsers (maybe?).
720
- // not necessary for touch, besides, browser would complain about passiveness.
721
- if (!ev.isTouch) {
722
- ev.origEvent.preventDefault();
723
- }
724
723
  this.emitter.trigger('pointerdown', ev);
725
- if (this.isInteracting && // not destroyed via pointerdown handler
726
- !this.pointer.shouldIgnoreMove) {
724
+ if (this.isInteracting) { // not cancelled?
725
+ internal.preventSelection(document.body);
726
+ internal.preventContextMenu(document.body);
727
+ // prevent links from being visited if there's an eventual drag.
728
+ // also prevents selection in older browsers (maybe?).
729
+ // not necessary for touch, besides, browser would complain about passiveness.
730
+ if (!ev.isTouch) {
731
+ ev.origEvent.preventDefault();
732
+ }
727
733
  // actions related to initiating dragstart+dragmove+dragend...
728
734
  this.mirror.setIsVisible(false); // reset. caller must set-visible
729
735
  this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
@@ -830,8 +836,14 @@ FullCalendar.Interaction = (function (exports, core, internal) {
830
836
  this.emitter.trigger('dragend', ev);
831
837
  }
832
838
  // fill in the implementations...
833
- setIgnoreMove(bool) {
834
- this.pointer.shouldIgnoreMove = bool;
839
+ /*
840
+ Can only be called by pointerdown to prevent drag
841
+ */
842
+ cancel() {
843
+ if (this.isInteracting) {
844
+ this.isInteracting = false;
845
+ this.pointer.cancel();
846
+ }
835
847
  }
836
848
  setMirrorIsVisible(bool) {
837
849
  this.mirror.setIsVisible(bool);
@@ -926,12 +938,11 @@ FullCalendar.Interaction = (function (exports, core, internal) {
926
938
  this.prepareHits();
927
939
  this.processFirstCoord(ev);
928
940
  if (this.initialHit || !this.requireInitial) {
929
- dragging.setIgnoreMove(false);
930
941
  // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
931
942
  this.emitter.trigger('pointerdown', ev);
932
943
  }
933
944
  else {
934
- dragging.setIgnoreMove(true);
945
+ dragging.cancel();
935
946
  }
936
947
  };
937
948
  this.handleDragStart = (ev) => {
@@ -1090,8 +1101,14 @@ FullCalendar.Interaction = (function (exports, core, internal) {
1090
1101
  this.handlePointerDown = (pev) => {
1091
1102
  let { dragging } = this;
1092
1103
  let downEl = pev.origEvent.target;
1093
- // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
1094
- dragging.setIgnoreMove(!this.component.isValidDateDownEl(downEl));
1104
+ /*
1105
+ If no dateClick, allow text on dates to be text-selectable
1106
+ */
1107
+ const canDateClick = this.component.context.emitter.hasHandlers('dateClick') &&
1108
+ this.component.isValidDateDownEl(downEl);
1109
+ if (!canDateClick) {
1110
+ dragging.cancel();
1111
+ }
1095
1112
  };
1096
1113
  // won't even fire if moving was ignored
1097
1114
  this.handleDragEnd = (ev) => {
@@ -1101,7 +1118,7 @@ FullCalendar.Interaction = (function (exports, core, internal) {
1101
1118
  let { initialHit, finalHit } = this.hitDragging;
1102
1119
  if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
1103
1120
  let { context } = component;
1104
- let arg = Object.assign(Object.assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.dayEl, jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
1121
+ let arg = Object.assign(Object.assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.getDayEl(), jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
1105
1122
  context.emitter.trigger('dateClick', arg);
1106
1123
  }
1107
1124
  }
@@ -1129,12 +1146,15 @@ FullCalendar.Interaction = (function (exports, core, internal) {
1129
1146
  this.handlePointerDown = (ev) => {
1130
1147
  let { component, dragging } = this;
1131
1148
  let { options } = component.context;
1132
- let canSelect = options.selectable &&
1149
+ let canDateSelect = options.selectable &&
1133
1150
  component.isValidDateDownEl(ev.origEvent.target);
1134
- // don't bother to watch expensive moves if component won't do selection
1135
- dragging.setIgnoreMove(!canSelect);
1136
- // if touch, require user to hold down
1137
- dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
1151
+ if (!canDateSelect) {
1152
+ dragging.cancel();
1153
+ }
1154
+ else {
1155
+ // if touch, require user to hold down
1156
+ dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
1157
+ }
1138
1158
  };
1139
1159
  this.handleDragStart = (ev) => {
1140
1160
  this.component.context.calendarApi.unselect(ev); // unselect previous selections
@@ -1264,11 +1284,15 @@ FullCalendar.Interaction = (function (exports, core, internal) {
1264
1284
  mirror.revertDuration = options.dragRevertDuration;
1265
1285
  let isValid = component.isValidSegDownEl(origTarget) &&
1266
1286
  !origTarget.closest('.fc-event-resizer'); // NOT on a resizer
1267
- dragging.setIgnoreMove(!isValid);
1268
- // disable dragging for elements that are resizable (ie, selectable)
1269
- // but are not draggable
1270
- this.isDragging = isValid &&
1271
- ev.subjectEl.classList.contains('fc-event-draggable');
1287
+ if (!isValid) {
1288
+ dragging.cancel();
1289
+ }
1290
+ else {
1291
+ // disable dragging for elements that are resizable (ie, selectable)
1292
+ // but are not draggable
1293
+ // TODO: merge this with .cancel() ?
1294
+ this.isDragging = ev.subjectEl.classList.contains('fc-event-draggable');
1295
+ }
1272
1296
  };
1273
1297
  this.handleDragStart = (ev) => {
1274
1298
  let initialContext = this.component.context;
@@ -1581,9 +1605,11 @@ FullCalendar.Interaction = (function (exports, core, internal) {
1581
1605
  let segEl = this.querySegEl(ev);
1582
1606
  let eventRange = this.eventRange = internal.getElEventRange(segEl);
1583
1607
  this.dragging.minDistance = component.context.options.eventDragMinDistance;
1584
- // if touch, need to be working with a selected event
1585
- this.dragging.setIgnoreMove(!this.component.isValidSegDownEl(ev.origEvent.target) ||
1586
- (ev.isTouch && this.component.props.eventSelection !== eventRange.instance.instanceId));
1608
+ const isValid = this.component.isValidSegDownEl(ev.origEvent.target) &&
1609
+ !(ev.isTouch && this.component.props.eventSelection !== eventRange.instance.instanceId);
1610
+ if (!isValid) {
1611
+ this.dragging.cancel();
1612
+ }
1587
1613
  };
1588
1614
  this.handleDragStart = (ev) => {
1589
1615
  let { context } = this.component;
@@ -2053,8 +2079,8 @@ FullCalendar.Interaction = (function (exports, core, internal) {
2053
2079
  destroy() {
2054
2080
  this.pointer.destroy();
2055
2081
  }
2056
- setIgnoreMove(bool) {
2057
- this.shouldIgnoreMove = bool;
2082
+ cancel() {
2083
+ this.shouldIgnoreMove = true;
2058
2084
  }
2059
2085
  setMirrorIsVisible(bool) {
2060
2086
  if (bool) {
@@ -1,6 +1,6 @@
1
1
  /*!
2
- FullCalendar Interaction Plugin v7.0.0-beta.3
2
+ FullCalendar Interaction Plugin v7.0.0-rc.0
3
3
  Docs & License: https://fullcalendar.io/docs/editable
4
4
  (c) 2024 Adam Shaw
5
5
  */
6
- FullCalendar.Interaction=function(t,e,i){"use strict";i.config.touchMouseIgnoreWait=500;let n=0,r=0,s=!1;class o{constructor(t){this.subjectEl=null,this.selector="",this.handleSelector="",this.shouldIgnoreMove=!1,this.shouldWatchScroll=!0,this.isDragging=!1,this.isTouchDragging=!1,this.wasTouchScroll=!1,this.handleMouseDown=t=>{if(!this.shouldIgnoreMouse()&&function(t){return 0===t.button&&!t.ctrlKey}(t)&&this.tryStart(t)){let e=this.createEventFromMouse(t,!0);this.emitter.trigger("pointerdown",e),this.initScrollWatch(e),this.shouldIgnoreMove||document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}},this.handleMouseMove=t=>{let e=this.createEventFromMouse(t);this.recordCoords(e),this.emitter.trigger("pointermove",e)},this.handleMouseUp=t=>{document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),this.emitter.trigger("pointerup",this.createEventFromMouse(t)),this.cleanup()},this.handleTouchStart=t=>{if(this.tryStart(t)){this.isTouchDragging=!0;let e=this.createEventFromTouch(t,!0);this.emitter.trigger("pointerdown",e),this.initScrollWatch(e);let i=t.target;this.shouldIgnoreMove||i.addEventListener("touchmove",this.handleTouchMove),i.addEventListener("touchend",this.handleTouchEnd),i.addEventListener("touchcancel",this.handleTouchEnd),window.addEventListener("scroll",this.handleTouchScroll,!0)}},this.handleTouchMove=t=>{let e=this.createEventFromTouch(t);this.recordCoords(e),this.emitter.trigger("pointermove",e)},this.handleTouchEnd=t=>{if(this.isDragging){let e=t.target;e.removeEventListener("touchmove",this.handleTouchMove),e.removeEventListener("touchend",this.handleTouchEnd),e.removeEventListener("touchcancel",this.handleTouchEnd),window.removeEventListener("scroll",this.handleTouchScroll,!0),this.emitter.trigger("pointerup",this.createEventFromTouch(t)),this.cleanup(),this.isTouchDragging=!1,n+=1,setTimeout(()=>{n-=1},i.config.touchMouseIgnoreWait)}},this.handleTouchScroll=()=>{this.wasTouchScroll=!0},this.handleScroll=t=>{if(!this.shouldIgnoreMove){let e=window.scrollX-this.prevScrollX+this.prevPageX,i=window.scrollY-this.prevScrollY+this.prevPageY;this.emitter.trigger("pointermove",{origEvent:t,isTouch:this.isTouchDragging,subjectEl:this.subjectEl,pageX:e,pageY:i,deltaX:e-this.origPageX,deltaY:i-this.origPageY})}},this.containerEl=t,this.emitter=new i.Emitter,t.addEventListener("mousedown",this.handleMouseDown),t.addEventListener("touchstart",this.handleTouchStart,{passive:!0}),r+=1,1===r&&window.addEventListener("touchmove",l,{passive:!1})}destroy(){this.containerEl.removeEventListener("mousedown",this.handleMouseDown),this.containerEl.removeEventListener("touchstart",this.handleTouchStart,{passive:!0}),r-=1,r||window.removeEventListener("touchmove",l,{passive:!1})}tryStart(t){let e=this.querySubjectEl(t),i=t.target;return!(!e||this.handleSelector&&!i.closest(this.handleSelector))&&(this.subjectEl=e,this.isDragging=!0,this.wasTouchScroll=!1,!0)}cleanup(){s=!1,this.isDragging=!1,this.subjectEl=null,this.destroyScrollWatch()}querySubjectEl(t){return this.selector?t.target.closest(this.selector):this.containerEl}shouldIgnoreMouse(){return n||this.isTouchDragging}cancelTouchScroll(){this.isDragging&&(s=!0)}initScrollWatch(t){this.shouldWatchScroll&&(this.recordCoords(t),window.addEventListener("scroll",this.handleScroll,!0))}recordCoords(t){this.shouldWatchScroll&&(this.prevPageX=t.pageX,this.prevPageY=t.pageY,this.prevScrollX=window.scrollX,this.prevScrollY=window.scrollY)}destroyScrollWatch(){this.shouldWatchScroll&&window.removeEventListener("scroll",this.handleScroll,!0)}createEventFromMouse(t,e){let i=0,n=0;return e?(this.origPageX=t.pageX,this.origPageY=t.pageY):(i=t.pageX-this.origPageX,n=t.pageY-this.origPageY),{origEvent:t,isTouch:!1,subjectEl:this.subjectEl,pageX:t.pageX,pageY:t.pageY,deltaX:i,deltaY:n}}createEventFromTouch(t,e){let i,n,r=t.touches,s=0,o=0;return r&&r.length?(i=r[0].pageX,n=r[0].pageY):(i=t.pageX,n=t.pageY),e?(this.origPageX=i,this.origPageY=n):(s=i-this.origPageX,o=n-this.origPageY),{origEvent:t,isTouch:!0,subjectEl:this.subjectEl,pageX:i,pageY:n,deltaX:s,deltaY:o}}}function l(t){s&&t.preventDefault()}class a{constructor(){this.isVisible=!1,this.sourceEl=null,this.mirrorEl=null,this.sourceElRect=null,this.parentNode=document.body,this.zIndex=9999,this.revertDuration=0}start(t,e,i){this.sourceEl=t,this.sourceElRect=this.sourceEl.getBoundingClientRect(),this.origScreenX=e-window.scrollX,this.origScreenY=i-window.scrollY,this.deltaX=0,this.deltaY=0,this.updateElPosition()}handleMove(t,e){this.deltaX=t-window.scrollX-this.origScreenX,this.deltaY=e-window.scrollY-this.origScreenY,this.updateElPosition()}setIsVisible(t){t?this.isVisible||(this.mirrorEl&&(this.mirrorEl.style.display=""),this.isVisible=t,this.updateElPosition()):this.isVisible&&(this.mirrorEl&&(this.mirrorEl.style.display="none"),this.isVisible=t)}stop(t,e){let i=()=>{this.cleanup(),e()};t&&this.mirrorEl&&this.isVisible&&this.revertDuration&&(this.deltaX||this.deltaY)?this.doRevertAnimation(i,this.revertDuration):setTimeout(i,0)}doRevertAnimation(t,e){let n=this.mirrorEl,r=this.sourceEl.getBoundingClientRect();n.style.transition="top "+e+"ms,left "+e+"ms",i.applyStyle(n,{left:r.left,top:r.top}),i.whenTransitionDone(n,()=>{n.style.transition="",t()})}cleanup(){this.mirrorEl&&(this.mirrorEl.remove(),this.mirrorEl=null),this.sourceEl=null}updateElPosition(){this.sourceEl&&this.isVisible&&i.applyStyle(this.getMirrorEl(),{left:this.sourceElRect.left+this.deltaX,top:this.sourceElRect.top+this.deltaY})}getMirrorEl(){let t=this.sourceElRect,e=this.mirrorEl;return e||(e=this.mirrorEl=this.sourceEl.cloneNode(!0),e.style.userSelect="none",e.style.webkitUserSelect="none",e.style.pointerEvents="none",e.classList.add("fc-event-dragging"),i.applyStyle(e,{position:"fixed",zIndex:this.zIndex,visibility:"",boxSizing:"border-box",width:t.right-t.left,height:t.bottom-t.top,right:"auto",bottom:"auto",margin:0}),this.parentNode.appendChild(e)),e}}class h extends i.ScrollController{constructor(t,e){super(),this.handleScroll=()=>{this.scrollTop=this.scrollController.getScrollTop(),this.scrollLeft=this.scrollController.getScrollLeft(),this.handleScrollChange()},this.scrollController=t,this.doesListening=e,this.scrollTop=this.origScrollTop=t.getScrollTop(),this.scrollLeft=this.origScrollLeft=t.getScrollLeft(),this.scrollWidth=t.getScrollWidth(),this.scrollHeight=t.getScrollHeight(),this.clientWidth=t.getClientWidth(),this.clientHeight=t.getClientHeight(),this.clientRect=this.computeClientRect(),this.doesListening&&this.getEventTarget().addEventListener("scroll",this.handleScroll)}destroy(){this.doesListening&&this.getEventTarget().removeEventListener("scroll",this.handleScroll)}getScrollTop(){return this.scrollTop}getScrollLeft(){return this.scrollLeft}setScrollTop(t){this.scrollController.setScrollTop(t),this.doesListening||(this.scrollTop=Math.max(Math.min(t,this.getMaxScrollTop()),0),this.handleScrollChange())}setScrollLeft(t){this.scrollController.setScrollLeft(t),this.doesListening||(this.scrollLeft=Math.max(Math.min(t,this.getMaxScrollLeft()),0),this.handleScrollChange())}getClientWidth(){return this.clientWidth}getClientHeight(){return this.clientHeight}getScrollWidth(){return this.scrollWidth}getScrollHeight(){return this.scrollHeight}handleScrollChange(){}}class c extends h{constructor(t,e){super(new i.ElementScrollController(t),e)}getEventTarget(){return this.scrollController.el}computeClientRect(){return i.computeInnerRect(this.scrollController.el)}}class d extends h{constructor(t){super(new i.WindowScrollController,t)}getEventTarget(){return window}computeClientRect(){return{left:this.scrollLeft,right:this.scrollLeft+this.clientWidth,top:this.scrollTop,bottom:this.scrollTop+this.clientHeight}}handleScrollChange(){this.clientRect=this.computeClientRect()}}const g="function"==typeof performance?performance.now:Date.now;class u{constructor(){this.isEnabled=!0,this.scrollQuery=[window,".fc-scroller"],this.edgeThreshold=50,this.maxVelocity=300,this.pointerScreenX=null,this.pointerScreenY=null,this.isAnimating=!1,this.scrollCaches=null,this.everMovedUp=!1,this.everMovedDown=!1,this.everMovedLeft=!1,this.everMovedRight=!1,this.animate=()=>{if(this.isAnimating){let t=this.computeBestEdge(this.pointerScreenX+window.scrollX,this.pointerScreenY+window.scrollY);if(t){let e=g();this.handleSide(t,(e-this.msSinceRequest)/1e3),this.requestAnimation(e)}else this.isAnimating=!1}}}start(t,e,i){this.isEnabled&&(this.scrollCaches=this.buildCaches(i),this.pointerScreenX=null,this.pointerScreenY=null,this.everMovedUp=!1,this.everMovedDown=!1,this.everMovedLeft=!1,this.everMovedRight=!1,this.handleMove(t,e))}handleMove(t,e){if(this.isEnabled){let i=t-window.scrollX,n=e-window.scrollY,r=null===this.pointerScreenY?0:n-this.pointerScreenY,s=null===this.pointerScreenX?0:i-this.pointerScreenX;r<0?this.everMovedUp=!0:r>0&&(this.everMovedDown=!0),s<0?this.everMovedLeft=!0:s>0&&(this.everMovedRight=!0),this.pointerScreenX=i,this.pointerScreenY=n,this.isAnimating||(this.isAnimating=!0,this.requestAnimation(g()))}}stop(){if(this.isEnabled){this.isAnimating=!1;for(let t of this.scrollCaches)t.destroy();this.scrollCaches=null}}requestAnimation(t){this.msSinceRequest=t,requestAnimationFrame(this.animate)}handleSide(t,e){let{scrollCache:i}=t,{edgeThreshold:n}=this,r=n-t.distance,s=r*r/(n*n)*this.maxVelocity*e,o=1;switch(t.name){case"left":o=-1;case"right":i.setScrollLeft(i.getScrollLeft()+s*o);break;case"top":o=-1;case"bottom":i.setScrollTop(i.getScrollTop()+s*o)}}computeBestEdge(t,e){let{edgeThreshold:i}=this,n=null,r=this.scrollCaches||[];for(let s of r){let r=s.clientRect,o=t-r.left,l=r.right-t,a=e-r.top,h=r.bottom-e;o>=0&&l>=0&&a>=0&&h>=0&&(a<=i&&this.everMovedUp&&s.canScrollUp()&&(!n||n.distance>a)&&(n={scrollCache:s,name:"top",distance:a}),h<=i&&this.everMovedDown&&s.canScrollDown()&&(!n||n.distance>h)&&(n={scrollCache:s,name:"bottom",distance:h}),o<=i&&this.everMovedLeft&&s.canScrollLeft()&&(!n||n.distance>o)&&(n={scrollCache:s,name:"left",distance:o}),l<=i&&this.everMovedRight&&s.canScrollRight()&&(!n||n.distance>l)&&(n={scrollCache:s,name:"right",distance:l}))}return n}buildCaches(t){return this.queryScrollEls(t).map(t=>t===window?new d(!1):new c(t,!1))}queryScrollEls(t){let e=[];for(let i of this.scrollQuery)"object"==typeof i?e.push(i):e.push(...Array.prototype.slice.call(t.getRootNode().querySelectorAll(i)));return e}}class p extends i.ElementDragging{constructor(t,e){super(t),this.containerEl=t,this.delay=null,this.minDistance=0,this.touchScrollAllowed=!0,this.mirrorNeedsRevert=!1,this.isInteracting=!1,this.isDragging=!1,this.isDelayEnded=!1,this.isDistanceSurpassed=!1,this.delayTimeoutId=null,this.onPointerDown=t=>{this.isDragging||(this.isInteracting=!0,this.isDelayEnded=!1,this.isDistanceSurpassed=!1,i.preventSelection(document.body),i.preventContextMenu(document.body),t.isTouch||t.origEvent.preventDefault(),this.emitter.trigger("pointerdown",t),this.isInteracting&&!this.pointer.shouldIgnoreMove&&(this.mirror.setIsVisible(!1),this.mirror.start(t.subjectEl,t.pageX,t.pageY),this.startDelay(t),this.minDistance||this.handleDistanceSurpassed(t)))},this.onPointerMove=t=>{if(this.isInteracting){if(this.emitter.trigger("pointermove",t),!this.isDistanceSurpassed){let e,i=this.minDistance,{deltaX:n,deltaY:r}=t;e=n*n+r*r,e>=i*i&&this.handleDistanceSurpassed(t)}this.isDragging&&("scroll"!==t.origEvent.type&&(this.mirror.handleMove(t.pageX,t.pageY),this.autoScroller.handleMove(t.pageX,t.pageY)),this.emitter.trigger("dragmove",t))}},this.onPointerUp=t=>{this.isInteracting&&(this.isInteracting=!1,i.allowSelection(document.body),i.allowContextMenu(document.body),this.emitter.trigger("pointerup",t),this.isDragging&&(this.autoScroller.stop(),this.tryStopDrag(t)),this.delayTimeoutId&&(clearTimeout(this.delayTimeoutId),this.delayTimeoutId=null))};let n=this.pointer=new o(t);n.emitter.on("pointerdown",this.onPointerDown),n.emitter.on("pointermove",this.onPointerMove),n.emitter.on("pointerup",this.onPointerUp),e&&(n.selector=e),this.mirror=new a,this.autoScroller=new u}destroy(){this.pointer.destroy(),this.onPointerUp({})}startDelay(t){"number"==typeof this.delay?this.delayTimeoutId=setTimeout(()=>{this.delayTimeoutId=null,this.handleDelayEnd(t)},this.delay):this.handleDelayEnd(t)}handleDelayEnd(t){this.isDelayEnded=!0,this.tryStartDrag(t)}handleDistanceSurpassed(t){this.isDistanceSurpassed=!0,this.tryStartDrag(t)}tryStartDrag(t){this.isDelayEnded&&this.isDistanceSurpassed&&(this.pointer.wasTouchScroll&&!this.touchScrollAllowed||(this.isDragging=!0,this.mirrorNeedsRevert=!1,this.autoScroller.start(t.pageX,t.pageY,this.containerEl),this.emitter.trigger("dragstart",t),!1===this.touchScrollAllowed&&this.pointer.cancelTouchScroll()))}tryStopDrag(t){this.mirror.stop(this.mirrorNeedsRevert,this.stopDrag.bind(this,t))}stopDrag(t){this.isDragging=!1,this.emitter.trigger("dragend",t)}setIgnoreMove(t){this.pointer.shouldIgnoreMove=t}setMirrorIsVisible(t){this.mirror.setIsVisible(t)}setMirrorNeedsRevert(t){this.mirrorNeedsRevert=t}setAutoScrollEnabled(t){this.autoScroller.isEnabled=t}}class v{constructor(t){this.el=t,this.origRect=i.computeRect(t),this.scrollCaches=i.getClippingParents(t).map(t=>new c(t,!0))}destroy(){for(let t of this.scrollCaches)t.destroy()}computeLeft(){let t=this.origRect.left;for(let e of this.scrollCaches)t+=e.origScrollLeft-e.getScrollLeft();return t}computeTop(){let t=this.origRect.top;for(let e of this.scrollCaches)t+=e.origScrollTop-e.getScrollTop();return t}isWithinClipping(t,e){let n={left:t,top:e};for(let t of this.scrollCaches)if(!E(t.getEventTarget())&&!i.pointInsideRect(n,t.clientRect))return!1;return!0}}function E(t){let e=t.tagName;return"HTML"===e||"BODY"===e}class m{constructor(t,e){this.useSubjectCenter=!1,this.requireInitial=!0,this.disablePointCheck=!1,this.initialHit=null,this.movingHit=null,this.finalHit=null,this.handlePointerDown=t=>{let{dragging:e}=this;this.initialHit=null,this.movingHit=null,this.finalHit=null,this.prepareHits(),this.processFirstCoord(t),this.initialHit||!this.requireInitial?(e.setIgnoreMove(!1),this.emitter.trigger("pointerdown",t)):e.setIgnoreMove(!0)},this.handleDragStart=t=>{this.emitter.trigger("dragstart",t),this.handleMove(t,!0)},this.handleDragMove=t=>{this.emitter.trigger("dragmove",t),this.handleMove(t)},this.handlePointerUp=t=>{this.releaseHits(),this.emitter.trigger("pointerup",t)},this.handleDragEnd=t=>{this.movingHit&&this.emitter.trigger("hitupdate",null,!0,t),this.finalHit=this.movingHit,this.movingHit=null,this.emitter.trigger("dragend",t)},this.droppableStore=e,t.emitter.on("pointerdown",this.handlePointerDown),t.emitter.on("dragstart",this.handleDragStart),t.emitter.on("dragmove",this.handleDragMove),t.emitter.on("pointerup",this.handlePointerUp),t.emitter.on("dragend",this.handleDragEnd),this.dragging=t,this.emitter=new i.Emitter}processFirstCoord(t){let e,n={left:t.pageX,top:t.pageY},r=n,s=t.subjectEl;s instanceof HTMLElement&&(e=i.computeRect(s),r=i.constrainPoint(r,e));let o=this.initialHit=this.queryHitForOffset(r.left,r.top);if(o){if(this.useSubjectCenter&&e){let t=i.intersectRects(e,o.rect);t&&(r=i.getRectCenter(t))}this.coordAdjust=i.diffPoints(r,n)}else this.coordAdjust={left:0,top:0}}handleMove(t,e){let i=this.queryHitForOffset(t.pageX+this.coordAdjust.left,t.pageY+this.coordAdjust.top);!e&&S(this.movingHit,i)||(this.movingHit=i,this.emitter.trigger("hitupdate",i,!1,t))}prepareHits(){this.offsetTrackers=i.mapHash(this.droppableStore,t=>(t.component.prepareHits(),new v(t.el)))}releaseHits(){let{offsetTrackers:t}=this;for(let e in t)t[e].destroy();this.offsetTrackers={}}queryHitForOffset(t,e){let{droppableStore:n,offsetTrackers:r}=this,s=null;for(let o in n){let l=n[o].component,a=r[o];if(a&&a.isWithinClipping(t,e)){let n=a.computeLeft(),r=a.computeTop(),h=t-n,c=e-r,{origRect:d}=a,g=d.right-d.left,u=d.bottom-d.top;if(h>=0&&h<g&&c>=0&&c<u){let t=l.queryHit(h,c,g,u);t&&i.rangeContainsRange(t.dateProfile.activeRange,t.dateSpan.range)&&(this.disablePointCheck||a.el.contains(a.el.getRootNode().elementFromPoint(h+n-window.scrollX,c+r-window.scrollY)))&&(!s||t.layer>s.layer)&&(t.componentId=o,t.context=l.context,t.rect.left+=n,t.rect.right+=n,t.rect.top+=r,t.rect.bottom+=r,s=t)}}}return s}}function S(t,e){return!t&&!e||Boolean(t)===Boolean(e)&&i.isDateSpansEqual(t.dateSpan,e.dateSpan)}function D(t,e){let i={};for(let n of e.pluginHooks.datePointTransforms)Object.assign(i,n(t,e));var n,r;return Object.assign(i,(n=t,{date:(r=e.dateEnv).toDate(n.range.start),dateStr:r.formatIso(n.range.start,{omitTime:n.allDay}),allDay:n.allDay})),i}class f extends i.Interaction{constructor(t){super(t),this.handlePointerDown=t=>{let{dragging:e}=this,i=t.origEvent.target;e.setIgnoreMove(!this.component.isValidDateDownEl(i))},this.handleDragEnd=t=>{let{component:e}=this,{pointer:i}=this.dragging;if(!i.wasTouchScroll){let{initialHit:i,finalHit:n}=this.hitDragging;if(i&&n&&S(i,n)){let{context:n}=e,r=Object.assign(Object.assign({},D(i.dateSpan,n)),{dayEl:i.dayEl,jsEvent:t.origEvent,view:n.viewApi||n.calendarApi.view});n.emitter.trigger("dateClick",r)}}},this.dragging=new p(t.el),this.dragging.autoScroller.isEnabled=!1;let e=this.hitDragging=new m(this.dragging,i.interactionSettingsToStore(t));e.emitter.on("pointerdown",this.handlePointerDown),e.emitter.on("dragend",this.handleDragEnd)}destroy(){this.dragging.destroy()}}class y extends i.Interaction{constructor(t){super(t),this.dragSelection=null,this.handlePointerDown=t=>{let{component:e,dragging:i}=this,{options:n}=e.context,r=n.selectable&&e.isValidDateDownEl(t.origEvent.target);i.setIgnoreMove(!r),i.delay=t.isTouch?function(t){let{options:e}=t.context,i=e.selectLongPressDelay;null==i&&(i=e.longPressDelay);return i}(e):null},this.handleDragStart=t=>{this.component.context.calendarApi.unselect(t)},this.handleHitUpdate=(t,e)=>{let{context:n}=this.component,r=null,s=!1;if(t){let e=this.hitDragging.initialHit;t.componentId===e.componentId&&this.isHitComboAllowed&&!this.isHitComboAllowed(e,t)||(r=function(t,e,n){let r=t.dateSpan,s=e.dateSpan,o=[r.range.start,r.range.end,s.range.start,s.range.end];o.sort(i.compareNumbers);let l={};for(let i of n){let n=i(t,e);if(!1===n)return null;n&&Object.assign(l,n)}return l.range={start:o[0],end:o[3]},l.allDay=r.allDay,l}(e,t,n.pluginHooks.dateSelectionTransformers)),r&&i.isDateSelectionValid(r,t.dateProfile,n)||(s=!0,r=null)}r?n.dispatch({type:"SELECT_DATES",selection:r}):e||n.dispatch({type:"UNSELECT_DATES"}),s?i.disableCursor():i.enableCursor(),e||(this.dragSelection=r)},this.handlePointerUp=t=>{this.dragSelection&&(i.triggerDateSelect(this.dragSelection,t,this.component.context),this.dragSelection=null)};let{component:e}=t,{options:n}=e.context,r=this.dragging=new p(t.el);r.touchScrollAllowed=!1,r.minDistance=n.selectMinDistance||0,r.autoScroller.isEnabled=n.dragScroll;let s=this.hitDragging=new m(this.dragging,i.interactionSettingsToStore(t));s.emitter.on("pointerdown",this.handlePointerDown),s.emitter.on("dragstart",this.handleDragStart),s.emitter.on("hitupdate",this.handleHitUpdate),s.emitter.on("pointerup",this.handlePointerUp)}destroy(){this.dragging.destroy()}}class w extends i.Interaction{constructor(t){super(t),this.subjectEl=null,this.isDragging=!1,this.eventRange=null,this.relevantEvents=null,this.receivingContext=null,this.validMutation=null,this.mutatedRelevantEvents=null,this.handlePointerDown=t=>{let e=t.origEvent.target,{component:n,dragging:r}=this,{mirror:s}=r,{options:o}=n.context,l=n.context;this.subjectEl=t.subjectEl;let a=(this.eventRange=i.getElEventRange(t.subjectEl)).instance.instanceId;this.relevantEvents=i.getRelevantEvents(l.getCurrentData().eventStore,a),r.minDistance=t.isTouch?0:o.eventDragMinDistance,r.delay=t.isTouch&&a!==n.props.eventSelection?function(t){let{options:e}=t.context,i=e.eventLongPressDelay;null==i&&(i=e.longPressDelay);return i}(n):null,o.fixedMirrorParent?s.parentNode=o.fixedMirrorParent:s.parentNode=e.closest(".fc"),s.revertDuration=o.dragRevertDuration;let h=n.isValidSegDownEl(e)&&!e.closest(".fc-event-resizer");r.setIgnoreMove(!h),this.isDragging=h&&t.subjectEl.classList.contains("fc-event-draggable")},this.handleDragStart=t=>{let e=this.component.context,n=this.eventRange,r=n.instance.instanceId;t.isTouch?r!==this.component.props.eventSelection&&e.dispatch({type:"SELECT_EVENT",eventInstanceId:r}):e.dispatch({type:"UNSELECT_EVENT"}),this.isDragging&&(e.calendarApi.unselect(t),e.emitter.trigger("eventDragStart",{el:this.subjectEl,event:new i.EventImpl(e,n.def,n.instance),jsEvent:t.origEvent,view:e.viewApi}))},this.handleHitUpdate=(t,e)=>{if(!this.isDragging)return;let n=this.relevantEvents,r=this.hitDragging.initialHit,s=this.component.context,o=null,l=null,a=null,h=!1,c={affectedEvents:n,mutatedEvents:i.createEmptyEventStore(),isEvent:!0};if(t){o=t.context;let e=o.options;s===o||e.editable&&e.droppable?(l=function(t,e,n,r){let s=t.dateSpan,o=e.dateSpan,l=s.range.start,a=o.range.start,h={};s.allDay!==o.allDay&&(h.allDay=o.allDay,h.hasEnd=e.context.options.allDayMaintainDuration,l=o.allDay?i.startOfDay(n):n);let c=i.diffDates(l,a,t.context.dateEnv,t.componentId===e.componentId?t.largeUnit:null);c.milliseconds&&(h.allDay=!1);let d={datesDelta:c,standardProps:h};for(let i of r)i(d,t,e);return d}(r,t,this.eventRange.instance.range.start,o.getCurrentData().pluginHooks.eventDragMutationMassagers),l&&(a=i.applyMutationToEventStore(n,o.getCurrentData().eventUiBases,l,o),c.mutatedEvents=a,i.isInteractionValid(c,t.dateProfile,o)||(h=!0,l=null,a=null,c.mutatedEvents=i.createEmptyEventStore()))):o=null}this.displayDrag(o,c),h?i.disableCursor():i.enableCursor(),e||(s===o&&S(r,t)&&(l=null),this.dragging.setMirrorNeedsRevert(!l),this.dragging.setMirrorIsVisible(!t||!this.subjectEl.getRootNode().querySelector(".fc-event-mirror")),this.receivingContext=o,this.validMutation=l,this.mutatedRelevantEvents=a)},this.handlePointerUp=()=>{this.isDragging||this.cleanup()},this.handleDragEnd=t=>{if(this.isDragging){let e=this.component.context,n=e.viewApi,{receivingContext:r,validMutation:s}=this,o=this.eventRange.def,l=this.eventRange.instance,a=new i.EventImpl(e,o,l),h=this.relevantEvents,c=this.mutatedRelevantEvents,{finalHit:d}=this.hitDragging;if(this.clearDrag(),e.emitter.trigger("eventDragStop",{el:this.subjectEl,event:a,jsEvent:t.origEvent,view:n}),s){if(r===e){let r=new i.EventImpl(e,c.defs[o.defId],l?c.instances[l.instanceId]:null);e.dispatch({type:"MERGE_EVENTS",eventStore:c});let d={oldEvent:a,event:r,relatedEvents:i.buildEventApis(c,e,l),revert(){e.dispatch({type:"MERGE_EVENTS",eventStore:h})}},g={};for(let t of e.getCurrentData().pluginHooks.eventDropTransformers)Object.assign(g,t(s,e));e.emitter.trigger("eventDrop",Object.assign(Object.assign(Object.assign({},d),g),{el:t.subjectEl,delta:s.datesDelta,jsEvent:t.origEvent,view:n})),e.emitter.trigger("eventChange",d)}else if(r){let s={event:a,relatedEvents:i.buildEventApis(h,e,l),revert(){e.dispatch({type:"MERGE_EVENTS",eventStore:h})}};e.emitter.trigger("eventLeave",Object.assign(Object.assign({},s),{draggedEl:t.subjectEl,view:n})),e.dispatch({type:"REMOVE_EVENTS",eventStore:h}),e.emitter.trigger("eventRemove",s);let g=c.defs[o.defId],u=c.instances[l.instanceId],p=new i.EventImpl(r,g,u);r.dispatch({type:"MERGE_EVENTS",eventStore:c});let v={event:p,relatedEvents:i.buildEventApis(c,r,u),revert(){r.dispatch({type:"REMOVE_EVENTS",eventStore:c})}};r.emitter.trigger("eventAdd",v),t.isTouch&&r.dispatch({type:"SELECT_EVENT",eventInstanceId:l.instanceId}),r.emitter.trigger("drop",Object.assign(Object.assign({},D(d.dateSpan,r)),{draggedEl:t.subjectEl,jsEvent:t.origEvent,view:d.context.viewApi})),r.emitter.trigger("eventReceive",Object.assign(Object.assign({},v),{draggedEl:t.subjectEl,view:d.context.viewApi}))}}else e.emitter.trigger("_noEventDrop")}this.cleanup()};let{component:e}=this,{options:n}=e.context,r=this.dragging=new p(t.el);r.pointer.selector=w.SELECTOR,r.touchScrollAllowed=!1,r.autoScroller.isEnabled=n.dragScroll;let s=this.hitDragging=new m(this.dragging,i.interactionSettingsStore);s.useSubjectCenter=t.useEventCenter,s.emitter.on("pointerdown",this.handlePointerDown),s.emitter.on("dragstart",this.handleDragStart),s.emitter.on("hitupdate",this.handleHitUpdate),s.emitter.on("pointerup",this.handlePointerUp),s.emitter.on("dragend",this.handleDragEnd)}destroy(){this.dragging.destroy()}displayDrag(t,e){let n=this.component.context,r=this.receivingContext;r&&r!==t&&(r===n?r.dispatch({type:"SET_EVENT_DRAG",state:{affectedEvents:e.affectedEvents,mutatedEvents:i.createEmptyEventStore(),isEvent:!0}}):r.dispatch({type:"UNSET_EVENT_DRAG"})),t&&t.dispatch({type:"SET_EVENT_DRAG",state:e})}clearDrag(){let t=this.component.context,{receivingContext:e}=this;e&&e.dispatch({type:"UNSET_EVENT_DRAG"}),t!==e&&t.dispatch({type:"UNSET_EVENT_DRAG"})}cleanup(){this.isDragging=!1,this.eventRange=null,this.relevantEvents=null,this.receivingContext=null,this.validMutation=null,this.mutatedRelevantEvents=null}}w.SELECTOR=".fc-event-draggable, .fc-event-resizable";class T extends i.Interaction{constructor(t){super(t),this.draggingSegEl=null,this.draggingEventRange=null,this.eventRange=null,this.relevantEvents=null,this.validMutation=null,this.mutatedRelevantEvents=null,this.handlePointerDown=t=>{let{component:e}=this,n=this.querySegEl(t),r=this.eventRange=i.getElEventRange(n);this.dragging.minDistance=e.context.options.eventDragMinDistance,this.dragging.setIgnoreMove(!this.component.isValidSegDownEl(t.origEvent.target)||t.isTouch&&this.component.props.eventSelection!==r.instance.instanceId)},this.handleDragStart=t=>{let{context:e}=this.component,n=this.eventRange;this.relevantEvents=i.getRelevantEvents(e.getCurrentData().eventStore,this.eventRange.instance.instanceId);let r=this.querySegEl(t);this.draggingSegEl=r,this.draggingEventRange=i.getElEventRange(r),e.calendarApi.unselect(),e.emitter.trigger("eventResizeStart",{el:r,event:new i.EventImpl(e,n.def,n.instance),jsEvent:t.origEvent,view:e.viewApi})},this.handleHitUpdate=(t,e,n)=>{let{context:r}=this.component,s=this.relevantEvents,o=this.hitDragging.initialHit,l=this.eventRange.instance,a=null,h=null,c=!1,d={affectedEvents:s,mutatedEvents:i.createEmptyEventStore(),isEvent:!0};if(t){t.componentId===o.componentId&&this.isHitComboAllowed&&!this.isHitComboAllowed(o,t)||(a=function(t,e,n,r){let s=t.context.dateEnv,o=t.dateSpan.range.start,l=e.dateSpan.range.start,a=i.diffDates(o,l,s,t.largeUnit);if(n){if(s.add(r.start,a)<r.end)return{startDelta:a}}else if(s.add(r.end,a)>r.start)return{endDelta:a};return null}(o,t,n.subjectEl.classList.contains("fc-event-resizer-start"),l.range))}a&&(h=i.applyMutationToEventStore(s,r.getCurrentData().eventUiBases,a,r),d.mutatedEvents=h,i.isInteractionValid(d,t.dateProfile,r)||(c=!0,a=null,h=null,d.mutatedEvents=null)),h?r.dispatch({type:"SET_EVENT_RESIZE",state:d}):r.dispatch({type:"UNSET_EVENT_RESIZE"}),c?i.disableCursor():i.enableCursor(),e||(a&&S(o,t)&&(a=null),this.validMutation=a,this.mutatedRelevantEvents=h)},this.handleDragEnd=t=>{let{context:e}=this.component,n=this.eventRange.def,r=this.eventRange.instance,s=new i.EventImpl(e,n,r),o=this.relevantEvents,l=this.mutatedRelevantEvents;if(e.emitter.trigger("eventResizeStop",{el:this.draggingSegEl,event:s,jsEvent:t.origEvent,view:e.viewApi}),this.validMutation){let a=new i.EventImpl(e,l.defs[n.defId],r?l.instances[r.instanceId]:null);e.dispatch({type:"MERGE_EVENTS",eventStore:l});let h={oldEvent:s,event:a,relatedEvents:i.buildEventApis(l,e,r),revert(){e.dispatch({type:"MERGE_EVENTS",eventStore:o})}};e.emitter.trigger("eventResize",Object.assign(Object.assign({},h),{el:this.draggingSegEl,startDelta:this.validMutation.startDelta||i.createDuration(0),endDelta:this.validMutation.endDelta||i.createDuration(0),jsEvent:t.origEvent,view:e.viewApi})),e.emitter.trigger("eventChange",h)}else e.emitter.trigger("_noEventResize");this.draggingEventRange=null,this.relevantEvents=null,this.validMutation=null};let{component:e}=t,n=this.dragging=new p(t.el);n.pointer.selector=".fc-event-resizer",n.touchScrollAllowed=!1,n.autoScroller.isEnabled=e.context.options.dragScroll;let r=this.hitDragging=new m(this.dragging,i.interactionSettingsToStore(t));r.emitter.on("pointerdown",this.handlePointerDown),r.emitter.on("dragstart",this.handleDragStart),r.emitter.on("hitupdate",this.handleHitUpdate),r.emitter.on("dragend",this.handleDragEnd)}destroy(){this.dragging.destroy()}querySegEl(t){return t.subjectEl.closest(".fc-event")}}const b={fixedMirrorParent:i.identity},M={dateClick:i.identity,eventDragStart:i.identity,eventDragStop:i.identity,eventDrop:i.identity,eventResizeStart:i.identity,eventResizeStop:i.identity,eventResize:i.identity,drop:i.identity,eventReceive:i.identity,eventLeave:i.identity};class C{constructor(t,e){this.receivingContext=null,this.droppableEvent=null,this.suppliedDragMeta=null,this.dragMeta=null,this.handleDragStart=t=>{this.dragMeta=this.buildDragMeta(t.subjectEl)},this.handleHitUpdate=(t,e,n)=>{let{dragging:r}=this.hitDragging,s=null,o=null,l=!1,a={affectedEvents:i.createEmptyEventStore(),mutatedEvents:i.createEmptyEventStore(),isEvent:this.dragMeta.create};t&&(s=t.context,this.canDropElOnCalendar(n.subjectEl,s)&&(o=function(t,e,n){let r=Object.assign({},e.leftoverProps);for(let i of n.pluginHooks.externalDefTransforms)Object.assign(r,i(t,e));let{refined:s,extra:o}=i.refineEventDef(r,n),l=i.parseEventDef(s,o,e.sourceId,t.allDay,n.options.forceEventDuration||Boolean(e.duration),n),a=t.range.start;t.allDay&&e.startTime&&(a=n.dateEnv.add(a,e.startTime));let h=e.duration?n.dateEnv.add(a,e.duration):i.getDefaultEventEnd(t.allDay,a,n),c=i.createEventInstance(l.defId,{start:a,end:h});return{def:l,instance:c}}(t.dateSpan,this.dragMeta,s),a.mutatedEvents=i.eventTupleToStore(o),l=!i.isInteractionValid(a,t.dateProfile,s),l&&(a.mutatedEvents=i.createEmptyEventStore(),o=null))),this.displayDrag(s,a),r.setMirrorIsVisible(e||!o||!document.querySelector(".fc-event-mirror")),l?i.disableCursor():i.enableCursor(),e||(r.setMirrorNeedsRevert(!o),this.receivingContext=s,this.droppableEvent=o)},this.handleDragEnd=t=>{let{receivingContext:e,droppableEvent:n}=this;if(this.clearDrag(),e&&n){let r=this.hitDragging.finalHit,s=r.context.viewApi,o=this.dragMeta;if(e.emitter.trigger("drop",Object.assign(Object.assign({},D(r.dateSpan,e)),{draggedEl:t.subjectEl,jsEvent:t.origEvent,view:s})),o.create){let r=i.eventTupleToStore(n);e.dispatch({type:"MERGE_EVENTS",eventStore:r}),t.isTouch&&e.dispatch({type:"SELECT_EVENT",eventInstanceId:n.instance.instanceId}),e.emitter.trigger("eventReceive",{event:new i.EventImpl(e,n.def,n.instance),relatedEvents:[],revert(){e.dispatch({type:"REMOVE_EVENTS",eventStore:r})},draggedEl:t.subjectEl,view:s})}}this.receivingContext=null,this.droppableEvent=null};let n=this.hitDragging=new m(t,i.interactionSettingsStore);n.requireInitial=!1,n.emitter.on("dragstart",this.handleDragStart),n.emitter.on("hitupdate",this.handleHitUpdate),n.emitter.on("dragend",this.handleDragEnd),this.suppliedDragMeta=e}buildDragMeta(t){return"object"==typeof this.suppliedDragMeta?i.parseDragMeta(this.suppliedDragMeta):"function"==typeof this.suppliedDragMeta?i.parseDragMeta(this.suppliedDragMeta(t)):function(t){let e=function(t,e){let n=i.config.dataAttrPrefix,r=(n?n+"-":"")+e;return t.getAttribute("data-"+r)||""}(t,"event"),n=e?JSON.parse(e):{create:!1};return i.parseDragMeta(n)}(t)}displayDrag(t,e){let i=this.receivingContext;i&&i!==t&&i.dispatch({type:"UNSET_EVENT_DRAG"}),t&&t.dispatch({type:"SET_EVENT_DRAG",state:e})}clearDrag(){this.receivingContext&&this.receivingContext.dispatch({type:"UNSET_EVENT_DRAG"})}canDropElOnCalendar(t,e){let i=e.options.dropAccept;return"function"==typeof i?i.call(e.calendarApi,t):"string"!=typeof i||!i||t.matches(i)}}i.config.dataAttrPrefix="";class R extends i.ElementDragging{constructor(t){super(t),this.shouldIgnoreMove=!1,this.mirrorSelector="",this.currentMirrorEl=null,this.handlePointerDown=t=>{this.emitter.trigger("pointerdown",t),this.shouldIgnoreMove||this.emitter.trigger("dragstart",t)},this.handlePointerMove=t=>{this.shouldIgnoreMove||this.emitter.trigger("dragmove",t)},this.handlePointerUp=t=>{this.emitter.trigger("pointerup",t),this.shouldIgnoreMove||this.emitter.trigger("dragend",t)};let e=this.pointer=new o(t);e.emitter.on("pointerdown",this.handlePointerDown),e.emitter.on("pointermove",this.handlePointerMove),e.emitter.on("pointerup",this.handlePointerUp)}destroy(){this.pointer.destroy()}setIgnoreMove(t){this.shouldIgnoreMove=t}setMirrorIsVisible(t){if(t)this.currentMirrorEl&&(this.currentMirrorEl.style.visibility="",this.currentMirrorEl=null);else{let t=this.mirrorSelector?document.querySelector(this.mirrorSelector):null;t&&(this.currentMirrorEl=t,t.style.visibility="hidden")}}}var I=e.createPlugin({name:"@fullcalendar/interaction",componentInteractions:[f,y,w,T],calendarInteractions:[class{constructor(t){this.context=t,this.isRecentPointerDateSelect=!1,this.matchesCancel=!1,this.matchesEvent=!1,this.onSelect=t=>{t.jsEvent&&(this.isRecentPointerDateSelect=!0)},this.onDocumentPointerDown=t=>{let e=this.context.options.unselectCancel,n=i.getEventTargetViaRoot(t.origEvent);this.matchesCancel=!!n.closest(e),this.matchesEvent=!!n.closest(w.SELECTOR)},this.onDocumentPointerUp=t=>{let{context:e}=this,{documentPointer:i}=this,n=e.getCurrentData();if(!i.wasTouchScroll){if(n.dateSelection&&!this.isRecentPointerDateSelect){let i=e.options.unselectAuto;!i||i&&this.matchesCancel||e.calendarApi.unselect(t)}n.eventSelection&&!this.matchesEvent&&e.dispatch({type:"UNSELECT_EVENT"})}this.isRecentPointerDateSelect=!1};let e=this.documentPointer=new o(document);e.shouldIgnoreMove=!0,e.shouldWatchScroll=!1,e.emitter.on("pointerdown",this.onDocumentPointerDown),e.emitter.on("pointerup",this.onDocumentPointerUp),t.emitter.on("select",this.onSelect)}destroy(){this.context.emitter.off("select",this.onSelect),this.documentPointer.destroy()}}],elementDraggingImpl:p,optionRefiners:b,listenerRefiners:M});return e.globalPlugins.push(I),t.Draggable=class{constructor(t,e={}){this.handlePointerDown=t=>{let{dragging:e}=this,{minDistance:n,longPressDelay:r}=this.settings;e.minDistance=null!=n?n:t.isTouch?0:i.BASE_OPTION_DEFAULTS.eventDragMinDistance,e.delay=t.isTouch?null!=r?r:i.BASE_OPTION_DEFAULTS.longPressDelay:0},this.handleDragStart=t=>{t.isTouch&&this.dragging.delay&&t.subjectEl.classList.contains("fc-event")&&this.dragging.mirror.getMirrorEl().classList.add("fc-event-selected")},this.settings=e;let n=this.dragging=new p(t);n.touchScrollAllowed=!1,null!=e.itemSelector&&(n.pointer.selector=e.itemSelector),null!=e.appendTo&&(n.mirror.parentNode=e.appendTo),n.emitter.on("pointerdown",this.handlePointerDown),n.emitter.on("dragstart",this.handleDragStart),new C(n,e.eventData)}destroy(){this.dragging.destroy()}},t.ThirdPartyDraggable=class{constructor(t,e){let i=document;t===document||t instanceof Element?(i=t,e=e||{}):e=t||{};let n=this.dragging=new R(i);"string"==typeof e.itemSelector?n.pointer.selector=e.itemSelector:i===document&&(n.pointer.selector="[data-event]"),"string"==typeof e.mirrorSelector&&(n.mirrorSelector=e.mirrorSelector),new C(n,e.eventData).hitDragging.disablePointCheck=!0}destroy(){this.dragging.destroy()}},t.default=I,Object.defineProperty(t,"__esModule",{value:!0}),t}({},FullCalendar,FullCalendar.Internal);
6
+ FullCalendar.Interaction=function(t,e,i){"use strict";i.config.touchMouseIgnoreWait=500;let n=0,s=0,r=!1;class o{constructor(t){this.subjectEl=null,this.selector="",this.handleSelector="",this.shouldIgnoreMove=!1,this.shouldWatchScroll=!0,this.isDragging=!1,this.isTouchDragging=!1,this.wasTouchScroll=!1,this.handleMouseDown=t=>{if(!this.shouldIgnoreMouse()&&function(t){return 0===t.button&&!t.ctrlKey}(t)&&this.tryStart(t)){let e=this.createEventFromMouse(t,!0);this.emitter.trigger("pointerdown",e),this.initScrollWatch(e),this.shouldIgnoreMove||document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}},this.handleMouseMove=t=>{let e=this.createEventFromMouse(t);this.recordCoords(e),this.emitter.trigger("pointermove",e)},this.handleMouseUp=t=>{document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),this.emitter.trigger("pointerup",this.createEventFromMouse(t)),this.cleanup()},this.handleTouchStart=t=>{if(this.tryStart(t)){this.isTouchDragging=!0;let e=this.createEventFromTouch(t,!0);this.emitter.trigger("pointerdown",e),this.initScrollWatch(e);let i=t.target;this.shouldIgnoreMove||i.addEventListener("touchmove",this.handleTouchMove),i.addEventListener("touchend",this.handleTouchEnd),i.addEventListener("touchcancel",this.handleTouchEnd),window.addEventListener("scroll",this.handleTouchScroll,!0)}},this.handleTouchMove=t=>{if(this.isDragging){let e=this.createEventFromTouch(t);this.recordCoords(e),this.emitter.trigger("pointermove",e)}},this.handleTouchEnd=t=>{if(this.isDragging){let e=t.target;e.removeEventListener("touchmove",this.handleTouchMove),e.removeEventListener("touchend",this.handleTouchEnd),e.removeEventListener("touchcancel",this.handleTouchEnd),window.removeEventListener("scroll",this.handleTouchScroll,!0),this.emitter.trigger("pointerup",this.createEventFromTouch(t)),this.cleanup(),this.isTouchDragging=!1,n+=1,setTimeout(()=>{n-=1},i.config.touchMouseIgnoreWait)}},this.handleTouchScroll=()=>{this.wasTouchScroll=!0},this.handleScroll=t=>{if(!this.shouldIgnoreMove){let e=window.scrollX-this.prevScrollX+this.prevPageX,i=window.scrollY-this.prevScrollY+this.prevPageY;this.emitter.trigger("pointermove",{origEvent:t,isTouch:this.isTouchDragging,subjectEl:this.subjectEl,pageX:e,pageY:i,deltaX:e-this.origPageX,deltaY:i-this.origPageY})}},this.containerEl=t,this.emitter=new i.Emitter,t.addEventListener("mousedown",this.handleMouseDown),t.addEventListener("touchstart",this.handleTouchStart,{passive:!0}),s+=1,1===s&&window.addEventListener("touchmove",l,{passive:!1})}destroy(){this.containerEl.removeEventListener("mousedown",this.handleMouseDown),this.containerEl.removeEventListener("touchstart",this.handleTouchStart,{passive:!0}),s-=1,s||window.removeEventListener("touchmove",l,{passive:!1})}cancel(){this.isDragging&&this.cleanup()}tryStart(t){let e=this.querySubjectEl(t),i=t.target;return!(!e||this.handleSelector&&!i.closest(this.handleSelector))&&(this.subjectEl=e,this.isDragging=!0,this.wasTouchScroll=!1,!0)}cleanup(){r=!1,this.isDragging=!1,this.subjectEl=null,this.destroyScrollWatch()}querySubjectEl(t){return this.selector?t.target.closest(this.selector):this.containerEl}shouldIgnoreMouse(){return n||this.isTouchDragging}cancelTouchScroll(){this.isDragging&&(r=!0)}initScrollWatch(t){this.shouldWatchScroll&&(this.recordCoords(t),window.addEventListener("scroll",this.handleScroll,!0))}recordCoords(t){this.shouldWatchScroll&&(this.prevPageX=t.pageX,this.prevPageY=t.pageY,this.prevScrollX=window.scrollX,this.prevScrollY=window.scrollY)}destroyScrollWatch(){this.shouldWatchScroll&&window.removeEventListener("scroll",this.handleScroll,!0)}createEventFromMouse(t,e){let i=0,n=0;return e?(this.origPageX=t.pageX,this.origPageY=t.pageY):(i=t.pageX-this.origPageX,n=t.pageY-this.origPageY),{origEvent:t,isTouch:!1,subjectEl:this.subjectEl,pageX:t.pageX,pageY:t.pageY,deltaX:i,deltaY:n}}createEventFromTouch(t,e){let i,n,s=t.touches,r=0,o=0;return s&&s.length?(i=s[0].pageX,n=s[0].pageY):(i=t.pageX,n=t.pageY),e?(this.origPageX=i,this.origPageY=n):(r=i-this.origPageX,o=n-this.origPageY),{origEvent:t,isTouch:!0,subjectEl:this.subjectEl,pageX:i,pageY:n,deltaX:r,deltaY:o}}}function l(t){r&&t.preventDefault()}class a{constructor(){this.isVisible=!1,this.sourceEl=null,this.mirrorEl=null,this.sourceElRect=null,this.parentNode=document.body,this.zIndex=9999,this.revertDuration=0}start(t,e,i){this.sourceEl=t,this.sourceElRect=this.sourceEl.getBoundingClientRect(),this.origScreenX=e-window.scrollX,this.origScreenY=i-window.scrollY,this.deltaX=0,this.deltaY=0,this.updateElPosition()}handleMove(t,e){this.deltaX=t-window.scrollX-this.origScreenX,this.deltaY=e-window.scrollY-this.origScreenY,this.updateElPosition()}setIsVisible(t){t?this.isVisible||(this.mirrorEl&&(this.mirrorEl.style.display=""),this.isVisible=t,this.updateElPosition()):this.isVisible&&(this.mirrorEl&&(this.mirrorEl.style.display="none"),this.isVisible=t)}stop(t,e){let i=()=>{this.cleanup(),e()};t&&this.mirrorEl&&this.isVisible&&this.revertDuration&&(this.deltaX||this.deltaY)?this.doRevertAnimation(i,this.revertDuration):setTimeout(i,0)}doRevertAnimation(t,e){let n=this.mirrorEl,s=this.sourceEl.getBoundingClientRect();n.style.transition="top "+e+"ms,left "+e+"ms",i.applyStyle(n,{left:s.left,top:s.top}),i.whenTransitionDone(n,()=>{n.style.transition="",t()})}cleanup(){this.mirrorEl&&(this.mirrorEl.remove(),this.mirrorEl=null),this.sourceEl=null}updateElPosition(){this.sourceEl&&this.isVisible&&i.applyStyle(this.getMirrorEl(),{left:this.sourceElRect.left+this.deltaX,top:this.sourceElRect.top+this.deltaY})}getMirrorEl(){let t=this.sourceElRect,e=this.mirrorEl;return e||(e=this.mirrorEl=this.sourceEl.cloneNode(!0),e.style.userSelect="none",e.style.webkitUserSelect="none",e.style.pointerEvents="none",e.classList.add("fc-event-dragging"),i.applyStyle(e,{position:"fixed",zIndex:this.zIndex,visibility:"",boxSizing:"border-box",width:t.right-t.left,height:t.bottom-t.top,right:"auto",bottom:"auto",margin:0}),this.parentNode.appendChild(e)),e}}class h extends i.ScrollController{constructor(t,e){super(),this.handleScroll=()=>{this.scrollTop=this.scrollController.getScrollTop(),this.scrollLeft=this.scrollController.getScrollLeft(),this.handleScrollChange()},this.scrollController=t,this.doesListening=e,this.scrollTop=this.origScrollTop=t.getScrollTop(),this.scrollLeft=this.origScrollLeft=t.getScrollLeft(),this.scrollWidth=t.getScrollWidth(),this.scrollHeight=t.getScrollHeight(),this.clientWidth=t.getClientWidth(),this.clientHeight=t.getClientHeight(),this.clientRect=this.computeClientRect(),this.doesListening&&this.getEventTarget().addEventListener("scroll",this.handleScroll)}destroy(){this.doesListening&&this.getEventTarget().removeEventListener("scroll",this.handleScroll)}getScrollTop(){return this.scrollTop}getScrollLeft(){return this.scrollLeft}setScrollTop(t){this.scrollController.setScrollTop(t),this.doesListening||(this.scrollTop=Math.max(Math.min(t,this.getMaxScrollTop()),0),this.handleScrollChange())}setScrollLeft(t){this.scrollController.setScrollLeft(t),this.doesListening||(this.scrollLeft=Math.max(Math.min(t,this.getMaxScrollLeft()),0),this.handleScrollChange())}getClientWidth(){return this.clientWidth}getClientHeight(){return this.clientHeight}getScrollWidth(){return this.scrollWidth}getScrollHeight(){return this.scrollHeight}handleScrollChange(){}}class c extends h{constructor(t,e){super(new i.ElementScrollController(t),e)}getEventTarget(){return this.scrollController.el}computeClientRect(){return i.computeInnerRect(this.scrollController.el)}}class d extends h{constructor(t){super(new i.WindowScrollController,t)}getEventTarget(){return window}computeClientRect(){return{left:this.scrollLeft,right:this.scrollLeft+this.clientWidth,top:this.scrollTop,bottom:this.scrollTop+this.clientHeight}}handleScrollChange(){this.clientRect=this.computeClientRect()}}const g="function"==typeof performance?performance.now:Date.now;class u{constructor(){this.isEnabled=!0,this.scrollQuery=[window,".fc-scroller"],this.edgeThreshold=50,this.maxVelocity=300,this.pointerScreenX=null,this.pointerScreenY=null,this.isAnimating=!1,this.scrollCaches=null,this.everMovedUp=!1,this.everMovedDown=!1,this.everMovedLeft=!1,this.everMovedRight=!1,this.animate=()=>{if(this.isAnimating){let t=this.computeBestEdge(this.pointerScreenX+window.scrollX,this.pointerScreenY+window.scrollY);if(t){let e=g();this.handleSide(t,(e-this.msSinceRequest)/1e3),this.requestAnimation(e)}else this.isAnimating=!1}}}start(t,e,i){this.isEnabled&&(this.scrollCaches=this.buildCaches(i),this.pointerScreenX=null,this.pointerScreenY=null,this.everMovedUp=!1,this.everMovedDown=!1,this.everMovedLeft=!1,this.everMovedRight=!1,this.handleMove(t,e))}handleMove(t,e){if(this.isEnabled){let i=t-window.scrollX,n=e-window.scrollY,s=null===this.pointerScreenY?0:n-this.pointerScreenY,r=null===this.pointerScreenX?0:i-this.pointerScreenX;s<0?this.everMovedUp=!0:s>0&&(this.everMovedDown=!0),r<0?this.everMovedLeft=!0:r>0&&(this.everMovedRight=!0),this.pointerScreenX=i,this.pointerScreenY=n,this.isAnimating||(this.isAnimating=!0,this.requestAnimation(g()))}}stop(){if(this.isEnabled){this.isAnimating=!1;for(let t of this.scrollCaches)t.destroy();this.scrollCaches=null}}requestAnimation(t){this.msSinceRequest=t,requestAnimationFrame(this.animate)}handleSide(t,e){let{scrollCache:i}=t,{edgeThreshold:n}=this,s=n-t.distance,r=s*s/(n*n)*this.maxVelocity*e,o=1;switch(t.name){case"left":o=-1;case"right":i.setScrollLeft(i.getScrollLeft()+r*o);break;case"top":o=-1;case"bottom":i.setScrollTop(i.getScrollTop()+r*o)}}computeBestEdge(t,e){let{edgeThreshold:i}=this,n=null,s=this.scrollCaches||[];for(let r of s){let s=r.clientRect,o=t-s.left,l=s.right-t,a=e-s.top,h=s.bottom-e;o>=0&&l>=0&&a>=0&&h>=0&&(a<=i&&this.everMovedUp&&r.canScrollUp()&&(!n||n.distance>a)&&(n={scrollCache:r,name:"top",distance:a}),h<=i&&this.everMovedDown&&r.canScrollDown()&&(!n||n.distance>h)&&(n={scrollCache:r,name:"bottom",distance:h}),o<=i&&this.everMovedLeft&&r.canScrollLeft()&&(!n||n.distance>o)&&(n={scrollCache:r,name:"left",distance:o}),l<=i&&this.everMovedRight&&r.canScrollRight()&&(!n||n.distance>l)&&(n={scrollCache:r,name:"right",distance:l}))}return n}buildCaches(t){return this.queryScrollEls(t).map(t=>t===window?new d(!1):new c(t,!1))}queryScrollEls(t){let e=[];for(let i of this.scrollQuery)"object"==typeof i?e.push(i):e.push(...Array.prototype.slice.call(t.getRootNode().querySelectorAll(i)));return e}}class p extends i.ElementDragging{constructor(t,e){super(t),this.containerEl=t,this.delay=null,this.minDistance=0,this.touchScrollAllowed=!0,this.mirrorNeedsRevert=!1,this.isInteracting=!1,this.isDragging=!1,this.isDelayEnded=!1,this.isDistanceSurpassed=!1,this.delayTimeoutId=null,this.onPointerDown=t=>{this.isDragging||(this.isInteracting=!0,this.isDelayEnded=!1,this.isDistanceSurpassed=!1,this.emitter.trigger("pointerdown",t),this.isInteracting&&(i.preventSelection(document.body),i.preventContextMenu(document.body),t.isTouch||t.origEvent.preventDefault(),this.mirror.setIsVisible(!1),this.mirror.start(t.subjectEl,t.pageX,t.pageY),this.startDelay(t),this.minDistance||this.handleDistanceSurpassed(t)))},this.onPointerMove=t=>{if(this.isInteracting){if(this.emitter.trigger("pointermove",t),!this.isDistanceSurpassed){let e,i=this.minDistance,{deltaX:n,deltaY:s}=t;e=n*n+s*s,e>=i*i&&this.handleDistanceSurpassed(t)}this.isDragging&&("scroll"!==t.origEvent.type&&(this.mirror.handleMove(t.pageX,t.pageY),this.autoScroller.handleMove(t.pageX,t.pageY)),this.emitter.trigger("dragmove",t))}},this.onPointerUp=t=>{this.isInteracting&&(this.isInteracting=!1,i.allowSelection(document.body),i.allowContextMenu(document.body),this.emitter.trigger("pointerup",t),this.isDragging&&(this.autoScroller.stop(),this.tryStopDrag(t)),this.delayTimeoutId&&(clearTimeout(this.delayTimeoutId),this.delayTimeoutId=null))};let n=this.pointer=new o(t);n.emitter.on("pointerdown",this.onPointerDown),n.emitter.on("pointermove",this.onPointerMove),n.emitter.on("pointerup",this.onPointerUp),e&&(n.selector=e),this.mirror=new a,this.autoScroller=new u}destroy(){this.pointer.destroy(),this.onPointerUp({})}startDelay(t){"number"==typeof this.delay?this.delayTimeoutId=setTimeout(()=>{this.delayTimeoutId=null,this.handleDelayEnd(t)},this.delay):this.handleDelayEnd(t)}handleDelayEnd(t){this.isDelayEnded=!0,this.tryStartDrag(t)}handleDistanceSurpassed(t){this.isDistanceSurpassed=!0,this.tryStartDrag(t)}tryStartDrag(t){this.isDelayEnded&&this.isDistanceSurpassed&&(this.pointer.wasTouchScroll&&!this.touchScrollAllowed||(this.isDragging=!0,this.mirrorNeedsRevert=!1,this.autoScroller.start(t.pageX,t.pageY,this.containerEl),this.emitter.trigger("dragstart",t),!1===this.touchScrollAllowed&&this.pointer.cancelTouchScroll()))}tryStopDrag(t){this.mirror.stop(this.mirrorNeedsRevert,this.stopDrag.bind(this,t))}stopDrag(t){this.isDragging=!1,this.emitter.trigger("dragend",t)}cancel(){this.isInteracting&&(this.isInteracting=!1,this.pointer.cancel())}setMirrorIsVisible(t){this.mirror.setIsVisible(t)}setMirrorNeedsRevert(t){this.mirrorNeedsRevert=t}setAutoScrollEnabled(t){this.autoScroller.isEnabled=t}}class v{constructor(t){this.el=t,this.origRect=i.computeRect(t),this.scrollCaches=i.getClippingParents(t).map(t=>new c(t,!0))}destroy(){for(let t of this.scrollCaches)t.destroy()}computeLeft(){let t=this.origRect.left;for(let e of this.scrollCaches)t+=e.origScrollLeft-e.getScrollLeft();return t}computeTop(){let t=this.origRect.top;for(let e of this.scrollCaches)t+=e.origScrollTop-e.getScrollTop();return t}isWithinClipping(t,e){let n={left:t,top:e};for(let t of this.scrollCaches)if(!E(t.getEventTarget())&&!i.pointInsideRect(n,t.clientRect))return!1;return!0}}function E(t){let e=t.tagName;return"HTML"===e||"BODY"===e}class m{constructor(t,e){this.useSubjectCenter=!1,this.requireInitial=!0,this.disablePointCheck=!1,this.initialHit=null,this.movingHit=null,this.finalHit=null,this.handlePointerDown=t=>{let{dragging:e}=this;this.initialHit=null,this.movingHit=null,this.finalHit=null,this.prepareHits(),this.processFirstCoord(t),this.initialHit||!this.requireInitial?this.emitter.trigger("pointerdown",t):e.cancel()},this.handleDragStart=t=>{this.emitter.trigger("dragstart",t),this.handleMove(t,!0)},this.handleDragMove=t=>{this.emitter.trigger("dragmove",t),this.handleMove(t)},this.handlePointerUp=t=>{this.releaseHits(),this.emitter.trigger("pointerup",t)},this.handleDragEnd=t=>{this.movingHit&&this.emitter.trigger("hitupdate",null,!0,t),this.finalHit=this.movingHit,this.movingHit=null,this.emitter.trigger("dragend",t)},this.droppableStore=e,t.emitter.on("pointerdown",this.handlePointerDown),t.emitter.on("dragstart",this.handleDragStart),t.emitter.on("dragmove",this.handleDragMove),t.emitter.on("pointerup",this.handlePointerUp),t.emitter.on("dragend",this.handleDragEnd),this.dragging=t,this.emitter=new i.Emitter}processFirstCoord(t){let e,n={left:t.pageX,top:t.pageY},s=n,r=t.subjectEl;r instanceof HTMLElement&&(e=i.computeRect(r),s=i.constrainPoint(s,e));let o=this.initialHit=this.queryHitForOffset(s.left,s.top);if(o){if(this.useSubjectCenter&&e){let t=i.intersectRects(e,o.rect);t&&(s=i.getRectCenter(t))}this.coordAdjust=i.diffPoints(s,n)}else this.coordAdjust={left:0,top:0}}handleMove(t,e){let i=this.queryHitForOffset(t.pageX+this.coordAdjust.left,t.pageY+this.coordAdjust.top);!e&&S(this.movingHit,i)||(this.movingHit=i,this.emitter.trigger("hitupdate",i,!1,t))}prepareHits(){this.offsetTrackers=i.mapHash(this.droppableStore,t=>(t.component.prepareHits(),new v(t.el)))}releaseHits(){let{offsetTrackers:t}=this;for(let e in t)t[e].destroy();this.offsetTrackers={}}queryHitForOffset(t,e){let{droppableStore:n,offsetTrackers:s}=this,r=null;for(let o in n){let l=n[o].component,a=s[o];if(a&&a.isWithinClipping(t,e)){let n=a.computeLeft(),s=a.computeTop(),h=t-n,c=e-s,{origRect:d}=a,g=d.right-d.left,u=d.bottom-d.top;if(h>=0&&h<g&&c>=0&&c<u){let t=l.queryHit(h,c,g,u);t&&i.rangeContainsRange(t.dateProfile.activeRange,t.dateSpan.range)&&(this.disablePointCheck||a.el.contains(a.el.getRootNode().elementFromPoint(h+n-window.scrollX,c+s-window.scrollY)))&&(!r||t.layer>r.layer)&&(t.componentId=o,t.context=l.context,t.rect.left+=n,t.rect.right+=n,t.rect.top+=s,t.rect.bottom+=s,r=t)}}}return r}}function S(t,e){return!t&&!e||Boolean(t)===Boolean(e)&&i.isDateSpansEqual(t.dateSpan,e.dateSpan)}function D(t,e){let i={};for(let n of e.pluginHooks.datePointTransforms)Object.assign(i,n(t,e));var n,s;return Object.assign(i,(n=t,{date:(s=e.dateEnv).toDate(n.range.start),dateStr:s.formatIso(n.range.start,{omitTime:n.allDay}),allDay:n.allDay})),i}class f extends i.Interaction{constructor(t){super(t),this.handlePointerDown=t=>{let{dragging:e}=this,i=t.origEvent.target;this.component.context.emitter.hasHandlers("dateClick")&&this.component.isValidDateDownEl(i)||e.cancel()},this.handleDragEnd=t=>{let{component:e}=this,{pointer:i}=this.dragging;if(!i.wasTouchScroll){let{initialHit:i,finalHit:n}=this.hitDragging;if(i&&n&&S(i,n)){let{context:n}=e,s=Object.assign(Object.assign({},D(i.dateSpan,n)),{dayEl:i.getDayEl(),jsEvent:t.origEvent,view:n.viewApi||n.calendarApi.view});n.emitter.trigger("dateClick",s)}}},this.dragging=new p(t.el),this.dragging.autoScroller.isEnabled=!1;let e=this.hitDragging=new m(this.dragging,i.interactionSettingsToStore(t));e.emitter.on("pointerdown",this.handlePointerDown),e.emitter.on("dragend",this.handleDragEnd)}destroy(){this.dragging.destroy()}}class y extends i.Interaction{constructor(t){super(t),this.dragSelection=null,this.handlePointerDown=t=>{let{component:e,dragging:i}=this,{options:n}=e.context;n.selectable&&e.isValidDateDownEl(t.origEvent.target)?i.delay=t.isTouch?function(t){let{options:e}=t.context,i=e.selectLongPressDelay;null==i&&(i=e.longPressDelay);return i}(e):null:i.cancel()},this.handleDragStart=t=>{this.component.context.calendarApi.unselect(t)},this.handleHitUpdate=(t,e)=>{let{context:n}=this.component,s=null,r=!1;if(t){let e=this.hitDragging.initialHit;t.componentId===e.componentId&&this.isHitComboAllowed&&!this.isHitComboAllowed(e,t)||(s=function(t,e,n){let s=t.dateSpan,r=e.dateSpan,o=[s.range.start,s.range.end,r.range.start,r.range.end];o.sort(i.compareNumbers);let l={};for(let i of n){let n=i(t,e);if(!1===n)return null;n&&Object.assign(l,n)}return l.range={start:o[0],end:o[3]},l.allDay=s.allDay,l}(e,t,n.pluginHooks.dateSelectionTransformers)),s&&i.isDateSelectionValid(s,t.dateProfile,n)||(r=!0,s=null)}s?n.dispatch({type:"SELECT_DATES",selection:s}):e||n.dispatch({type:"UNSELECT_DATES"}),r?i.disableCursor():i.enableCursor(),e||(this.dragSelection=s)},this.handlePointerUp=t=>{this.dragSelection&&(i.triggerDateSelect(this.dragSelection,t,this.component.context),this.dragSelection=null)};let{component:e}=t,{options:n}=e.context,s=this.dragging=new p(t.el);s.touchScrollAllowed=!1,s.minDistance=n.selectMinDistance||0,s.autoScroller.isEnabled=n.dragScroll;let r=this.hitDragging=new m(this.dragging,i.interactionSettingsToStore(t));r.emitter.on("pointerdown",this.handlePointerDown),r.emitter.on("dragstart",this.handleDragStart),r.emitter.on("hitupdate",this.handleHitUpdate),r.emitter.on("pointerup",this.handlePointerUp)}destroy(){this.dragging.destroy()}}class w extends i.Interaction{constructor(t){super(t),this.subjectEl=null,this.isDragging=!1,this.eventRange=null,this.relevantEvents=null,this.receivingContext=null,this.validMutation=null,this.mutatedRelevantEvents=null,this.handlePointerDown=t=>{let e=t.origEvent.target,{component:n,dragging:s}=this,{mirror:r}=s,{options:o}=n.context,l=n.context;this.subjectEl=t.subjectEl;let a=(this.eventRange=i.getElEventRange(t.subjectEl)).instance.instanceId;this.relevantEvents=i.getRelevantEvents(l.getCurrentData().eventStore,a),s.minDistance=t.isTouch?0:o.eventDragMinDistance,s.delay=t.isTouch&&a!==n.props.eventSelection?function(t){let{options:e}=t.context,i=e.eventLongPressDelay;null==i&&(i=e.longPressDelay);return i}(n):null,o.fixedMirrorParent?r.parentNode=o.fixedMirrorParent:r.parentNode=e.closest(".fc"),r.revertDuration=o.dragRevertDuration,n.isValidSegDownEl(e)&&!e.closest(".fc-event-resizer")?this.isDragging=t.subjectEl.classList.contains("fc-event-draggable"):s.cancel()},this.handleDragStart=t=>{let e=this.component.context,n=this.eventRange,s=n.instance.instanceId;t.isTouch?s!==this.component.props.eventSelection&&e.dispatch({type:"SELECT_EVENT",eventInstanceId:s}):e.dispatch({type:"UNSELECT_EVENT"}),this.isDragging&&(e.calendarApi.unselect(t),e.emitter.trigger("eventDragStart",{el:this.subjectEl,event:new i.EventImpl(e,n.def,n.instance),jsEvent:t.origEvent,view:e.viewApi}))},this.handleHitUpdate=(t,e)=>{if(!this.isDragging)return;let n=this.relevantEvents,s=this.hitDragging.initialHit,r=this.component.context,o=null,l=null,a=null,h=!1,c={affectedEvents:n,mutatedEvents:i.createEmptyEventStore(),isEvent:!0};if(t){o=t.context;let e=o.options;r===o||e.editable&&e.droppable?(l=function(t,e,n,s){let r=t.dateSpan,o=e.dateSpan,l=r.range.start,a=o.range.start,h={};r.allDay!==o.allDay&&(h.allDay=o.allDay,h.hasEnd=e.context.options.allDayMaintainDuration,l=o.allDay?i.startOfDay(n):n);let c=i.diffDates(l,a,t.context.dateEnv,t.componentId===e.componentId?t.largeUnit:null);c.milliseconds&&(h.allDay=!1);let d={datesDelta:c,standardProps:h};for(let i of s)i(d,t,e);return d}(s,t,this.eventRange.instance.range.start,o.getCurrentData().pluginHooks.eventDragMutationMassagers),l&&(a=i.applyMutationToEventStore(n,o.getCurrentData().eventUiBases,l,o),c.mutatedEvents=a,i.isInteractionValid(c,t.dateProfile,o)||(h=!0,l=null,a=null,c.mutatedEvents=i.createEmptyEventStore()))):o=null}this.displayDrag(o,c),h?i.disableCursor():i.enableCursor(),e||(r===o&&S(s,t)&&(l=null),this.dragging.setMirrorNeedsRevert(!l),this.dragging.setMirrorIsVisible(!t||!this.subjectEl.getRootNode().querySelector(".fc-event-mirror")),this.receivingContext=o,this.validMutation=l,this.mutatedRelevantEvents=a)},this.handlePointerUp=()=>{this.isDragging||this.cleanup()},this.handleDragEnd=t=>{if(this.isDragging){let e=this.component.context,n=e.viewApi,{receivingContext:s,validMutation:r}=this,o=this.eventRange.def,l=this.eventRange.instance,a=new i.EventImpl(e,o,l),h=this.relevantEvents,c=this.mutatedRelevantEvents,{finalHit:d}=this.hitDragging;if(this.clearDrag(),e.emitter.trigger("eventDragStop",{el:this.subjectEl,event:a,jsEvent:t.origEvent,view:n}),r){if(s===e){let s=new i.EventImpl(e,c.defs[o.defId],l?c.instances[l.instanceId]:null);e.dispatch({type:"MERGE_EVENTS",eventStore:c});let d={oldEvent:a,event:s,relatedEvents:i.buildEventApis(c,e,l),revert(){e.dispatch({type:"MERGE_EVENTS",eventStore:h})}},g={};for(let t of e.getCurrentData().pluginHooks.eventDropTransformers)Object.assign(g,t(r,e));e.emitter.trigger("eventDrop",Object.assign(Object.assign(Object.assign({},d),g),{el:t.subjectEl,delta:r.datesDelta,jsEvent:t.origEvent,view:n})),e.emitter.trigger("eventChange",d)}else if(s){let r={event:a,relatedEvents:i.buildEventApis(h,e,l),revert(){e.dispatch({type:"MERGE_EVENTS",eventStore:h})}};e.emitter.trigger("eventLeave",Object.assign(Object.assign({},r),{draggedEl:t.subjectEl,view:n})),e.dispatch({type:"REMOVE_EVENTS",eventStore:h}),e.emitter.trigger("eventRemove",r);let g=c.defs[o.defId],u=c.instances[l.instanceId],p=new i.EventImpl(s,g,u);s.dispatch({type:"MERGE_EVENTS",eventStore:c});let v={event:p,relatedEvents:i.buildEventApis(c,s,u),revert(){s.dispatch({type:"REMOVE_EVENTS",eventStore:c})}};s.emitter.trigger("eventAdd",v),t.isTouch&&s.dispatch({type:"SELECT_EVENT",eventInstanceId:l.instanceId}),s.emitter.trigger("drop",Object.assign(Object.assign({},D(d.dateSpan,s)),{draggedEl:t.subjectEl,jsEvent:t.origEvent,view:d.context.viewApi})),s.emitter.trigger("eventReceive",Object.assign(Object.assign({},v),{draggedEl:t.subjectEl,view:d.context.viewApi}))}}else e.emitter.trigger("_noEventDrop")}this.cleanup()};let{component:e}=this,{options:n}=e.context,s=this.dragging=new p(t.el);s.pointer.selector=w.SELECTOR,s.touchScrollAllowed=!1,s.autoScroller.isEnabled=n.dragScroll;let r=this.hitDragging=new m(this.dragging,i.interactionSettingsStore);r.useSubjectCenter=t.useEventCenter,r.emitter.on("pointerdown",this.handlePointerDown),r.emitter.on("dragstart",this.handleDragStart),r.emitter.on("hitupdate",this.handleHitUpdate),r.emitter.on("pointerup",this.handlePointerUp),r.emitter.on("dragend",this.handleDragEnd)}destroy(){this.dragging.destroy()}displayDrag(t,e){let n=this.component.context,s=this.receivingContext;s&&s!==t&&(s===n?s.dispatch({type:"SET_EVENT_DRAG",state:{affectedEvents:e.affectedEvents,mutatedEvents:i.createEmptyEventStore(),isEvent:!0}}):s.dispatch({type:"UNSET_EVENT_DRAG"})),t&&t.dispatch({type:"SET_EVENT_DRAG",state:e})}clearDrag(){let t=this.component.context,{receivingContext:e}=this;e&&e.dispatch({type:"UNSET_EVENT_DRAG"}),t!==e&&t.dispatch({type:"UNSET_EVENT_DRAG"})}cleanup(){this.isDragging=!1,this.eventRange=null,this.relevantEvents=null,this.receivingContext=null,this.validMutation=null,this.mutatedRelevantEvents=null}}w.SELECTOR=".fc-event-draggable, .fc-event-resizable";class T extends i.Interaction{constructor(t){super(t),this.draggingSegEl=null,this.draggingEventRange=null,this.eventRange=null,this.relevantEvents=null,this.validMutation=null,this.mutatedRelevantEvents=null,this.handlePointerDown=t=>{let{component:e}=this,n=this.querySegEl(t),s=this.eventRange=i.getElEventRange(n);this.dragging.minDistance=e.context.options.eventDragMinDistance;this.component.isValidSegDownEl(t.origEvent.target)&&!(t.isTouch&&this.component.props.eventSelection!==s.instance.instanceId)||this.dragging.cancel()},this.handleDragStart=t=>{let{context:e}=this.component,n=this.eventRange;this.relevantEvents=i.getRelevantEvents(e.getCurrentData().eventStore,this.eventRange.instance.instanceId);let s=this.querySegEl(t);this.draggingSegEl=s,this.draggingEventRange=i.getElEventRange(s),e.calendarApi.unselect(),e.emitter.trigger("eventResizeStart",{el:s,event:new i.EventImpl(e,n.def,n.instance),jsEvent:t.origEvent,view:e.viewApi})},this.handleHitUpdate=(t,e,n)=>{let{context:s}=this.component,r=this.relevantEvents,o=this.hitDragging.initialHit,l=this.eventRange.instance,a=null,h=null,c=!1,d={affectedEvents:r,mutatedEvents:i.createEmptyEventStore(),isEvent:!0};if(t){t.componentId===o.componentId&&this.isHitComboAllowed&&!this.isHitComboAllowed(o,t)||(a=function(t,e,n,s){let r=t.context.dateEnv,o=t.dateSpan.range.start,l=e.dateSpan.range.start,a=i.diffDates(o,l,r,t.largeUnit);if(n){if(r.add(s.start,a)<s.end)return{startDelta:a}}else if(r.add(s.end,a)>s.start)return{endDelta:a};return null}(o,t,n.subjectEl.classList.contains("fc-event-resizer-start"),l.range))}a&&(h=i.applyMutationToEventStore(r,s.getCurrentData().eventUiBases,a,s),d.mutatedEvents=h,i.isInteractionValid(d,t.dateProfile,s)||(c=!0,a=null,h=null,d.mutatedEvents=null)),h?s.dispatch({type:"SET_EVENT_RESIZE",state:d}):s.dispatch({type:"UNSET_EVENT_RESIZE"}),c?i.disableCursor():i.enableCursor(),e||(a&&S(o,t)&&(a=null),this.validMutation=a,this.mutatedRelevantEvents=h)},this.handleDragEnd=t=>{let{context:e}=this.component,n=this.eventRange.def,s=this.eventRange.instance,r=new i.EventImpl(e,n,s),o=this.relevantEvents,l=this.mutatedRelevantEvents;if(e.emitter.trigger("eventResizeStop",{el:this.draggingSegEl,event:r,jsEvent:t.origEvent,view:e.viewApi}),this.validMutation){let a=new i.EventImpl(e,l.defs[n.defId],s?l.instances[s.instanceId]:null);e.dispatch({type:"MERGE_EVENTS",eventStore:l});let h={oldEvent:r,event:a,relatedEvents:i.buildEventApis(l,e,s),revert(){e.dispatch({type:"MERGE_EVENTS",eventStore:o})}};e.emitter.trigger("eventResize",Object.assign(Object.assign({},h),{el:this.draggingSegEl,startDelta:this.validMutation.startDelta||i.createDuration(0),endDelta:this.validMutation.endDelta||i.createDuration(0),jsEvent:t.origEvent,view:e.viewApi})),e.emitter.trigger("eventChange",h)}else e.emitter.trigger("_noEventResize");this.draggingEventRange=null,this.relevantEvents=null,this.validMutation=null};let{component:e}=t,n=this.dragging=new p(t.el);n.pointer.selector=".fc-event-resizer",n.touchScrollAllowed=!1,n.autoScroller.isEnabled=e.context.options.dragScroll;let s=this.hitDragging=new m(this.dragging,i.interactionSettingsToStore(t));s.emitter.on("pointerdown",this.handlePointerDown),s.emitter.on("dragstart",this.handleDragStart),s.emitter.on("hitupdate",this.handleHitUpdate),s.emitter.on("dragend",this.handleDragEnd)}destroy(){this.dragging.destroy()}querySegEl(t){return t.subjectEl.closest(".fc-event")}}const b={fixedMirrorParent:i.identity},M={dateClick:i.identity,eventDragStart:i.identity,eventDragStop:i.identity,eventDrop:i.identity,eventResizeStart:i.identity,eventResizeStop:i.identity,eventResize:i.identity,drop:i.identity,eventReceive:i.identity,eventLeave:i.identity};class C{constructor(t,e){this.receivingContext=null,this.droppableEvent=null,this.suppliedDragMeta=null,this.dragMeta=null,this.handleDragStart=t=>{this.dragMeta=this.buildDragMeta(t.subjectEl)},this.handleHitUpdate=(t,e,n)=>{let{dragging:s}=this.hitDragging,r=null,o=null,l=!1,a={affectedEvents:i.createEmptyEventStore(),mutatedEvents:i.createEmptyEventStore(),isEvent:this.dragMeta.create};t&&(r=t.context,this.canDropElOnCalendar(n.subjectEl,r)&&(o=function(t,e,n){let s=Object.assign({},e.leftoverProps);for(let i of n.pluginHooks.externalDefTransforms)Object.assign(s,i(t,e));let{refined:r,extra:o}=i.refineEventDef(s,n),l=i.parseEventDef(r,o,e.sourceId,t.allDay,n.options.forceEventDuration||Boolean(e.duration),n),a=t.range.start;t.allDay&&e.startTime&&(a=n.dateEnv.add(a,e.startTime));let h=e.duration?n.dateEnv.add(a,e.duration):i.getDefaultEventEnd(t.allDay,a,n),c=i.createEventInstance(l.defId,{start:a,end:h});return{def:l,instance:c}}(t.dateSpan,this.dragMeta,r),a.mutatedEvents=i.eventTupleToStore(o),l=!i.isInteractionValid(a,t.dateProfile,r),l&&(a.mutatedEvents=i.createEmptyEventStore(),o=null))),this.displayDrag(r,a),s.setMirrorIsVisible(e||!o||!document.querySelector(".fc-event-mirror")),l?i.disableCursor():i.enableCursor(),e||(s.setMirrorNeedsRevert(!o),this.receivingContext=r,this.droppableEvent=o)},this.handleDragEnd=t=>{let{receivingContext:e,droppableEvent:n}=this;if(this.clearDrag(),e&&n){let s=this.hitDragging.finalHit,r=s.context.viewApi,o=this.dragMeta;if(e.emitter.trigger("drop",Object.assign(Object.assign({},D(s.dateSpan,e)),{draggedEl:t.subjectEl,jsEvent:t.origEvent,view:r})),o.create){let s=i.eventTupleToStore(n);e.dispatch({type:"MERGE_EVENTS",eventStore:s}),t.isTouch&&e.dispatch({type:"SELECT_EVENT",eventInstanceId:n.instance.instanceId}),e.emitter.trigger("eventReceive",{event:new i.EventImpl(e,n.def,n.instance),relatedEvents:[],revert(){e.dispatch({type:"REMOVE_EVENTS",eventStore:s})},draggedEl:t.subjectEl,view:r})}}this.receivingContext=null,this.droppableEvent=null};let n=this.hitDragging=new m(t,i.interactionSettingsStore);n.requireInitial=!1,n.emitter.on("dragstart",this.handleDragStart),n.emitter.on("hitupdate",this.handleHitUpdate),n.emitter.on("dragend",this.handleDragEnd),this.suppliedDragMeta=e}buildDragMeta(t){return"object"==typeof this.suppliedDragMeta?i.parseDragMeta(this.suppliedDragMeta):"function"==typeof this.suppliedDragMeta?i.parseDragMeta(this.suppliedDragMeta(t)):function(t){let e=function(t,e){let n=i.config.dataAttrPrefix,s=(n?n+"-":"")+e;return t.getAttribute("data-"+s)||""}(t,"event"),n=e?JSON.parse(e):{create:!1};return i.parseDragMeta(n)}(t)}displayDrag(t,e){let i=this.receivingContext;i&&i!==t&&i.dispatch({type:"UNSET_EVENT_DRAG"}),t&&t.dispatch({type:"SET_EVENT_DRAG",state:e})}clearDrag(){this.receivingContext&&this.receivingContext.dispatch({type:"UNSET_EVENT_DRAG"})}canDropElOnCalendar(t,e){let i=e.options.dropAccept;return"function"==typeof i?i.call(e.calendarApi,t):"string"!=typeof i||!i||t.matches(i)}}i.config.dataAttrPrefix="";class R extends i.ElementDragging{constructor(t){super(t),this.shouldIgnoreMove=!1,this.mirrorSelector="",this.currentMirrorEl=null,this.handlePointerDown=t=>{this.emitter.trigger("pointerdown",t),this.shouldIgnoreMove||this.emitter.trigger("dragstart",t)},this.handlePointerMove=t=>{this.shouldIgnoreMove||this.emitter.trigger("dragmove",t)},this.handlePointerUp=t=>{this.emitter.trigger("pointerup",t),this.shouldIgnoreMove||this.emitter.trigger("dragend",t)};let e=this.pointer=new o(t);e.emitter.on("pointerdown",this.handlePointerDown),e.emitter.on("pointermove",this.handlePointerMove),e.emitter.on("pointerup",this.handlePointerUp)}destroy(){this.pointer.destroy()}cancel(){this.shouldIgnoreMove=!0}setMirrorIsVisible(t){if(t)this.currentMirrorEl&&(this.currentMirrorEl.style.visibility="",this.currentMirrorEl=null);else{let t=this.mirrorSelector?document.querySelector(this.mirrorSelector):null;t&&(this.currentMirrorEl=t,t.style.visibility="hidden")}}}var I=e.createPlugin({name:"@fullcalendar/interaction",componentInteractions:[f,y,w,T],calendarInteractions:[class{constructor(t){this.context=t,this.isRecentPointerDateSelect=!1,this.matchesCancel=!1,this.matchesEvent=!1,this.onSelect=t=>{t.jsEvent&&(this.isRecentPointerDateSelect=!0)},this.onDocumentPointerDown=t=>{let e=this.context.options.unselectCancel,n=i.getEventTargetViaRoot(t.origEvent);this.matchesCancel=!!n.closest(e),this.matchesEvent=!!n.closest(w.SELECTOR)},this.onDocumentPointerUp=t=>{let{context:e}=this,{documentPointer:i}=this,n=e.getCurrentData();if(!i.wasTouchScroll){if(n.dateSelection&&!this.isRecentPointerDateSelect){let i=e.options.unselectAuto;!i||i&&this.matchesCancel||e.calendarApi.unselect(t)}n.eventSelection&&!this.matchesEvent&&e.dispatch({type:"UNSELECT_EVENT"})}this.isRecentPointerDateSelect=!1};let e=this.documentPointer=new o(document);e.shouldIgnoreMove=!0,e.shouldWatchScroll=!1,e.emitter.on("pointerdown",this.onDocumentPointerDown),e.emitter.on("pointerup",this.onDocumentPointerUp),t.emitter.on("select",this.onSelect)}destroy(){this.context.emitter.off("select",this.onSelect),this.documentPointer.destroy()}}],elementDraggingImpl:p,optionRefiners:b,listenerRefiners:M});return e.globalPlugins.push(I),t.Draggable=class{constructor(t,e={}){this.handlePointerDown=t=>{let{dragging:e}=this,{minDistance:n,longPressDelay:s}=this.settings;e.minDistance=null!=n?n:t.isTouch?0:i.BASE_OPTION_DEFAULTS.eventDragMinDistance,e.delay=t.isTouch?null!=s?s:i.BASE_OPTION_DEFAULTS.longPressDelay:0},this.handleDragStart=t=>{t.isTouch&&this.dragging.delay&&t.subjectEl.classList.contains("fc-event")&&this.dragging.mirror.getMirrorEl().classList.add("fc-event-selected")},this.settings=e;let n=this.dragging=new p(t);n.touchScrollAllowed=!1,null!=e.itemSelector&&(n.pointer.selector=e.itemSelector),null!=e.appendTo&&(n.mirror.parentNode=e.appendTo),n.emitter.on("pointerdown",this.handlePointerDown),n.emitter.on("dragstart",this.handleDragStart),new C(n,e.eventData)}destroy(){this.dragging.destroy()}},t.ThirdPartyDraggable=class{constructor(t,e){let i=document;t===document||t instanceof Element?(i=t,e=e||{}):e=t||{};let n=this.dragging=new R(i);"string"==typeof e.itemSelector?n.pointer.selector=e.itemSelector:i===document&&(n.pointer.selector="[data-event]"),"string"==typeof e.mirrorSelector&&(n.mirrorSelector=e.mirrorSelector),new C(n,e.eventData).hitDragging.disablePointCheck=!0}destroy(){this.dragging.destroy()}},t.default=I,Object.defineProperty(t,"__esModule",{value:!0}),t}({},FullCalendar,FullCalendar.Internal);
package/index.js CHANGED
@@ -29,7 +29,7 @@ class PointerDragging {
29
29
  // internal states
30
30
  this.isDragging = false;
31
31
  this.isTouchDragging = false;
32
- this.wasTouchScroll = false;
32
+ this.wasTouchScroll = false; // HACK public
33
33
  // Mouse
34
34
  // ----------------------------------------------------------------------------------------------------
35
35
  this.handleMouseDown = (ev) => {
@@ -79,9 +79,11 @@ class PointerDragging {
79
79
  }
80
80
  };
81
81
  this.handleTouchMove = (ev) => {
82
- let pev = this.createEventFromTouch(ev);
83
- this.recordCoords(pev);
84
- this.emitter.trigger('pointermove', pev);
82
+ if (this.isDragging) {
83
+ let pev = this.createEventFromTouch(ev);
84
+ this.recordCoords(pev);
85
+ this.emitter.trigger('pointermove', pev);
86
+ }
85
87
  };
86
88
  this.handleTouchEnd = (ev) => {
87
89
  if (this.isDragging) { // done to guard against touchend followed by touchcancel
@@ -125,6 +127,11 @@ class PointerDragging {
125
127
  this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
126
128
  listenerDestroyed();
127
129
  }
130
+ cancel() {
131
+ if (this.isDragging) {
132
+ this.cleanup();
133
+ }
134
+ }
128
135
  tryStart(ev) {
129
136
  let subjectEl = this.querySubjectEl(ev);
130
137
  let downEl = ev.target;
@@ -708,17 +715,16 @@ class FeaturefulElementDragging extends ElementDragging {
708
715
  this.isInteracting = true;
709
716
  this.isDelayEnded = false;
710
717
  this.isDistanceSurpassed = false;
711
- preventSelection(document.body);
712
- preventContextMenu(document.body);
713
- // prevent links from being visited if there's an eventual drag.
714
- // also prevents selection in older browsers (maybe?).
715
- // not necessary for touch, besides, browser would complain about passiveness.
716
- if (!ev.isTouch) {
717
- ev.origEvent.preventDefault();
718
- }
719
718
  this.emitter.trigger('pointerdown', ev);
720
- if (this.isInteracting && // not destroyed via pointerdown handler
721
- !this.pointer.shouldIgnoreMove) {
719
+ if (this.isInteracting) { // not cancelled?
720
+ preventSelection(document.body);
721
+ preventContextMenu(document.body);
722
+ // prevent links from being visited if there's an eventual drag.
723
+ // also prevents selection in older browsers (maybe?).
724
+ // not necessary for touch, besides, browser would complain about passiveness.
725
+ if (!ev.isTouch) {
726
+ ev.origEvent.preventDefault();
727
+ }
722
728
  // actions related to initiating dragstart+dragmove+dragend...
723
729
  this.mirror.setIsVisible(false); // reset. caller must set-visible
724
730
  this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
@@ -825,8 +831,14 @@ class FeaturefulElementDragging extends ElementDragging {
825
831
  this.emitter.trigger('dragend', ev);
826
832
  }
827
833
  // fill in the implementations...
828
- setIgnoreMove(bool) {
829
- this.pointer.shouldIgnoreMove = bool;
834
+ /*
835
+ Can only be called by pointerdown to prevent drag
836
+ */
837
+ cancel() {
838
+ if (this.isInteracting) {
839
+ this.isInteracting = false;
840
+ this.pointer.cancel();
841
+ }
830
842
  }
831
843
  setMirrorIsVisible(bool) {
832
844
  this.mirror.setIsVisible(bool);
@@ -921,12 +933,11 @@ class HitDragging {
921
933
  this.prepareHits();
922
934
  this.processFirstCoord(ev);
923
935
  if (this.initialHit || !this.requireInitial) {
924
- dragging.setIgnoreMove(false);
925
936
  // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
926
937
  this.emitter.trigger('pointerdown', ev);
927
938
  }
928
939
  else {
929
- dragging.setIgnoreMove(true);
940
+ dragging.cancel();
930
941
  }
931
942
  };
932
943
  this.handleDragStart = (ev) => {
@@ -1085,8 +1096,14 @@ class DateClicking extends Interaction {
1085
1096
  this.handlePointerDown = (pev) => {
1086
1097
  let { dragging } = this;
1087
1098
  let downEl = pev.origEvent.target;
1088
- // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
1089
- dragging.setIgnoreMove(!this.component.isValidDateDownEl(downEl));
1099
+ /*
1100
+ If no dateClick, allow text on dates to be text-selectable
1101
+ */
1102
+ const canDateClick = this.component.context.emitter.hasHandlers('dateClick') &&
1103
+ this.component.isValidDateDownEl(downEl);
1104
+ if (!canDateClick) {
1105
+ dragging.cancel();
1106
+ }
1090
1107
  };
1091
1108
  // won't even fire if moving was ignored
1092
1109
  this.handleDragEnd = (ev) => {
@@ -1096,7 +1113,7 @@ class DateClicking extends Interaction {
1096
1113
  let { initialHit, finalHit } = this.hitDragging;
1097
1114
  if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
1098
1115
  let { context } = component;
1099
- let arg = Object.assign(Object.assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.dayEl, jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
1116
+ let arg = Object.assign(Object.assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.getDayEl(), jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
1100
1117
  context.emitter.trigger('dateClick', arg);
1101
1118
  }
1102
1119
  }
@@ -1124,12 +1141,15 @@ class DateSelecting extends Interaction {
1124
1141
  this.handlePointerDown = (ev) => {
1125
1142
  let { component, dragging } = this;
1126
1143
  let { options } = component.context;
1127
- let canSelect = options.selectable &&
1144
+ let canDateSelect = options.selectable &&
1128
1145
  component.isValidDateDownEl(ev.origEvent.target);
1129
- // don't bother to watch expensive moves if component won't do selection
1130
- dragging.setIgnoreMove(!canSelect);
1131
- // if touch, require user to hold down
1132
- dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
1146
+ if (!canDateSelect) {
1147
+ dragging.cancel();
1148
+ }
1149
+ else {
1150
+ // if touch, require user to hold down
1151
+ dragging.delay = ev.isTouch ? getComponentTouchDelay$1(component) : null;
1152
+ }
1133
1153
  };
1134
1154
  this.handleDragStart = (ev) => {
1135
1155
  this.component.context.calendarApi.unselect(ev); // unselect previous selections
@@ -1259,11 +1279,15 @@ class EventDragging extends Interaction {
1259
1279
  mirror.revertDuration = options.dragRevertDuration;
1260
1280
  let isValid = component.isValidSegDownEl(origTarget) &&
1261
1281
  !origTarget.closest('.fc-event-resizer'); // NOT on a resizer
1262
- dragging.setIgnoreMove(!isValid);
1263
- // disable dragging for elements that are resizable (ie, selectable)
1264
- // but are not draggable
1265
- this.isDragging = isValid &&
1266
- ev.subjectEl.classList.contains('fc-event-draggable');
1282
+ if (!isValid) {
1283
+ dragging.cancel();
1284
+ }
1285
+ else {
1286
+ // disable dragging for elements that are resizable (ie, selectable)
1287
+ // but are not draggable
1288
+ // TODO: merge this with .cancel() ?
1289
+ this.isDragging = ev.subjectEl.classList.contains('fc-event-draggable');
1290
+ }
1267
1291
  };
1268
1292
  this.handleDragStart = (ev) => {
1269
1293
  let initialContext = this.component.context;
@@ -1576,9 +1600,11 @@ class EventResizing extends Interaction {
1576
1600
  let segEl = this.querySegEl(ev);
1577
1601
  let eventRange = this.eventRange = getElEventRange(segEl);
1578
1602
  this.dragging.minDistance = component.context.options.eventDragMinDistance;
1579
- // if touch, need to be working with a selected event
1580
- this.dragging.setIgnoreMove(!this.component.isValidSegDownEl(ev.origEvent.target) ||
1581
- (ev.isTouch && this.component.props.eventSelection !== eventRange.instance.instanceId));
1603
+ const isValid = this.component.isValidSegDownEl(ev.origEvent.target) &&
1604
+ !(ev.isTouch && this.component.props.eventSelection !== eventRange.instance.instanceId);
1605
+ if (!isValid) {
1606
+ this.dragging.cancel();
1607
+ }
1582
1608
  };
1583
1609
  this.handleDragStart = (ev) => {
1584
1610
  let { context } = this.component;
@@ -2048,8 +2074,8 @@ class InferredElementDragging extends ElementDragging {
2048
2074
  destroy() {
2049
2075
  this.pointer.destroy();
2050
2076
  }
2051
- setIgnoreMove(bool) {
2052
- this.shouldIgnoreMove = bool;
2077
+ cancel() {
2078
+ this.shouldIgnoreMove = true;
2053
2079
  }
2054
2080
  setMirrorIsVisible(bool) {
2055
2081
  if (bool) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fullcalendar/interaction",
3
- "version": "7.0.0-beta.3",
3
+ "version": "7.0.0-rc.0",
4
4
  "title": "FullCalendar Interaction Plugin",
5
5
  "description": "Calendar functionality for event drag-n-drop, event resizing, date clicking, and date selecting",
6
6
  "keywords": [
@@ -14,7 +14,7 @@
14
14
  ],
15
15
  "homepage": "https://fullcalendar.io/docs/editable",
16
16
  "peerDependencies": {
17
- "@fullcalendar/core": "7.0.0-beta.3"
17
+ "@fullcalendar/core": "7.0.0-rc.0"
18
18
  },
19
19
  "type": "module",
20
20
  "bugs": "https://fullcalendar.io/reporting-bugs",