@gravity-ui/page-constructor 8.12.0 → 8.13.0-beta.1

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.
@@ -29,14 +29,9 @@ module.exports = __toCommonJS(stdin_exports);
29
29
  function isObject(obj) {
30
30
  return obj !== null && typeof obj === "object" && "constructor" in obj && obj.constructor === Object;
31
31
  }
32
- function extend(target, src) {
33
- if (target === void 0) {
34
- target = {};
35
- }
36
- if (src === void 0) {
37
- src = {};
38
- }
39
- Object.keys(src).forEach((key) => {
32
+ function extend(target = {}, src = {}) {
33
+ const noExtend = ["__proto__", "constructor", "prototype"];
34
+ Object.keys(src).filter((key) => noExtend.indexOf(key) < 0).forEach((key) => {
40
35
  if (typeof target[key] === "undefined") target[key] = src[key];
41
36
  else if (isObject(src[key]) && isObject(target[key]) && Object.keys(src[key]).length > 0) {
42
37
  extend(target[key], src[key]);
@@ -175,18 +170,23 @@ function getWindow() {
175
170
  }
176
171
 
177
172
  // node_modules/swiper/shared/utils.mjs
178
- function elementChildren(element, selector) {
179
- if (selector === void 0) {
180
- selector = "";
181
- }
182
- return [...element.children].filter((el) => el.matches(selector));
173
+ function classesToTokens(classes = "") {
174
+ return classes.trim().split(" ").filter((c) => !!c.trim());
183
175
  }
184
- function createElement(tag, classes) {
185
- if (classes === void 0) {
186
- classes = [];
176
+ function elementChildren(element, selector = "") {
177
+ const window2 = getWindow();
178
+ const children = [...element.children];
179
+ if (window2.HTMLSlotElement && element instanceof HTMLSlotElement) {
180
+ children.push(...element.assignedElements());
181
+ }
182
+ if (!selector) {
183
+ return children;
187
184
  }
185
+ return children.filter((el) => el.matches(selector));
186
+ }
187
+ function createElement(tag, classes = []) {
188
188
  const el = document.createElement(tag);
189
- el.classList.add(...Array.isArray(classes) ? classes : [classes]);
189
+ el.classList.add(...Array.isArray(classes) ? classes : classesToTokens(classes));
190
190
  return el;
191
191
  }
192
192
  function elementIndex(el) {
@@ -221,6 +221,18 @@ function elementOuterSize(el, size, includeMargins) {
221
221
  }
222
222
  return el.offsetWidth;
223
223
  }
224
+ function makeElementsArray(el) {
225
+ return (Array.isArray(el) ? el : [el]).filter((e) => !!e);
226
+ }
227
+ function setInnerHTML(el, html = "") {
228
+ if (typeof trustedTypes !== "undefined") {
229
+ el.innerHTML = trustedTypes.createPolicy("html", {
230
+ createHTML: (s) => s
231
+ }).createHTML(html);
232
+ } else {
233
+ el.innerHTML = html;
234
+ }
235
+ }
224
236
 
225
237
  // node_modules/swiper/shared/create-element-if-not-defined.mjs
226
238
  function createElementIfNotDefined(swiper, originalParams, params, checkProps) {
@@ -242,21 +254,17 @@ function createElementIfNotDefined(swiper, originalParams, params, checkProps) {
242
254
  }
243
255
 
244
256
  // node_modules/swiper/shared/classes-to-selector.mjs
245
- function classesToSelector(classes) {
246
- if (classes === void 0) {
247
- classes = "";
248
- }
249
- return `.${classes.trim().replace(/([\.:!+\/])/g, "\\$1").replace(/ /g, ".")}`;
257
+ function classesToSelector(classes = "") {
258
+ return `.${classes.trim().replace(/([\.:!+\/()[\]#>~*^$|=,'"@{}\\])/g, "\\$1").replace(/ /g, ".")}`;
250
259
  }
251
260
 
252
261
  // node_modules/swiper/modules/pagination.mjs
253
- function Pagination(_ref) {
254
- let {
255
- swiper,
256
- extendParams,
257
- on,
258
- emit
259
- } = _ref;
262
+ function Pagination({
263
+ swiper,
264
+ extendParams,
265
+ on,
266
+ emit
267
+ }) {
260
268
  const pfx = "swiper-pagination";
261
269
  extendParams({
262
270
  pagination: {
@@ -296,7 +304,6 @@ function Pagination(_ref) {
296
304
  };
297
305
  let bulletSize;
298
306
  let dynamicBulletIndex = 0;
299
- const makeElementsArray = (el) => (Array.isArray(el) ? el : [el]).filter((e) => !!e);
300
307
  function isPaginationDisabled() {
301
308
  return !swiper.params.pagination.el || !swiper.pagination.el || Array.isArray(swiper.pagination.el) && swiper.pagination.el.length === 0;
302
309
  }
@@ -314,6 +321,16 @@ function Pagination(_ref) {
314
321
  }
315
322
  }
316
323
  }
324
+ function getMoveDirection(prevIndex, nextIndex, length) {
325
+ prevIndex = prevIndex % length;
326
+ nextIndex = nextIndex % length;
327
+ if (nextIndex === prevIndex + 1) {
328
+ return "next";
329
+ } else if (nextIndex === prevIndex - 1) {
330
+ return "previous";
331
+ }
332
+ return;
333
+ }
317
334
  function onBulletClick(e) {
318
335
  const bulletEl = e.target.closest(classesToSelector(swiper.params.pagination.bulletClass));
319
336
  if (!bulletEl) {
@@ -323,30 +340,14 @@ function Pagination(_ref) {
323
340
  const index = elementIndex(bulletEl) * swiper.params.slidesPerGroup;
324
341
  if (swiper.params.loop) {
325
342
  if (swiper.realIndex === index) return;
326
- const realIndex = swiper.realIndex;
327
- const newSlideIndex = swiper.getSlideIndexByData(index);
328
- const currentSlideIndex = swiper.getSlideIndexByData(swiper.realIndex);
329
- const loopFix = (dir) => {
330
- const indexBeforeLoopFix = swiper.activeIndex;
331
- swiper.loopFix({
332
- direction: dir,
333
- activeSlideIndex: newSlideIndex,
334
- slideTo: false
335
- });
336
- const indexAfterFix = swiper.activeIndex;
337
- if (indexBeforeLoopFix === indexAfterFix) {
338
- swiper.slideToLoop(realIndex, 0, false, true);
339
- }
340
- };
341
- if (newSlideIndex > swiper.slides.length - swiper.loopedSlides) {
342
- loopFix(newSlideIndex > currentSlideIndex ? "next" : "prev");
343
- } else if (swiper.params.centeredSlides) {
344
- const slidesPerView = swiper.params.slidesPerView === "auto" ? swiper.slidesPerViewDynamic() : Math.ceil(parseFloat(swiper.params.slidesPerView, 10));
345
- if (newSlideIndex < Math.floor(slidesPerView / 2)) {
346
- loopFix("prev");
347
- }
343
+ const moveDirection = getMoveDirection(swiper.realIndex, index, swiper.slides.length);
344
+ if (moveDirection === "next") {
345
+ swiper.slideNext();
346
+ } else if (moveDirection === "previous") {
347
+ swiper.slidePrev();
348
+ } else {
349
+ swiper.slideToLoop(index);
348
350
  }
349
- swiper.slideToLoop(index);
350
351
  } else {
351
352
  swiper.slideTo(index);
352
353
  }
@@ -478,7 +479,7 @@ function Pagination(_ref) {
478
479
  });
479
480
  }
480
481
  if (params.type === "custom" && params.renderCustom) {
481
- subEl.innerHTML = params.renderCustom(swiper, current + 1, total);
482
+ setInnerHTML(subEl, params.renderCustom(swiper, current + 1, total));
482
483
  if (subElIndex === 0) emit("paginationRender", subEl);
483
484
  } else {
484
485
  if (subElIndex === 0) emit("paginationRender", subEl);
@@ -492,7 +493,7 @@ function Pagination(_ref) {
492
493
  function render() {
493
494
  const params = swiper.params.pagination;
494
495
  if (isPaginationDisabled()) return;
495
- const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length;
496
+ const slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.grid && swiper.params.grid.rows > 1 ? swiper.slides.length / Math.ceil(swiper.params.grid.rows) : swiper.slides.length;
496
497
  let el = swiper.pagination.el;
497
498
  el = makeElementsArray(el);
498
499
  let paginationHTML = "";
@@ -526,7 +527,7 @@ function Pagination(_ref) {
526
527
  swiper.pagination.bullets = [];
527
528
  el.forEach((subEl) => {
528
529
  if (params.type !== "custom") {
529
- subEl.innerHTML = paginationHTML || "";
530
+ setInnerHTML(subEl, paginationHTML || "");
530
531
  }
531
532
  if (params.type === "bullets") {
532
533
  swiper.pagination.bullets.push(...subEl.querySelectorAll(classesToSelector(params.bulletClass)));
@@ -556,10 +557,10 @@ function Pagination(_ref) {
556
557
  if (swiper.params.uniqueNavElements && typeof params.el === "string" && Array.isArray(el) && el.length > 1) {
557
558
  el = [...swiper.el.querySelectorAll(params.el)];
558
559
  if (el.length > 1) {
559
- el = el.filter((subEl) => {
560
+ el = el.find((subEl) => {
560
561
  if (elementParents(subEl, ".swiper")[0] !== swiper.el) return false;
561
562
  return true;
562
- })[0];
563
+ });
563
564
  }
564
565
  }
565
566
  if (Array.isArray(el) && el.length === 1) el = el[0];
@@ -706,12 +707,11 @@ function Pagination(_ref) {
706
707
  }
707
708
 
708
709
  // node_modules/swiper/modules/a11y.mjs
709
- function A11y(_ref) {
710
- let {
711
- swiper,
712
- extendParams,
713
- on
714
- } = _ref;
710
+ function A11y({
711
+ swiper,
712
+ extendParams,
713
+ on
714
+ }) {
715
715
  extendParams({
716
716
  a11y: {
717
717
  enabled: true,
@@ -724,26 +724,27 @@ function A11y(_ref) {
724
724
  slideLabelMessage: "{{index}} / {{slidesLength}}",
725
725
  containerMessage: null,
726
726
  containerRoleDescriptionMessage: null,
727
+ containerRole: null,
727
728
  itemRoleDescriptionMessage: null,
728
729
  slideRole: "group",
729
- id: null
730
+ id: null,
731
+ scrollOnFocus: true,
732
+ wrapperLiveRegion: true
730
733
  }
731
734
  });
732
735
  swiper.a11y = {
733
736
  clicked: false
734
737
  };
735
738
  let liveRegion = null;
739
+ let preventFocusHandler;
740
+ let focusTargetSlideEl;
741
+ let visibilityChangedTimestamp = (/* @__PURE__ */ new Date()).getTime();
736
742
  function notify(message) {
737
743
  const notification = liveRegion;
738
744
  if (notification.length === 0) return;
739
- notification.innerHTML = "";
740
- notification.innerHTML = message;
745
+ setInnerHTML(notification, message);
741
746
  }
742
- const makeElementsArray = (el) => (Array.isArray(el) ? el : [el]).filter((e) => !!e);
743
- function getRandomNumber(size) {
744
- if (size === void 0) {
745
- size = 16;
746
- }
747
+ function getRandomNumber(size = 16) {
747
748
  const randomChar = () => Math.round(16 * Math.random()).toString(16);
748
749
  return "x".repeat(size).replace(/x/g, randomChar);
749
750
  }
@@ -771,12 +772,6 @@ function A11y(_ref) {
771
772
  subEl.setAttribute("aria-roledescription", description);
772
773
  });
773
774
  }
774
- function addElControls(el, controls) {
775
- el = makeElementsArray(el);
776
- el.forEach((subEl) => {
777
- subEl.setAttribute("aria-controls", controls);
778
- });
779
- }
780
775
  function addElLabel(el, label) {
781
776
  el = makeElementsArray(el);
782
777
  el.forEach((subEl) => {
@@ -804,7 +799,7 @@ function A11y(_ref) {
804
799
  function enableEl(el) {
805
800
  el = makeElementsArray(el);
806
801
  el.forEach((subEl) => {
807
- subEl.setAttribute("aria-disabled", false);
802
+ subEl.removeAttribute("aria-disabled");
808
803
  });
809
804
  }
810
805
  function onEnterOrSpaceKey(e) {
@@ -814,24 +809,28 @@ function A11y(_ref) {
814
809
  if (swiper.pagination && swiper.pagination.el && (targetEl === swiper.pagination.el || swiper.pagination.el.contains(e.target))) {
815
810
  if (!e.target.matches(classesToSelector(swiper.params.pagination.bulletClass))) return;
816
811
  }
817
- if (swiper.navigation && swiper.navigation.nextEl && targetEl === swiper.navigation.nextEl) {
818
- if (!(swiper.isEnd && !swiper.params.loop)) {
819
- swiper.slideNext();
820
- }
821
- if (swiper.isEnd) {
822
- notify(params.lastSlideMessage);
823
- } else {
824
- notify(params.nextSlideMessage);
825
- }
826
- }
827
- if (swiper.navigation && swiper.navigation.prevEl && targetEl === swiper.navigation.prevEl) {
828
- if (!(swiper.isBeginning && !swiper.params.loop)) {
829
- swiper.slidePrev();
812
+ if (swiper.navigation && swiper.navigation.prevEl && swiper.navigation.nextEl) {
813
+ const prevEls = makeElementsArray(swiper.navigation.prevEl);
814
+ const nextEls = makeElementsArray(swiper.navigation.nextEl);
815
+ if (nextEls.includes(targetEl)) {
816
+ if (!(swiper.isEnd && !swiper.params.loop)) {
817
+ swiper.slideNext();
818
+ }
819
+ if (swiper.isEnd) {
820
+ notify(params.lastSlideMessage);
821
+ } else {
822
+ notify(params.nextSlideMessage);
823
+ }
830
824
  }
831
- if (swiper.isBeginning) {
832
- notify(params.firstSlideMessage);
833
- } else {
834
- notify(params.prevSlideMessage);
825
+ if (prevEls.includes(targetEl)) {
826
+ if (!(swiper.isBeginning && !swiper.params.loop)) {
827
+ swiper.slidePrev();
828
+ }
829
+ if (swiper.isBeginning) {
830
+ notify(params.firstSlideMessage);
831
+ } else {
832
+ notify(params.prevSlideMessage);
833
+ }
835
834
  }
836
835
  }
837
836
  if (swiper.pagination && targetEl.matches(classesToSelector(swiper.params.pagination.bulletClass))) {
@@ -894,12 +893,15 @@ function A11y(_ref) {
894
893
  el.addEventListener("keydown", onEnterOrSpaceKey);
895
894
  }
896
895
  addElLabel(el, message);
897
- addElControls(el, wrapperId);
898
896
  };
899
- const handlePointerDown = () => {
897
+ const handlePointerDown = (e) => {
898
+ if (focusTargetSlideEl && focusTargetSlideEl !== e.target && !focusTargetSlideEl.contains(e.target)) {
899
+ preventFocusHandler = true;
900
+ }
900
901
  swiper.a11y.clicked = true;
901
902
  };
902
903
  const handlePointerUp = () => {
904
+ preventFocusHandler = false;
903
905
  requestAnimationFrame(() => {
904
906
  requestAnimationFrame(() => {
905
907
  if (!swiper.destroyed) {
@@ -908,11 +910,17 @@ function A11y(_ref) {
908
910
  });
909
911
  });
910
912
  };
913
+ const onVisibilityChange = (e) => {
914
+ visibilityChangedTimestamp = (/* @__PURE__ */ new Date()).getTime();
915
+ };
911
916
  const handleFocus = (e) => {
912
- if (swiper.a11y.clicked) return;
917
+ if (swiper.a11y.clicked || !swiper.params.a11y.scrollOnFocus) return;
918
+ if ((/* @__PURE__ */ new Date()).getTime() - visibilityChangedTimestamp < 100) return;
913
919
  const slideEl = e.target.closest(`.${swiper.params.slideClass}, swiper-slide`);
914
920
  if (!slideEl || !swiper.slides.includes(slideEl)) return;
915
- const isActive = swiper.slides.indexOf(slideEl) === swiper.activeIndex;
921
+ focusTargetSlideEl = slideEl;
922
+ const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
923
+ const isActive = (isVirtual ? parseInt(slideEl.getAttribute("data-swiper-slide-index"), 10) : swiper.slides.indexOf(slideEl)) === swiper.activeIndex;
916
924
  const isVisible = swiper.params.watchSlidesProgress && swiper.visibleSlides && swiper.visibleSlides.includes(slideEl);
917
925
  if (isActive || isVisible) return;
918
926
  if (e.sourceCapabilities && e.sourceCapabilities.firesTouchEvents) return;
@@ -921,7 +929,17 @@ function A11y(_ref) {
921
929
  } else {
922
930
  swiper.el.scrollTop = 0;
923
931
  }
924
- swiper.slideTo(swiper.slides.indexOf(slideEl), 0);
932
+ requestAnimationFrame(() => {
933
+ if (preventFocusHandler) return;
934
+ if (swiper.params.loop) {
935
+ swiper.slideToLoop(swiper.getSlideIndexWhenGrid(parseInt(slideEl.getAttribute("data-swiper-slide-index"))), 0);
936
+ } else if (isVirtual) {
937
+ swiper.slideTo(swiper.getSlideIndexWhenGrid(parseInt(slideEl.getAttribute("data-swiper-slide-index"), 10)), 0);
938
+ } else {
939
+ swiper.slideTo(swiper.getSlideIndexWhenGrid(swiper.slides.indexOf(slideEl)), 0);
940
+ }
941
+ preventFocusHandler = false;
942
+ });
925
943
  };
926
944
  const initSlides = () => {
927
945
  const params = swiper.params.a11y;
@@ -950,11 +968,16 @@ function A11y(_ref) {
950
968
  if (params.containerMessage) {
951
969
  addElLabel(containerEl, params.containerMessage);
952
970
  }
971
+ if (params.containerRole) {
972
+ addElRole(containerEl, params.containerRole);
973
+ }
953
974
  const wrapperEl = swiper.wrapperEl;
954
975
  const wrapperId = params.id || wrapperEl.getAttribute("id") || `swiper-wrapper-${getRandomNumber(16)}`;
955
- const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? "off" : "polite";
956
976
  addElId(wrapperEl, wrapperId);
957
- addElLive(wrapperEl, live);
977
+ if (params.wrapperLiveRegion) {
978
+ const live = swiper.params.autoplay && swiper.params.autoplay.enabled ? "off" : "polite";
979
+ addElLive(wrapperEl, live);
980
+ }
958
981
  initSlides();
959
982
  let {
960
983
  nextEl,
@@ -969,11 +992,13 @@ function A11y(_ref) {
969
992
  prevEl.forEach((el) => initNavEl(el, wrapperId, params.prevSlideMessage));
970
993
  }
971
994
  if (hasClickablePagination()) {
972
- const paginationEl = Array.isArray(swiper.pagination.el) ? swiper.pagination.el : [swiper.pagination.el];
995
+ const paginationEl = makeElementsArray(swiper.pagination.el);
973
996
  paginationEl.forEach((el) => {
974
997
  el.addEventListener("keydown", onEnterOrSpaceKey);
975
998
  });
976
999
  }
1000
+ const document2 = getDocument();
1001
+ document2.addEventListener("visibilitychange", onVisibilityChange);
977
1002
  swiper.el.addEventListener("focus", handleFocus, true);
978
1003
  swiper.el.addEventListener("pointerdown", handlePointerDown, true);
979
1004
  swiper.el.addEventListener("pointerup", handlePointerUp, true);
@@ -993,14 +1018,18 @@ function A11y(_ref) {
993
1018
  prevEl.forEach((el) => el.removeEventListener("keydown", onEnterOrSpaceKey));
994
1019
  }
995
1020
  if (hasClickablePagination()) {
996
- const paginationEl = Array.isArray(swiper.pagination.el) ? swiper.pagination.el : [swiper.pagination.el];
1021
+ const paginationEl = makeElementsArray(swiper.pagination.el);
997
1022
  paginationEl.forEach((el) => {
998
1023
  el.removeEventListener("keydown", onEnterOrSpaceKey);
999
1024
  });
1000
1025
  }
1001
- swiper.el.removeEventListener("focus", handleFocus, true);
1002
- swiper.el.removeEventListener("pointerdown", handlePointerDown, true);
1003
- swiper.el.removeEventListener("pointerup", handlePointerUp, true);
1026
+ const document2 = getDocument();
1027
+ document2.removeEventListener("visibilitychange", onVisibilityChange);
1028
+ if (swiper.el && typeof swiper.el !== "string") {
1029
+ swiper.el.removeEventListener("focus", handleFocus, true);
1030
+ swiper.el.removeEventListener("pointerdown", handlePointerDown, true);
1031
+ swiper.el.removeEventListener("pointerup", handlePointerUp, true);
1032
+ }
1004
1033
  }
1005
1034
  on("beforeInit", () => {
1006
1035
  liveRegion = createElement("span", swiper.params.a11y.notificationClass);
@@ -1030,14 +1059,13 @@ function A11y(_ref) {
1030
1059
  }
1031
1060
 
1032
1061
  // node_modules/swiper/modules/autoplay.mjs
1033
- function Autoplay(_ref) {
1034
- let {
1035
- swiper,
1036
- extendParams,
1037
- on,
1038
- emit,
1039
- params
1040
- } = _ref;
1062
+ function Autoplay({
1063
+ swiper,
1064
+ extendParams,
1065
+ on,
1066
+ emit,
1067
+ params
1068
+ }) {
1041
1069
  swiper.autoplay = {
1042
1070
  running: false,
1043
1071
  paused: false,
@@ -1048,7 +1076,7 @@ function Autoplay(_ref) {
1048
1076
  enabled: false,
1049
1077
  delay: 3e3,
1050
1078
  waitForTransition: true,
1051
- disableOnInteraction: true,
1079
+ disableOnInteraction: false,
1052
1080
  stopOnLastSlide: false,
1053
1081
  reverseDirection: false,
1054
1082
  pauseOnMouseEnter: false
@@ -1059,17 +1087,20 @@ function Autoplay(_ref) {
1059
1087
  let autoplayDelayTotal = params && params.autoplay ? params.autoplay.delay : 3e3;
1060
1088
  let autoplayDelayCurrent = params && params.autoplay ? params.autoplay.delay : 3e3;
1061
1089
  let autoplayTimeLeft;
1062
- let autoplayStartTime = (/* @__PURE__ */ new Date()).getTime;
1090
+ let autoplayStartTime = (/* @__PURE__ */ new Date()).getTime();
1063
1091
  let wasPaused;
1064
1092
  let isTouched;
1065
1093
  let pausedByTouch;
1066
1094
  let touchStartTimeout;
1067
- let slideChanged;
1068
1095
  let pausedByInteraction;
1096
+ let pausedByPointerEnter;
1069
1097
  function onTransitionEnd(e) {
1070
1098
  if (!swiper || swiper.destroyed || !swiper.wrapperEl) return;
1071
1099
  if (e.target !== swiper.wrapperEl) return;
1072
1100
  swiper.wrapperEl.removeEventListener("transitionend", onTransitionEnd);
1101
+ if (pausedByPointerEnter || e.detail && e.detail.bySwiperTouchMove) {
1102
+ return;
1103
+ }
1073
1104
  resume();
1074
1105
  }
1075
1106
  const calcTimeLeft = () => {
@@ -1090,7 +1121,7 @@ function Autoplay(_ref) {
1090
1121
  const getSlideDelay = () => {
1091
1122
  let activeSlideEl;
1092
1123
  if (swiper.virtual && swiper.params.virtual.enabled) {
1093
- activeSlideEl = swiper.slides.filter((slideEl) => slideEl.classList.contains("swiper-slide-active"))[0];
1124
+ activeSlideEl = swiper.slides.find((slideEl) => slideEl.classList.contains("swiper-slide-active"));
1094
1125
  } else {
1095
1126
  activeSlideEl = swiper.slides[swiper.activeIndex];
1096
1127
  }
@@ -1098,18 +1129,23 @@ function Autoplay(_ref) {
1098
1129
  const currentSlideDelay = parseInt(activeSlideEl.getAttribute("data-swiper-autoplay"), 10);
1099
1130
  return currentSlideDelay;
1100
1131
  };
1132
+ const getTotalDelay = () => {
1133
+ let totalDelay = swiper.params.autoplay.delay;
1134
+ const currentSlideDelay = getSlideDelay();
1135
+ if (!Number.isNaN(currentSlideDelay) && currentSlideDelay > 0) {
1136
+ totalDelay = currentSlideDelay;
1137
+ }
1138
+ return totalDelay;
1139
+ };
1101
1140
  const run = (delayForce) => {
1102
1141
  if (swiper.destroyed || !swiper.autoplay.running) return;
1103
1142
  cancelAnimationFrame(raf);
1104
1143
  calcTimeLeft();
1105
- let delay = typeof delayForce === "undefined" ? swiper.params.autoplay.delay : delayForce;
1106
- autoplayDelayTotal = swiper.params.autoplay.delay;
1107
- autoplayDelayCurrent = swiper.params.autoplay.delay;
1108
- const currentSlideDelay = getSlideDelay();
1109
- if (!Number.isNaN(currentSlideDelay) && currentSlideDelay > 0 && typeof delayForce === "undefined") {
1110
- delay = currentSlideDelay;
1111
- autoplayDelayTotal = currentSlideDelay;
1112
- autoplayDelayCurrent = currentSlideDelay;
1144
+ let delay = delayForce;
1145
+ if (typeof delay === "undefined") {
1146
+ delay = getTotalDelay();
1147
+ autoplayDelayTotal = delay;
1148
+ autoplayDelayCurrent = delay;
1113
1149
  }
1114
1150
  autoplayTimeLeft = delay;
1115
1151
  const speed = swiper.params.speed;
@@ -1152,6 +1188,7 @@ function Autoplay(_ref) {
1152
1188
  return delay;
1153
1189
  };
1154
1190
  const start = () => {
1191
+ autoplayStartTime = (/* @__PURE__ */ new Date()).getTime();
1155
1192
  swiper.autoplay.running = true;
1156
1193
  run();
1157
1194
  emit("autoplayStart");
@@ -1178,10 +1215,6 @@ function Autoplay(_ref) {
1178
1215
  };
1179
1216
  swiper.autoplay.paused = true;
1180
1217
  if (reset) {
1181
- if (slideChanged) {
1182
- autoplayTimeLeft = swiper.params.autoplay.delay;
1183
- }
1184
- slideChanged = false;
1185
1218
  proceed();
1186
1219
  return;
1187
1220
  }
@@ -1217,11 +1250,13 @@ function Autoplay(_ref) {
1217
1250
  const onPointerEnter = (e) => {
1218
1251
  if (e.pointerType !== "mouse") return;
1219
1252
  pausedByInteraction = true;
1253
+ pausedByPointerEnter = true;
1220
1254
  if (swiper.animating || swiper.autoplay.paused) return;
1221
1255
  pause(true);
1222
1256
  };
1223
1257
  const onPointerLeave = (e) => {
1224
1258
  if (e.pointerType !== "mouse") return;
1259
+ pausedByPointerEnter = false;
1225
1260
  if (swiper.autoplay.paused) {
1226
1261
  resume();
1227
1262
  }
@@ -1233,8 +1268,10 @@ function Autoplay(_ref) {
1233
1268
  }
1234
1269
  };
1235
1270
  const detachMouseEvents = () => {
1236
- swiper.el.removeEventListener("pointerenter", onPointerEnter);
1237
- swiper.el.removeEventListener("pointerleave", onPointerLeave);
1271
+ if (swiper.el && typeof swiper.el !== "string") {
1272
+ swiper.el.removeEventListener("pointerenter", onPointerEnter);
1273
+ swiper.el.removeEventListener("pointerleave", onPointerLeave);
1274
+ }
1238
1275
  };
1239
1276
  const attachDocumentEvents = () => {
1240
1277
  const document2 = getDocument();
@@ -1248,7 +1285,6 @@ function Autoplay(_ref) {
1248
1285
  if (swiper.params.autoplay.enabled) {
1249
1286
  attachMouseEvents();
1250
1287
  attachDocumentEvents();
1251
- autoplayStartTime = (/* @__PURE__ */ new Date()).getTime();
1252
1288
  start();
1253
1289
  }
1254
1290
  });
@@ -1259,6 +1295,18 @@ function Autoplay(_ref) {
1259
1295
  stop();
1260
1296
  }
1261
1297
  });
1298
+ on("_freeModeStaticRelease", () => {
1299
+ if (pausedByTouch || pausedByInteraction) {
1300
+ resume();
1301
+ }
1302
+ });
1303
+ on("_freeModeNoMomentumRelease", () => {
1304
+ if (!swiper.params.autoplay.disableOnInteraction) {
1305
+ pause(true, true);
1306
+ } else {
1307
+ stop();
1308
+ }
1309
+ });
1262
1310
  on("beforeTransitionStart", (_s, speed, internal) => {
1263
1311
  if (swiper.destroyed || !swiper.autoplay.running) return;
1264
1312
  if (internal || !swiper.params.autoplay.disableOnInteraction) {
@@ -1297,7 +1345,10 @@ function Autoplay(_ref) {
1297
1345
  });
1298
1346
  on("slideChange", () => {
1299
1347
  if (swiper.destroyed || !swiper.autoplay.running) return;
1300
- slideChanged = true;
1348
+ if (swiper.autoplay.paused) {
1349
+ autoplayTimeLeft = getTotalDelay();
1350
+ autoplayDelayTotal = getTotalDelay();
1351
+ }
1301
1352
  });
1302
1353
  Object.assign(swiper.autoplay, {
1303
1354
  start,