react-spring-carousel 3.0.0-beta-2.0.97 → 3.0.0-beta-2.0.99
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/dist/index.es.js +591 -587
- package/dist/index.umd.js +5 -5
- package/package.json +2 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(N,M){typeof exports=="object"&&typeof module<"u"?M(exports,require("react/jsx-runtime"),require("@react-spring/web"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@react-spring/web","react"],M):(N=typeof globalThis<"u"?globalThis:N||self,M(N["react-spring-carousel"]={},N["react/jsx-runtime"],N["@react-spring/web"],N.React))})(this,function(N,M,X,m){"use strict";function $e(t,e,r){return Math.max(e,Math.min(t,r))}const b={toVector(t,e){return t===void 0&&(t=e),Array.isArray(t)?t:[t,t]},add(t,e){return[t[0]+e[0],t[1]+e[1]]},sub(t,e){return[t[0]-e[0],t[1]-e[1]]},addTo(t,e){t[0]+=e[0],t[1]+=e[1]},subTo(t,e){t[0]-=e[0],t[1]-=e[1]}};function ie(t,e,r){return e===0||Math.abs(e)===1/0?Math.pow(t,r*5):t*e*r/(e+r*t)}function oe(t,e,r,n=.15){return n===0?$e(t,e,r):t<e?-ie(e-t,r-e,n)+e:t>r?+ie(t-r,r-e,n)+r:t}function Pe(t,[e,r],[n,s]){const[[o,a],[c,l]]=t;return[oe(e,o,a,n),oe(r,c,l,s)]}function Oe(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ae(t){var e=Oe(t,"string");return typeof e=="symbol"?e:String(e)}function I(t,e,r){return e=Ae(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ae(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ae(Object(r),!0).forEach(function(n){I(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ae(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}const ce={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function ue(t){return t?t[0].toUpperCase()+t.slice(1):""}const Ne=["enter","leave"];function Le(t=!1,e){return t&&!Ne.includes(e)}function Me(t,e="",r=!1){const n=ce[t],s=n&&n[e]||e;return"on"+ue(t)+ue(s)+(Le(r,s)?"Capture":"")}const Ve=["gotpointercapture","lostpointercapture"];function je(t){let e=t.substring(2).toLowerCase();const r=!!~e.indexOf("passive");r&&(e=e.replace("passive",""));const n=Ve.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:r}}function Re(t,e=""){const r=ce[t],n=r&&r[e]||e;return t+n}function z(t){return"touches"in t}function le(t){return z(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function Be(t){return Array.from(t.touches).filter(e=>{var r,n;return e.target===t.currentTarget||((r=t.currentTarget)===null||r===void 0||(n=r.contains)===null||n===void 0?void 0:n.call(r,e.target))})}function Ue(t){return t.type==="touchend"||t.type==="touchcancel"?t.changedTouches:t.targetTouches}function fe(t){return z(t)?Ue(t)[0]:t}function Ke(t){return Be(t).map(e=>e.identifier)}function q(t){const e=fe(t);return z(t)?e.identifier:e.pointerId}function de(t){const e=fe(t);return[e.clientX,e.clientY]}function Ge(t){const e={};if("buttons"in t&&(e.buttons=t.buttons),"shiftKey"in t){const{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o}=t;Object.assign(e,{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o})}return e}function W(t,...e){return typeof t=="function"?t(...e):t}function ze(){}function We(...t){return t.length===0?ze:t.length===1?t[0]:function(){let e;for(const r of t)e=r.apply(this,arguments)||e;return e}}function he(t,e){return Object.assign({},e,t||{})}const Ye=32;class Fe{constructor(e,r,n){this.ctrl=e,this.args=r,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:r,ingKey:n,args:s}=this;r[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=s,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const r=this.state,n=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=e.target,r.currentTarget=e.currentTarget,r.lastOffset=n.from?W(n.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=e.timeStamp)}computeValues(e){const r=this.state;r._values=e,r.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:r,config:n,shared:s}=this;r.args=this.args;let o=0;if(e&&(r.event=e,n.preventDefault&&e.cancelable&&r.event.preventDefault(),r.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,Ge(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,o=e.timeStamp-r.timeStamp,r.timeStamp=e.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const A=r._delta.map(Math.abs);b.addTo(r._distance,A)}this.axisIntent&&this.axisIntent(e);const[a,c]=r._movement,[l,d]=n.threshold,{_step:u,values:w}=r;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(a)>=l&&w[0]),u[1]===!1&&(u[1]=Math.abs(c)>=d&&w[1])):(u[0]===!1&&(u[0]=Math.abs(a)>=l&&Math.sign(a)*l),u[1]===!1&&(u[1]=Math.abs(c)>=d&&Math.sign(c)*d)),r.intentional=u[0]!==!1||u[1]!==!1,!r.intentional)return;const g=[0,0];if(n.hasCustomTransform){const[A,h]=w;g[0]=u[0]!==!1?A-u[0]:0,g[1]=u[1]!==!1?h-u[1]:0}else g[0]=u[0]!==!1?a-u[0]:0,g[1]=u[1]!==!1?c-u[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(g);const C=r.offset,P=r._active&&!r._blocked||r.active;P&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=s[this.ingKey]=r._active,e&&(r.first&&("bounds"in n&&(r._bounds=W(n.bounds,r)),this.setup&&this.setup()),r.movement=g,this.computeOffset()));const[O,E]=r.offset,[[x,V],[v,k]]=r._bounds;r.overflow=[O<x?-1:O>V?1:0,E<v?-1:E>k?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const L=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=Pe(r._bounds,r.offset,L),r.delta=b.sub(r.offset,C),this.computeMovement(),P&&(!r.last||o>Ye)){r.delta=b.sub(r.offset,C);const A=r.delta.map(Math.abs);b.addTo(r.distance,A),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&o>0&&(r.velocity=[A[0]/o,A[1]/o],r.timeDelta=o)}}emit(){const e=this.state,r=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(p(p(p({},r),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function He([t,e],r){const n=Math.abs(t),s=Math.abs(e);if(n>s&&n>r)return"x";if(s>n&&s>r)return"y"}class Xe extends Fe{constructor(...e){super(...e),I(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=b.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=b.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const r=this.state,n=this.config;if(!r.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[le(e)]:n.axisThreshold;r.axis=He(r._movement,s)}r._blocked=(n.lockDirection||!!n.axis)&&!r.axis||!!n.axis&&n.axis!==r.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const pe=t=>t,me=.15,J={enabled(t=!0){return t},eventOptions(t,e,r){return p(p({},r.shared.eventOptions),t)},preventDefault(t=!1){return t},triggerAllEvents(t=!1){return t},rubberband(t=0){switch(t){case!0:return[me,me];case!1:return[0,0];default:return b.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return b.toVector(t)},transform(t,e,r){const n=t||r.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||pe;return o=>{const a=s(o);return(!isFinite(a[0])||!isFinite(a[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${a[0]},${[1]}]`),a}}return n||pe},threshold(t){return b.toVector(t,0)}};process.env.NODE_ENV==="development"&&Object.assign(J,{domTarget(t){if(t!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(t){if(t!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(t){if(t!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const qe=0,K=p(p({},J),{},{axis(t,e,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(t=qe){return t},bounds(t={}){if(typeof t=="function")return o=>K.bounds(t(o));if("current"in t)return()=>t.current;if(typeof HTMLElement=="function"&&t instanceof HTMLElement)return t;const{left:e=-1/0,right:r=1/0,top:n=-1/0,bottom:s=1/0}=t;return[[e,r],[n,s]]}}),ge={ArrowRight:(t,e=1)=>[t*e,0],ArrowLeft:(t,e=1)=>[-1*t*e,0],ArrowUp:(t,e=1)=>[0,-1*t*e],ArrowDown:(t,e=1)=>[0,t*e]};class Je extends Xe{constructor(...e){super(...e),I(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const r=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:r.left-n.left+e.offset[0],right:r.right-n.right+e.offset[0],top:r.top-n.top+e.offset[1],bottom:r.bottom-n.bottom+e.offset[1]};e._bounds=K.bounds(s)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const r=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(r.pointerButtons)?!r.pointerButtons.includes(e.buttons):r.pointerButtons!==-1&&r.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);r.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=q(e),n._pointerActive=!0,this.computeValues(de(e)),this.computeInitial(),r.preventScrollAxis&&le(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):r.delay>0?(this.setupDelayTrigger(e),r.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const r=this.state;r._active=!0,r._preventScroll=!0,r._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const r=this.state,n=this.config;if(!r._pointerActive)return;const s=q(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;const o=de(e);if(document.pointerLockElement===e.target?r._delta=[e.movementX,e.movementY]:(r._delta=b.sub(o,r._values),this.computeValues(o)),b.addTo(r._movement,r._delta),this.compute(e),r._delayed&&r.intentional){this.timeoutStore.remove("dragDelay"),r.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!r._preventScroll)if(r.axis)if(r.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){r._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{process.env.NODE_ENV==="development"&&console.warn("[@use-gesture]: If you see this message, it's likely that you're using an outdated version of `@react-three/fiber`. \n\nPlease upgrade to the latest version.")}const r=this.state,n=this.config;if(!r._active||!r._pointerActive)return;const s=q(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,a]=r._distance;if(r.tap=o<=n.tapsThreshold&&a<=n.tapsThreshold,r.tap&&n.filterTaps)r._force=!0;else{const[c,l]=r._delta,[d,u]=r._movement,[w,g]=n.swipe.velocity,[C,P]=n.swipe.distance,O=n.swipe.duration;if(r.elapsedTime<O){const E=Math.abs(c/r.timeDelta),x=Math.abs(l/r.timeDelta);E>w&&Math.abs(d)>C&&(r.swipe[0]=Math.sign(c)),x>g&&Math.abs(u)>P&&(r.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const r=this.config,n=r.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&r.preventScrollDelay===void 0){const s="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(s).touchAction==="auto"&&console.warn("[@use-gesture]: The drag target has its `touch-action` style property set to `auto`. It is recommended to add `touch-action: 'none'` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.",s)}}catch{}r.pointerLock&&e.currentTarget.requestPointerLock(),r.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,Qe(e);const r=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",r),this.eventStore.add(this.sharedConfig.window,"touch","cancel",r),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const r=ge[e.key];if(r){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=r(this.config.keyboardDisplacement,s),n._keyboardActive=!0,b.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in ge&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const r=this.config.device;e(r,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(r,"change",this.pointerMove.bind(this)),e(r,"end",this.pointerUp.bind(this)),e(r,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function Qe(t){"persist"in t&&typeof t.persist=="function"&&t.persist()}const G=typeof window<"u"&&window.document&&window.document.createElement;function ve(){return G&&"ontouchstart"in window}function Ze(){return ve()||G&&window.navigator.maxTouchPoints>1}function et(){return G&&"onpointerdown"in window}function tt(){return G&&"exitPointerLock"in window.document}function rt(){try{return"constructor"in GestureEvent}catch{return!1}}const $={isBrowser:G,gesture:rt(),touch:ve(),touchscreen:Ze(),pointer:et(),pointerLock:tt()},nt=250,st=180,it=.5,ot=50,at=250,ct=10,ye={mouse:0,touch:0,pen:8},be=p(p({},K),{},{device(t,e,{pointer:{touch:r=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&$.pointerLock,$.touch&&r?"touch":this.pointerLock?"mouse":$.pointer&&!s?"pointer":$.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&t?nt:void 0,!(!$.touchscreen||r===!1))return t||(r!==void 0?"y":void 0)},pointerCapture(t,e,{pointer:{capture:r=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&r},threshold(t,e,{filterTaps:r=!1,tapsThreshold:n=3,axis:s=void 0}){const o=b.toVector(t,r?n:s?1:0);return this.filterTaps=r,this.tapsThreshold=n,o},swipe({velocity:t=it,distance:e=ot,duration:r=at}={}){return{velocity:this.transform(b.toVector(t)),distance:this.transform(b.toVector(e)),duration:r}},delay(t=0){switch(t){case!0:return st;case!1:return 0;default:return t}},axisThreshold(t){return t?p(p({},ye),t):ye},keyboardDisplacement(t=ct){return t}});process.env.NODE_ENV==="development"&&Object.assign(be,{useTouch(t){if(t!==void 0)throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");return NaN},experimental_preventWindowScrollY(t){if(t!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");return NaN},swipeDistance(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),p(p({},J),{},{device(t,e,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!$.touch&&$.gesture)return"gesture";if($.touch&&n)return"touch";if($.touchscreen){if($.pointer)return"pointer";if($.touch)return"touch"}},bounds(t,e,{scaleBounds:r={},angleBounds:n={}}){const s=a=>{const c=he(W(r,a),{min:-1/0,max:1/0});return[c.min,c.max]},o=a=>{const c=he(W(n,a),{min:-1/0,max:1/0});return[c.min,c.max]};return typeof r!="function"&&typeof n!="function"?[s(),o()]:a=>[s(a),o(a)]},threshold(t,e,r){return this.lockDirection=r.axis==="lock",b.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}}),p(p({},K),{},{mouseOnly:(t=!0)=>t}),p(p({},K),{},{mouseOnly:(t=!0)=>t});const _e=new Map,Q=new Map;function ut(t){_e.set(t.key,t.engine),Q.set(t.key,t.resolver)}const lt={key:"drag",engine:Je,resolver:be};function ft(t,e){if(t==null)return{};var r={},n=Object.keys(t),s,o;for(o=0;o<n.length;o++)s=n[o],!(e.indexOf(s)>=0)&&(r[s]=t[s]);return r}function dt(t,e){if(t==null)return{};var r=ft(t,e),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(s=0;s<o.length;s++)n=o[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}const ht={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=$.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},pt=["target","eventOptions","window","enabled","transform"];function Y(t={},e){const r={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const o=s.call(r,t[n],n,t);Number.isNaN(o)||(r[n]=o)}else r[n]=s.call(r,t[n],n,t);break;case"object":r[n]=Y(t[n],s);break;case"boolean":s&&(r[n]=t[n]);break}return r}function mt(t,e,r={}){const n=t,{target:s,eventOptions:o,window:a,enabled:c,transform:l}=n,d=dt(n,pt);if(r.shared=Y({target:s,eventOptions:o,window:a,enabled:c,transform:l},ht),e){const u=Q.get(e);r[e]=Y(p({shared:r.shared},d),u)}else for(const u in d){const w=Q.get(u);if(w)r[u]=Y(p({shared:r.shared},d[u]),w);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(u)){if(u==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${u}\` was used. Please read the documentation for further information.`)}}return r}class we{constructor(e,r){I(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=r}add(e,r,n,s,o){const a=this._listeners,c=Re(r,n),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},d=p(p({},l),o);e.addEventListener(c,s,d);const u=()=>{e.removeEventListener(c,s,d),a.delete(u)};return a.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class gt{constructor(){I(this,"_timeouts",new Map)}add(e,r,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(r,n,...s))}remove(e){const r=this._timeouts.get(e);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class vt{constructor(e){I(this,"gestures",new Set),I(this,"_targetEventStore",new we(this)),I(this,"gestureEventStores",{}),I(this,"gestureTimeoutStores",{}),I(this,"handlers",{}),I(this,"config",{}),I(this,"pointerIds",new Set),I(this,"touchIds",new Set),I(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),yt(this,e)}setEventIds(e){if(z(e))return this.touchIds=new Set(Ke(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,r){this.handlers=e,this.nativeHandlers=r}applyConfig(e,r){this.config=mt(e,r,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const r=this.config.shared,n={};let s;if(!(r.target&&(s=r.target(),!s))){if(r.enabled){for(const a of this.gestures){const c=this.config[a],l=Ee(n,c.eventOptions,!!s);if(c.enabled){const d=_e.get(a);new d(this,e,a).bind(l)}}const o=Ee(n,r.eventOptions,!!s);for(const a in this.nativeHandlers)o(a,"",c=>this.nativeHandlers[a](p(p({},this.state.shared),{},{event:c,args:e})),void 0,!0)}for(const o in n)n[o]=We(...n[o]);if(!s)return n;for(const o in n){const{device:a,capture:c,passive:l}=je(o);this._targetEventStore.add(s,a,"",n[o],{capture:c,passive:l})}}}}function j(t,e){t.gestures.add(e),t.gestureEventStores[e]=new we(t,e),t.gestureTimeoutStores[e]=new gt}function yt(t,e){e.drag&&j(t,"drag"),e.wheel&&j(t,"wheel"),e.scroll&&j(t,"scroll"),e.move&&j(t,"move"),e.pinch&&j(t,"pinch"),e.hover&&j(t,"hover")}const Ee=(t,e,r)=>(n,s,o,a={},c=!1)=>{var l,d;const u=(l=a.capture)!==null&&l!==void 0?l:e.capture,w=(d=a.passive)!==null&&d!==void 0?d:e.passive;let g=c?n:Me(n,s,u);r&&w&&(g+="Passive"),t[g]=t[g]||[],t[g].push(o)};function bt(t,e={},r,n){const s=m.useMemo(()=>new vt(t),[]);if(s.applyHandlers(t,n),s.applyConfig(e,r),m.useEffect(s.effect.bind(s)),m.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function _t(t,e){return ut(lt),bt({drag:t},e||{},"drag")}const Z="RSC::Event";function wt(){const t=m.useRef(null);function e(n){m.useEffect(()=>{t.current||(t.current=document.createElement("div"));function s(o){n(o.detail)}if(t.current)return t.current.addEventListener(Z,s,!1),()=>{var o;(o=t.current)==null||o.removeEventListener(Z,s,!1)}},[n])}function r(n){if(t.current){const s=new CustomEvent(Z,{detail:n});t.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:r}}function Et(t){let e=t.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,"");return e=e.replace(/[\n\t]+/g," "),e=e.replace(/\s*([{}:;,])\s*/g,"$1"),e=e.replace(/\s+}/g,"}"),e=e.replace(/{\s+/g,"{"),e=e.replace(/\s+/g," "),e.trim()}function xt({init:t=!0,items:e,withLoop:r=!1,id:n,gutter:s=[{breakpoint:0,gutter:0,startEndGutter:0}],itemsPerSlide:o=[{breakpoint:0,itemsPerSlide:1}],carouselAxis:a="x",startingPosition:c="start",enableGestures:l=!0,slideWhenDragThresholdIsReached:d=!0,onInit:u,slideType:w="item",initialActiveItem:g=0}){const[C,P]=m.useState(!1),O=m.useRef(t),E=m.useRef(null),x=m.useRef(null),V=m.useRef(0),v=m.useRef(0),k=m.useRef(!r),L=m.useRef(!1),A=m.useRef(0),h=m.useRef(0),F=X.useSpringRef(),te=X.useSpring({value:0,ref:F,onChange({value:i}){x.current.style.transform=`translate3d(calc(${i.value}px + var(--${n}-offset-modifier)), 0px, 0px)`}}),It=r?[...e.map(i=>({...i,id:`prev-repeated-item-${i.id}`,isClonedItem:!0})),...e,...e.map(i=>({...i,id:`next-repeated-item-${i.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:Te,emitEvent:H}=wt();function Se(){const{totalGutterCssVar:i}=Ie();return i}function Ct(){if(E.current){const f=window.getComputedStyle(E.current).getPropertyValue(`--${n}-items-per-slide`).trim();return Number(f)||1}return 1}function re(i){O.current&&(L.current||R({type:"next",toIndex:i,actionType:"click"}))}function ne(i){O.current&&(k.current||R({type:"prev",toIndex:i,actionType:"click"}))}function R({type:i,shouldAnimate:f=!0,toIndex:_,actionType:T}){var B,ke;const S=!f;k.current=!1,L.current=!1;let y=te.value.get(),D=0;if(i==="next"&&(h.current+=1),i==="prev"&&(h.current===0?h.current=e.length-1:h.current-=1),_!==void 0&&(h.current=_),i==="next"){const U=se(r?v.current*(e.length*2):0);D=-(h.current*v.current),r&&h.current===e.length&&(h.current=0,y=y+v.current*e.length,D=0),!r&&(Math.abs(D)>=U||h.current===e.length-1)&&(L.current=!0,D=-U)}i==="prev"&&(D=-(h.current*v.current),h.current===e.length-1&&(y=y-e.length*v.current),!r&&D>=0&&(k.current=!0,D=0)),V.current=D,T==="resize"?(D=-(h.current*v.current),H({eventName:"onResize",sliceActionType:T,slideDirection:i,currentItem:{index:h.current,id:((B=e.at(h.current))==null?void 0:B.id)??"",startReached:k.current,endReached:L.current}})):H({eventName:"onSlideStartChange",sliceActionType:T,slideDirection:i,nextItem:{index:h.current,id:((ke=e.at(h.current))==null?void 0:ke.id)??"",startReached:k.current,endReached:L.current}}),F.start({immediate:S,from:{value:y},to:{value:D},onChange({value:U}){x.current.style.transform=`translate3d(calc(${U.value}px + var(--${n}-offset-modifier)), 0px, 0px)`},onRest({finished:U}){var De;U&&H({eventName:"onSlideChangeComplete",sliceActionType:T,slideDirection:i,currentItem:{index:h.current,id:((De=e.at(h.current))==null?void 0:De.id)??"",startReached:k.current,endReached:L.current}})}})}function kt(){const i=x.current;let f=0;return w==="item"?f=i.children[0].getBoundingClientRect()[a==="x"?"width":"height"]+Se():f=i.getBoundingClientRect()[a==="x"?"width":"height"]+Se(),f}function se(i){const f=x.current;return f[a==="x"?"scrollWidth":"scrollHeight"]-f.getBoundingClientRect()[a==="x"?"width":"height"]-i}function Ie(){let i=0,f=0;if(E.current){const _=window.getComputedStyle(E.current),T=_.getPropertyValue(`--${n}-start-end-gutter`).trim();T.includes("px")&&(i=Number(T.replace("px","")));const S=_.getPropertyValue(`--${n}-gutter`).trim();S.includes("px")&&(f=Number(S.replace("px","")))}return{totalStartEndGutterCssVar:i,totalGutterCssVar:f}}m.useEffect(()=>{function i(S){const y=Ct();switch(S){case"start":return 0;case"middle-start":return Math.floor((y-1)*.25);case"center":return Math.floor((y-1)*.5);case"middle-end":return Math.floor((y-1)*.75);case"end":return y-1;default:return 0}}function f(){v.current=kt(),console.log("scrollAmountValue",v.current),A.current=v.current/4;const{totalStartEndGutterCssVar:S}=Ie();let y=0;r&&(y=v.current*e.length),y-=v.current*i(c),y-=S/2,console.log({mod1:v.current*e.length,mod2:v.current*i(c),mod3:S/2}),E.current.style.setProperty(`--${n}-offset-modifier`,`${-y}px`)}function _(S){E.current&&(f(),P(!0),S&&S())}function T(){_(),R({type:"resize",toIndex:h.current,shouldAnimate:!1,actionType:"resize"})}if(t)return O.current=!0,_(u),window.addEventListener("resize",T),()=>{window.removeEventListener("resize",T)}},[t,r,n,a,s,c]),m.useEffect(()=>{t&&g!==h.current&&R({type:"next",toIndex:g,actionType:"resize",shouldAnimate:!1})},[t,g]);const Ce=l,Dt=_t(i=>{if(!O.current)return;const f=i.dragging,_=i.offset[a==="x"?0:1],T=i.movement[a==="x"?0:1],S=T>A.current,y=T<-A.current,D=i.velocity;f&&(H({...i,eventName:"onDrag",slideActionType:"drag"}),F.start({value:_,immediate:!0,config:{velocity:D},onChange({value:B}){x.current.style.transform=`translate3d(calc(${B.value}px + var(--${n}-offset-modifier)), 0px, 0px)`}}),d&&(S||y)&&i.cancel()),i.last&&(S?(R({actionType:"drag",type:"prev"}),i.cancel()):y?(R({actionType:"drag",type:"next"}),i.cancel()):(F.start({value:V.current,config:{velocity:D},onChange({value:B}){x.current.style.transform=`translate3d(calc(${B.value}px + var(--${n}-offset-modifier)), 0px, 0px)`}}),i.cancel()))},{enabled:Ce,axis:a,rubberband:!r,...r?{}:{bounds:()=>({right:0,left:-se(0),top:-se(0),bottom:0})},from:()=>[te.value.get(),te.value.get()]});function $t(i){var f,_;return typeof i=="number"?h.current===i:((f=e.find(T=>T.id===i))==null?void 0:f.id)===((_=e[h.current])==null?void 0:_.id)}return{carouselFragment:M.jsxs("div",{ref:E,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Dt(),children:[M.jsx("style",{dangerouslySetInnerHTML:{__html:Et(`
|
|
1
|
+
(function(N,M){typeof exports=="object"&&typeof module<"u"?M(exports,require("react/jsx-runtime"),require("@react-spring/web"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","@react-spring/web","react"],M):(N=typeof globalThis<"u"?globalThis:N||self,M(N["react-spring-carousel"]={},N["react/jsx-runtime"],N["@react-spring/web"],N.React))})(this,function(N,M,J,m){"use strict";function $e(t,e,r){return Math.max(e,Math.min(t,r))}const b={toVector(t,e){return t===void 0&&(t=e),Array.isArray(t)?t:[t,t]},add(t,e){return[t[0]+e[0],t[1]+e[1]]},sub(t,e){return[t[0]-e[0],t[1]-e[1]]},addTo(t,e){t[0]+=e[0],t[1]+=e[1]},subTo(t,e){t[0]-=e[0],t[1]-=e[1]}};function ae(t,e,r){return e===0||Math.abs(e)===1/0?Math.pow(t,r*5):t*e*r/(e+r*t)}function ce(t,e,r,n=.15){return n===0?$e(t,e,r):t<e?-ae(e-t,r-e,n)+e:t>r?+ae(t-r,r-e,n)+r:t}function Pe(t,[e,r],[n,s]){const[[o,a],[c,f]]=t;return[ce(e,o,a,n),ce(r,c,f,s)]}function Oe(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ae(t){var e=Oe(t,"string");return typeof e=="symbol"?e:String(e)}function I(t,e,r){return e=Ae(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ue(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),r.push.apply(r,n)}return r}function p(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ue(Object(r),!0).forEach(function(n){I(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ue(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}const le={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function fe(t){return t?t[0].toUpperCase()+t.slice(1):""}const Ne=["enter","leave"];function Le(t=!1,e){return t&&!Ne.includes(e)}function Me(t,e="",r=!1){const n=le[t],s=n&&n[e]||e;return"on"+fe(t)+fe(s)+(Le(r,s)?"Capture":"")}const Ve=["gotpointercapture","lostpointercapture"];function je(t){let e=t.substring(2).toLowerCase();const r=!!~e.indexOf("passive");r&&(e=e.replace("passive",""));const n=Ve.includes(e)?"capturecapture":"capture",s=!!~e.indexOf(n);return s&&(e=e.replace("capture","")),{device:e,capture:s,passive:r}}function Re(t,e=""){const r=le[t],n=r&&r[e]||e;return t+n}function W(t){return"touches"in t}function de(t){return W(t)?"touch":"pointerType"in t?t.pointerType:"mouse"}function Be(t){return Array.from(t.touches).filter(e=>{var r,n;return e.target===t.currentTarget||((r=t.currentTarget)===null||r===void 0||(n=r.contains)===null||n===void 0?void 0:n.call(r,e.target))})}function Ue(t){return t.type==="touchend"||t.type==="touchcancel"?t.changedTouches:t.targetTouches}function he(t){return W(t)?Ue(t)[0]:t}function Ke(t){return Be(t).map(e=>e.identifier)}function Q(t){const e=he(t);return W(t)?e.identifier:e.pointerId}function pe(t){const e=he(t);return[e.clientX,e.clientY]}function Ge(t){const e={};if("buttons"in t&&(e.buttons=t.buttons),"shiftKey"in t){const{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o}=t;Object.assign(e,{shiftKey:r,altKey:n,metaKey:s,ctrlKey:o})}return e}function Y(t,...e){return typeof t=="function"?t(...e):t}function ze(){}function We(...t){return t.length===0?ze:t.length===1?t[0]:function(){let e;for(const r of t)e=r.apply(this,arguments)||e;return e}}function me(t,e){return Object.assign({},e,t||{})}const Ye=32;class Fe{constructor(e,r,n){this.ctrl=e,this.args=r,this.key=n,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(e){this.ctrl.state[this.key]=e}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:e,shared:r,ingKey:n,args:s}=this;r[n]=e._active=e.active=e._blocked=e._force=!1,e._step=[!1,!1],e.intentional=!1,e._movement=[0,0],e._distance=[0,0],e._direction=[0,0],e._delta=[0,0],e._bounds=[[-1/0,1/0],[-1/0,1/0]],e.args=s,e.axis=void 0,e.memo=void 0,e.elapsedTime=e.timeDelta=0,e.direction=[0,0],e.distance=[0,0],e.overflow=[0,0],e._movementBound=[!1,!1],e.velocity=[0,0],e.movement=[0,0],e.delta=[0,0],e.timeStamp=0}start(e){const r=this.state,n=this.config;r._active||(this.reset(),this.computeInitial(),r._active=!0,r.target=e.target,r.currentTarget=e.currentTarget,r.lastOffset=n.from?Y(n.from,r):r.offset,r.offset=r.lastOffset,r.startTime=r.timeStamp=e.timeStamp)}computeValues(e){const r=this.state;r._values=e,r.values=this.config.transform(e)}computeInitial(){const e=this.state;e._initial=e._values,e.initial=e.values}compute(e){const{state:r,config:n,shared:s}=this;r.args=this.args;let o=0;if(e&&(r.event=e,n.preventDefault&&e.cancelable&&r.event.preventDefault(),r.type=e.type,s.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,s.locked=!!document.pointerLockElement,Object.assign(s,Ge(e)),s.down=s.pressed=s.buttons%2===1||s.touches>0,o=e.timeStamp-r.timeStamp,r.timeStamp=e.timeStamp,r.elapsedTime=r.timeStamp-r.startTime),r._active){const A=r._delta.map(Math.abs);b.addTo(r._distance,A)}this.axisIntent&&this.axisIntent(e);const[a,c]=r._movement,[f,d]=n.threshold,{_step:u,values:w}=r;if(n.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(a)>=f&&w[0]),u[1]===!1&&(u[1]=Math.abs(c)>=d&&w[1])):(u[0]===!1&&(u[0]=Math.abs(a)>=f&&Math.sign(a)*f),u[1]===!1&&(u[1]=Math.abs(c)>=d&&Math.sign(c)*d)),r.intentional=u[0]!==!1||u[1]!==!1,!r.intentional)return;const g=[0,0];if(n.hasCustomTransform){const[A,h]=w;g[0]=u[0]!==!1?A-u[0]:0,g[1]=u[1]!==!1?h-u[1]:0}else g[0]=u[0]!==!1?a-u[0]:0,g[1]=u[1]!==!1?c-u[1]:0;this.restrictToAxis&&!r._blocked&&this.restrictToAxis(g);const C=r.offset,P=r._active&&!r._blocked||r.active;P&&(r.first=r._active&&!r.active,r.last=!r._active&&r.active,r.active=s[this.ingKey]=r._active,e&&(r.first&&("bounds"in n&&(r._bounds=Y(n.bounds,r)),this.setup&&this.setup()),r.movement=g,this.computeOffset()));const[O,x]=r.offset,[[E,j],[v,k]]=r._bounds;r.overflow=[O<E?-1:O>j?1:0,x<v?-1:x>k?1:0],r._movementBound[0]=r.overflow[0]?r._movementBound[0]===!1?r._movement[0]:r._movementBound[0]:!1,r._movementBound[1]=r.overflow[1]?r._movementBound[1]===!1?r._movement[1]:r._movementBound[1]:!1;const L=r._active?n.rubberband||[0,0]:[0,0];if(r.offset=Pe(r._bounds,r.offset,L),r.delta=b.sub(r.offset,C),this.computeMovement(),P&&(!r.last||o>Ye)){r.delta=b.sub(r.offset,C);const A=r.delta.map(Math.abs);b.addTo(r.distance,A),r.direction=r.delta.map(Math.sign),r._direction=r._delta.map(Math.sign),!r.first&&o>0&&(r.velocity=[A[0]/o,A[1]/o],r.timeDelta=o)}}emit(){const e=this.state,r=this.shared,n=this.config;if(e._active||this.clean(),(e._blocked||!e.intentional)&&!e._force&&!n.triggerAllEvents)return;const s=this.handler(p(p(p({},r),e),{},{[this.aliasKey]:e.values}));s!==void 0&&(e.memo=s)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function He([t,e],r){const n=Math.abs(t),s=Math.abs(e);if(n>s&&n>r)return"x";if(s>n&&s>r)return"y"}class Xe extends Fe{constructor(...e){super(...e),I(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=b.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=b.sub(this.state.offset,this.state.lastOffset)}axisIntent(e){const r=this.state,n=this.config;if(!r.axis&&e){const s=typeof n.axisThreshold=="object"?n.axisThreshold[de(e)]:n.axisThreshold;r.axis=He(r._movement,s)}r._blocked=(n.lockDirection||!!n.axis)&&!r.axis||!!n.axis&&n.axis!==r.axis}restrictToAxis(e){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":e[1]=0;break;case"y":e[0]=0;break}}}const ge=t=>t,ve=.15,Z={enabled(t=!0){return t},eventOptions(t,e,r){return p(p({},r.shared.eventOptions),t)},preventDefault(t=!1){return t},triggerAllEvents(t=!1){return t},rubberband(t=0){switch(t){case!0:return[ve,ve];case!1:return[0,0];default:return b.toVector(t)}},from(t){if(typeof t=="function")return t;if(t!=null)return b.toVector(t)},transform(t,e,r){const n=t||r.shared.transform;if(this.hasCustomTransform=!!n,process.env.NODE_ENV==="development"){const s=n||ge;return o=>{const a=s(o);return(!isFinite(a[0])||!isFinite(a[1]))&&console.warn(`[@use-gesture]: config.transform() must produce a valid result, but it was: [${a[0]},${[1]}]`),a}}return n||ge},threshold(t){return b.toVector(t,0)}};process.env.NODE_ENV==="development"&&Object.assign(Z,{domTarget(t){if(t!==void 0)throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");return NaN},lockDirection(t){if(t!==void 0)throw Error("[@use-gesture]: `lockDirection` option has been merged with `axis`. Use it as in `{ axis: 'lock' }`");return NaN},initial(t){if(t!==void 0)throw Error("[@use-gesture]: `initial` option has been renamed to `from`.");return NaN}});const qe=0,G=p(p({},Z),{},{axis(t,e,{axis:r}){if(this.lockDirection=r==="lock",!this.lockDirection)return r},axisThreshold(t=qe){return t},bounds(t={}){if(typeof t=="function")return o=>G.bounds(t(o));if("current"in t)return()=>t.current;if(typeof HTMLElement=="function"&&t instanceof HTMLElement)return t;const{left:e=-1/0,right:r=1/0,top:n=-1/0,bottom:s=1/0}=t;return[[e,r],[n,s]]}}),ye={ArrowRight:(t,e=1)=>[t*e,0],ArrowLeft:(t,e=1)=>[-1*t*e,0],ArrowUp:(t,e=1)=>[0,-1*t*e],ArrowDown:(t,e=1)=>[0,t*e]};class Je extends Xe{constructor(...e){super(...e),I(this,"ingKey","dragging")}reset(){super.reset();const e=this.state;e._pointerId=void 0,e._pointerActive=!1,e._keyboardActive=!1,e._preventScroll=!1,e._delayed=!1,e.swipe=[0,0],e.tap=!1,e.canceled=!1,e.cancel=this.cancel.bind(this)}setup(){const e=this.state;if(e._bounds instanceof HTMLElement){const r=e._bounds.getBoundingClientRect(),n=e.currentTarget.getBoundingClientRect(),s={left:r.left-n.left+e.offset[0],right:r.right-n.right+e.offset[0],top:r.top-n.top+e.offset[1],bottom:r.bottom-n.bottom+e.offset[1]};e._bounds=G.bounds(s)}}cancel(){const e=this.state;e.canceled||(e.canceled=!0,e._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(e){const r=this.config,n=this.state;if(e.buttons!=null&&(Array.isArray(r.pointerButtons)?!r.pointerButtons.includes(e.buttons):r.pointerButtons!==-1&&r.pointerButtons!==e.buttons))return;const s=this.ctrl.setEventIds(e);r.pointerCapture&&e.target.setPointerCapture(e.pointerId),!(s&&s.size>1&&n._pointerActive)&&(this.start(e),this.setupPointer(e),n._pointerId=Q(e),n._pointerActive=!0,this.computeValues(pe(e)),this.computeInitial(),r.preventScrollAxis&&de(e)!=="mouse"?(n._active=!1,this.setupScrollPrevention(e)):r.delay>0?(this.setupDelayTrigger(e),r.triggerAllEvents&&(this.compute(e),this.emit())):this.startPointerDrag(e))}startPointerDrag(e){const r=this.state;r._active=!0,r._preventScroll=!0,r._delayed=!1,this.compute(e),this.emit()}pointerMove(e){const r=this.state,n=this.config;if(!r._pointerActive)return;const s=Q(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;const o=pe(e);if(document.pointerLockElement===e.target?r._delta=[e.movementX,e.movementY]:(r._delta=b.sub(o,r._values),this.computeValues(o)),b.addTo(r._movement,r._delta),this.compute(e),r._delayed&&r.intentional){this.timeoutStore.remove("dragDelay"),r.active=!1,this.startPointerDrag(e);return}if(n.preventScrollAxis&&!r._preventScroll)if(r.axis)if(r.axis===n.preventScrollAxis||n.preventScrollAxis==="xy"){r._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(e);return}else return;this.emit()}pointerUp(e){this.ctrl.setEventIds(e);try{this.config.pointerCapture&&e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId)}catch{process.env.NODE_ENV==="development"&&console.warn("[@use-gesture]: If you see this message, it's likely that you're using an outdated version of `@react-three/fiber`. \n\nPlease upgrade to the latest version.")}const r=this.state,n=this.config;if(!r._active||!r._pointerActive)return;const s=Q(e);if(r._pointerId!==void 0&&s!==r._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(e);const[o,a]=r._distance;if(r.tap=o<=n.tapsThreshold&&a<=n.tapsThreshold,r.tap&&n.filterTaps)r._force=!0;else{const[c,f]=r._delta,[d,u]=r._movement,[w,g]=n.swipe.velocity,[C,P]=n.swipe.distance,O=n.swipe.duration;if(r.elapsedTime<O){const x=Math.abs(c/r.timeDelta),E=Math.abs(f/r.timeDelta);x>w&&Math.abs(d)>C&&(r.swipe[0]=Math.sign(c)),E>g&&Math.abs(u)>P&&(r.swipe[1]=Math.sign(f))}}this.emit()}pointerClick(e){!this.state.tap&&e.detail>0&&(e.preventDefault(),e.stopPropagation())}setupPointer(e){const r=this.config,n=r.device;if(process.env.NODE_ENV==="development")try{if(n==="pointer"&&r.preventScrollDelay===void 0){const s="uv"in e?e.sourceEvent.currentTarget:e.currentTarget;window.getComputedStyle(s).touchAction==="auto"&&console.warn("[@use-gesture]: The drag target has its `touch-action` style property set to `auto`. It is recommended to add `touch-action: 'none'` so that the drag gesture behaves correctly on touch-enabled devices. For more information read this: https://use-gesture.netlify.app/docs/extras/#touch-action.\n\nThis message will only show in development mode. It won't appear in production. If this is intended, you can ignore it.",s)}}catch{}r.pointerLock&&e.currentTarget.requestPointerLock(),r.pointerCapture||(this.eventStore.add(this.sharedConfig.window,n,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,n,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(e){this.state._preventScroll&&e.cancelable&&e.preventDefault()}setupScrollPrevention(e){this.state._preventScroll=!1,Qe(e);const r=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",r),this.eventStore.add(this.sharedConfig.window,"touch","cancel",r),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,e)}setupDelayTrigger(e){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(e)},this.config.delay)}keyDown(e){const r=ye[e.key];if(r){const n=this.state,s=e.shiftKey?10:e.altKey?.1:1;this.start(e),n._delta=r(this.config.keyboardDisplacement,s),n._keyboardActive=!0,b.addTo(n._movement,n._delta),this.compute(e),this.emit()}}keyUp(e){e.key in ye&&(this.state._keyboardActive=!1,this.setActive(),this.compute(e),this.emit())}bind(e){const r=this.config.device;e(r,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(e(r,"change",this.pointerMove.bind(this)),e(r,"end",this.pointerUp.bind(this)),e(r,"cancel",this.pointerUp.bind(this)),e("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(e("key","down",this.keyDown.bind(this)),e("key","up",this.keyUp.bind(this))),this.config.filterTaps&&e("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function Qe(t){"persist"in t&&typeof t.persist=="function"&&t.persist()}const z=typeof window<"u"&&window.document&&window.document.createElement;function be(){return z&&"ontouchstart"in window}function Ze(){return be()||z&&window.navigator.maxTouchPoints>1}function et(){return z&&"onpointerdown"in window}function tt(){return z&&"exitPointerLock"in window.document}function rt(){try{return"constructor"in GestureEvent}catch{return!1}}const $={isBrowser:z,gesture:rt(),touch:be(),touchscreen:Ze(),pointer:et(),pointerLock:tt()},nt=250,st=180,it=.5,ot=50,at=250,ct=10,_e={mouse:0,touch:0,pen:8},we=p(p({},G),{},{device(t,e,{pointer:{touch:r=!1,lock:n=!1,mouse:s=!1}={}}){return this.pointerLock=n&&$.pointerLock,$.touch&&r?"touch":this.pointerLock?"mouse":$.pointer&&!s?"pointer":$.touch?"touch":"mouse"},preventScrollAxis(t,e,{preventScroll:r}){if(this.preventScrollDelay=typeof r=="number"?r:r||r===void 0&&t?nt:void 0,!(!$.touchscreen||r===!1))return t||(r!==void 0?"y":void 0)},pointerCapture(t,e,{pointer:{capture:r=!0,buttons:n=1,keys:s=!0}={}}){return this.pointerButtons=n,this.keys=s,!this.pointerLock&&this.device==="pointer"&&r},threshold(t,e,{filterTaps:r=!1,tapsThreshold:n=3,axis:s=void 0}){const o=b.toVector(t,r?n:s?1:0);return this.filterTaps=r,this.tapsThreshold=n,o},swipe({velocity:t=it,distance:e=ot,duration:r=at}={}){return{velocity:this.transform(b.toVector(t)),distance:this.transform(b.toVector(e)),duration:r}},delay(t=0){switch(t){case!0:return st;case!1:return 0;default:return t}},axisThreshold(t){return t?p(p({},_e),t):_e},keyboardDisplacement(t=ct){return t}});process.env.NODE_ENV==="development"&&Object.assign(we,{useTouch(t){if(t!==void 0)throw Error("[@use-gesture]: `useTouch` option has been renamed to `pointer.touch`. Use it as in `{ pointer: { touch: true } }`.");return NaN},experimental_preventWindowScrollY(t){if(t!==void 0)throw Error("[@use-gesture]: `experimental_preventWindowScrollY` option has been renamed to `preventScroll`.");return NaN},swipeVelocity(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeVelocity` option has been renamed to `swipe.velocity`. Use it as in `{ swipe: { velocity: 0.5 } }`.");return NaN},swipeDistance(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDistance` option has been renamed to `swipe.distance`. Use it as in `{ swipe: { distance: 50 } }`.");return NaN},swipeDuration(t){if(t!==void 0)throw Error("[@use-gesture]: `swipeDuration` option has been renamed to `swipe.duration`. Use it as in `{ swipe: { duration: 250 } }`.");return NaN}}),p(p({},Z),{},{device(t,e,{shared:r,pointer:{touch:n=!1}={}}){if(r.target&&!$.touch&&$.gesture)return"gesture";if($.touch&&n)return"touch";if($.touchscreen){if($.pointer)return"pointer";if($.touch)return"touch"}},bounds(t,e,{scaleBounds:r={},angleBounds:n={}}){const s=a=>{const c=me(Y(r,a),{min:-1/0,max:1/0});return[c.min,c.max]},o=a=>{const c=me(Y(n,a),{min:-1/0,max:1/0});return[c.min,c.max]};return typeof r!="function"&&typeof n!="function"?[s(),o()]:a=>[s(a),o(a)]},threshold(t,e,r){return this.lockDirection=r.axis==="lock",b.toVector(t,this.lockDirection?[.1,3]:0)},modifierKey(t){return t===void 0?"ctrlKey":t},pinchOnWheel(t=!0){return t}}),p(p({},G),{},{mouseOnly:(t=!0)=>t}),p(p({},G),{},{mouseOnly:(t=!0)=>t});const xe=new Map,ee=new Map;function ut(t){xe.set(t.key,t.engine),ee.set(t.key,t.resolver)}const lt={key:"drag",engine:Je,resolver:we};function ft(t,e){if(t==null)return{};var r={},n=Object.keys(t),s,o;for(o=0;o<n.length;o++)s=n[o],!(e.indexOf(s)>=0)&&(r[s]=t[s]);return r}function dt(t,e){if(t==null)return{};var r=ft(t,e),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(s=0;s<o.length;s++)n=o[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}const ht={target(t){if(t)return()=>"current"in t?t.current:t},enabled(t=!0){return t},window(t=$.isBrowser?window:void 0){return t},eventOptions({passive:t=!0,capture:e=!1}={}){return{passive:t,capture:e}},transform(t){return t}},pt=["target","eventOptions","window","enabled","transform"];function F(t={},e){const r={};for(const[n,s]of Object.entries(e))switch(typeof s){case"function":if(process.env.NODE_ENV==="development"){const o=s.call(r,t[n],n,t);Number.isNaN(o)||(r[n]=o)}else r[n]=s.call(r,t[n],n,t);break;case"object":r[n]=F(t[n],s);break;case"boolean":s&&(r[n]=t[n]);break}return r}function mt(t,e,r={}){const n=t,{target:s,eventOptions:o,window:a,enabled:c,transform:f}=n,d=dt(n,pt);if(r.shared=F({target:s,eventOptions:o,window:a,enabled:c,transform:f},ht),e){const u=ee.get(e);r[e]=F(p({shared:r.shared},d),u)}else for(const u in d){const w=ee.get(u);if(w)r[u]=F(p({shared:r.shared},d[u]),w);else if(process.env.NODE_ENV==="development"&&!["drag","pinch","scroll","wheel","move","hover"].includes(u)){if(u==="domTarget")throw Error("[@use-gesture]: `domTarget` option has been renamed to `target`.");console.warn(`[@use-gesture]: Unknown config key \`${u}\` was used. Please read the documentation for further information.`)}}return r}class Ee{constructor(e,r){I(this,"_listeners",new Set),this._ctrl=e,this._gestureKey=r}add(e,r,n,s,o){const a=this._listeners,c=Re(r,n),f=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},d=p(p({},f),o);e.addEventListener(c,s,d);const u=()=>{e.removeEventListener(c,s,d),a.delete(u)};return a.add(u),u}clean(){this._listeners.forEach(e=>e()),this._listeners.clear()}}class gt{constructor(){I(this,"_timeouts",new Map)}add(e,r,n=140,...s){this.remove(e),this._timeouts.set(e,window.setTimeout(r,n,...s))}remove(e){const r=this._timeouts.get(e);r&&window.clearTimeout(r)}clean(){this._timeouts.forEach(e=>void window.clearTimeout(e)),this._timeouts.clear()}}class vt{constructor(e){I(this,"gestures",new Set),I(this,"_targetEventStore",new Ee(this)),I(this,"gestureEventStores",{}),I(this,"gestureTimeoutStores",{}),I(this,"handlers",{}),I(this,"config",{}),I(this,"pointerIds",new Set),I(this,"touchIds",new Set),I(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),yt(this,e)}setEventIds(e){if(W(e))return this.touchIds=new Set(Ke(e)),this.touchIds;if("pointerId"in e)return e.type==="pointerup"||e.type==="pointercancel"?this.pointerIds.delete(e.pointerId):e.type==="pointerdown"&&this.pointerIds.add(e.pointerId),this.pointerIds}applyHandlers(e,r){this.handlers=e,this.nativeHandlers=r}applyConfig(e,r){this.config=mt(e,r,this.config)}clean(){this._targetEventStore.clean();for(const e of this.gestures)this.gestureEventStores[e].clean(),this.gestureTimeoutStores[e].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...e){const r=this.config.shared,n={};let s;if(!(r.target&&(s=r.target(),!s))){if(r.enabled){for(const a of this.gestures){const c=this.config[a],f=Te(n,c.eventOptions,!!s);if(c.enabled){const d=xe.get(a);new d(this,e,a).bind(f)}}const o=Te(n,r.eventOptions,!!s);for(const a in this.nativeHandlers)o(a,"",c=>this.nativeHandlers[a](p(p({},this.state.shared),{},{event:c,args:e})),void 0,!0)}for(const o in n)n[o]=We(...n[o]);if(!s)return n;for(const o in n){const{device:a,capture:c,passive:f}=je(o);this._targetEventStore.add(s,a,"",n[o],{capture:c,passive:f})}}}}function B(t,e){t.gestures.add(e),t.gestureEventStores[e]=new Ee(t,e),t.gestureTimeoutStores[e]=new gt}function yt(t,e){e.drag&&B(t,"drag"),e.wheel&&B(t,"wheel"),e.scroll&&B(t,"scroll"),e.move&&B(t,"move"),e.pinch&&B(t,"pinch"),e.hover&&B(t,"hover")}const Te=(t,e,r)=>(n,s,o,a={},c=!1)=>{var f,d;const u=(f=a.capture)!==null&&f!==void 0?f:e.capture,w=(d=a.passive)!==null&&d!==void 0?d:e.passive;let g=c?n:Me(n,s,u);r&&w&&(g+="Passive"),t[g]=t[g]||[],t[g].push(o)};function bt(t,e={},r,n){const s=m.useMemo(()=>new vt(t),[]);if(s.applyHandlers(t,n),s.applyConfig(e,r),m.useEffect(s.effect.bind(s)),m.useEffect(()=>s.clean.bind(s),[]),e.target===void 0)return s.bind.bind(s)}function _t(t,e){return ut(lt),bt({drag:t},e||{},"drag")}const te="RSC::Event";function wt(){const t=m.useRef(null);function e(n){m.useEffect(()=>{t.current||(t.current=document.createElement("div"));function s(o){n(o.detail)}if(t.current)return t.current.addEventListener(te,s,!1),()=>{var o;(o=t.current)==null||o.removeEventListener(te,s,!1)}},[n])}function r(n){if(t.current){const s=new CustomEvent(te,{detail:n});t.current.dispatchEvent(s)}}return{useListenToCustomEvent:e,emitEvent:r}}function xt(t){let e=t.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,"");return e=e.replace(/[\n\t]+/g," "),e=e.replace(/\s*([{}:;,])\s*/g,"$1"),e=e.replace(/\s+}/g,"}"),e=e.replace(/{\s+/g,"{"),e=e.replace(/\s+/g," "),e.trim()}function Et({init:t=!0,items:e,withLoop:r=!1,id:n,gutter:s=[{breakpoint:0,gutter:0,startEndGutter:0}],itemsPerSlide:o=[{breakpoint:0,itemsPerSlide:1}],carouselAxis:a="x",startingPosition:c="start",enableGestures:f=!0,slideWhenDragThresholdIsReached:d=!0,onInit:u,slideType:w="item",initialActiveItem:g=0}){const[C,P]=m.useState(!1),O=m.useRef(t),x=m.useRef(null),E=m.useRef(null),j=m.useRef(0),v=m.useRef(0),k=m.useRef(!r),L=m.useRef(!1),A=m.useRef(0),h=m.useRef(0),H=J.useSpringRef(),ne=J.useSpring({value:0,ref:H,onChange({value:i}){const l=a==="x"?`translate3d(calc(${i.value}px + var(--${n}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${i.value}px + var(--${n}-offset-modifier)), 0px)`;E.current.style.transform=l}}),It=r?[...e.map(i=>({...i,id:`prev-repeated-item-${i.id}`,isClonedItem:!0})),...e,...e.map(i=>({...i,id:`next-repeated-item-${i.id}`,isClonedItem:!0}))]:e,{useListenToCustomEvent:Ie,emitEvent:X}=wt();function Ce(){const{totalGutterCssVar:i}=ke();return i}function Ct(){if(x.current){const l=window.getComputedStyle(x.current).getPropertyValue(`--${n}-items-per-slide`).trim();return Number(l)||1}return 1}function se(i){O.current&&(L.current||U({type:"next",toIndex:i,actionType:"click"}))}function ie(i){O.current&&(k.current||U({type:"prev",toIndex:i,actionType:"click"}))}function U({type:i,shouldAnimate:l=!0,toIndex:_,actionType:T}){var V,K;const S=!l;k.current=!1,L.current=!1;let y=ne.value.get(),D=0;if(i==="next"&&(h.current+=1),i==="prev"&&(h.current===0?h.current=e.length-1:h.current-=1),_!==void 0&&(h.current=_),i==="next"){const R=oe(r?v.current*(e.length*2):0);D=-(h.current*v.current),r&&h.current===e.length&&(h.current=0,y=y+v.current*e.length,D=0),!r&&(Math.abs(D)>=R||h.current===e.length-1)&&(L.current=!0,D=-R)}i==="prev"&&(D=-(h.current*v.current),h.current===e.length-1&&(y=y-e.length*v.current),!r&&D>=0&&(k.current=!0,D=0)),j.current=D,T==="resize"?(D=-(h.current*v.current),X({eventName:"onResize",sliceActionType:T,slideDirection:i,currentItem:{index:h.current,id:((V=e.at(h.current))==null?void 0:V.id)??"",startReached:k.current,endReached:L.current}})):X({eventName:"onSlideStartChange",sliceActionType:T,slideDirection:i,nextItem:{index:h.current,id:((K=e.at(h.current))==null?void 0:K.id)??"",startReached:k.current,endReached:L.current}}),H.start({immediate:S,from:{value:y},to:{value:D},onChange({value:R}){const q=a==="x"?`translate3d(calc(${R.value}px + var(--${n}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${R.value}px + var(--${n}-offset-modifier)), 0px)`;E.current.style.transform=q},onRest({finished:R}){var q;R&&X({eventName:"onSlideChangeComplete",sliceActionType:T,slideDirection:i,currentItem:{index:h.current,id:((q=e.at(h.current))==null?void 0:q.id)??"",startReached:k.current,endReached:L.current}})}})}function kt(){const i=E.current;let l=0;return w==="item"?l=i.children[0].getBoundingClientRect()[a==="x"?"width":"height"]+Ce():l=i.getBoundingClientRect()[a==="x"?"width":"height"]+Ce(),l}function oe(i){const l=E.current;return l[a==="x"?"scrollWidth":"scrollHeight"]-l.getBoundingClientRect()[a==="x"?"width":"height"]-i}function ke(){let i=0,l=0;if(x.current){const _=window.getComputedStyle(x.current),T=_.getPropertyValue(`--${n}-start-end-gutter`).trim();T.includes("px")&&(i=Number(T.replace("px","")));const S=_.getPropertyValue(`--${n}-gutter`).trim();S.includes("px")&&(l=Number(S.replace("px","")))}return{totalStartEndGutterCssVar:i,totalGutterCssVar:l}}m.useEffect(()=>{function i(S){const y=Ct();switch(S){case"start":return 0;case"middle-start":return Math.floor((y-1)*.25);case"center":return Math.floor((y-1)*.5);case"middle-end":return Math.floor((y-1)*.75);case"end":return y-1;default:return 0}}function l(){v.current=kt(),console.log("scrollAmountValue",v.current),A.current=v.current/4;const{totalStartEndGutterCssVar:S}=ke();let y=0;r&&(y=v.current*e.length),y-=v.current*i(c),y-=S/2,console.log({mod1:v.current*e.length,mod2:v.current*i(c),mod3:S/2}),x.current.style.setProperty(`--${n}-offset-modifier`,`${-y}px`)}function _(S){x.current&&(l(),P(!0),S&&S())}function T(){_(),U({type:"resize",toIndex:h.current,shouldAnimate:!1,actionType:"resize"})}if(t)return O.current=!0,_(u),window.addEventListener("resize",T),()=>{window.removeEventListener("resize",T)}},[t,r,n,a,s,c]),m.useEffect(()=>{t&&g!==h.current&&U({type:"next",toIndex:g,actionType:"resize",shouldAnimate:!1})},[t,g]);const De=f,Dt=_t(i=>{if(!O.current)return;const l=i.dragging,_=i.offset[a==="x"?0:1],T=i.movement[a==="x"?0:1],S=T>A.current,y=T<-A.current,D=i.velocity;l&&(X({...i,eventName:"onDrag",slideActionType:"drag"}),H.start({value:_,immediate:!0,config:{velocity:D},onChange({value:V}){const K=a==="x"?`translate3d(calc(${V.value}px + var(--${n}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${V.value}px + var(--${n}-offset-modifier)), 0px)`;E.current.style.transform=K}}),d&&(S||y)&&i.cancel()),i.last&&(S?(U({actionType:"drag",type:"prev"}),i.cancel()):y?(U({actionType:"drag",type:"next"}),i.cancel()):(H.start({value:j.current,config:{velocity:D},onChange({value:V}){const K=a==="x"?`translate3d(calc(${V.value}px + var(--${n}-offset-modifier)), 0px, 0px)`:`translate3d(0px, calc(${V.value}px + var(--${n}-offset-modifier)), 0px)`;E.current.style.transform=K}}),i.cancel()))},{enabled:De,axis:a,rubberband:!r,...r?{}:{bounds:()=>({right:0,left:-oe(0),top:-oe(0),bottom:0})},from:()=>[ne.value.get(),ne.value.get()]});function $t(i){var l,_;return typeof i=="number"?h.current===i:((l=e.find(T=>T.id===i))==null?void 0:l.id)===((_=e[h.current])==null?void 0:_.id)}return{carouselFragment:M.jsxs("div",{ref:x,className:"ReactSpringCarouselContainer","data-part":"Container","data-part-internal":`${n}-Container`,...Dt(),children:[M.jsx("style",{dangerouslySetInnerHTML:{__html:xt(`
|
|
2
2
|
[data-part-internal="${n}-Container"] {
|
|
3
3
|
display: flex;
|
|
4
4
|
width: 100%;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
--${n}-scroll-y-value: ${a==="y"?`calc(var(--${n}-offset-position) + var(--${n}-offset-modifier))`:"0px"};
|
|
12
12
|
--${n}-gutter: 0px;
|
|
13
13
|
--${n}-start-end-gutter: 0px;
|
|
14
|
-
touch-action: ${
|
|
14
|
+
touch-action: ${De?a==="x"?"pan-y":"pan-x":"auto"};
|
|
15
15
|
}
|
|
16
16
|
[data-part-internal="${n}-Track"] {
|
|
17
17
|
display: flex;
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
display: flex;
|
|
30
30
|
flex: 1 0 calc(100% / var(--${n}-items-per-slide) - calc(var(--${n}-gutter) * (var(--${n}-items-per-slide) - 1)) / var(--${n}-items-per-slide) - calc(var(--${n}-start-end-gutter) / var(--${n}-items-per-slide)));
|
|
31
31
|
}
|
|
32
|
-
${s&&s.length>0?s.sort((i,
|
|
32
|
+
${s&&s.length>0?s.sort((i,l)=>i.breakpoint-l.breakpoint).map(i=>`
|
|
33
33
|
@media ${i.media||`(min-width: ${i.breakpoint}px)`} {
|
|
34
34
|
[data-part-internal="${n}-Container"] {
|
|
35
35
|
--${n}-gutter: ${i.gutter||0}px;
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
`).join(""):""}
|
|
40
|
-
${o&&o.length>0?o.sort((i,
|
|
40
|
+
${o&&o.length>0?o.sort((i,l)=>i.breakpoint-l.breakpoint).map(i=>`
|
|
41
41
|
@media ${i.media||`(min-width: ${i.breakpoint}px)`} {
|
|
42
42
|
[data-part-internal="${n}-Container"] {
|
|
43
43
|
--${n}-items-per-slide: ${i.itemsPerSlide||1};
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
`).join(""):""}
|
|
47
|
-
`)}}),M.jsx("div",{ref:
|
|
47
|
+
`)}}),M.jsx("div",{ref:E,className:"ReactSpringCarouselTrack","data-part":"Track","data-part-internal":`${n}-Track`,onScroll:()=>{k.current=!1,L.current=!1},children:It.map((i,l)=>M.jsx("div",{className:"ReactSpringCarouselItem","data-part":"Item","data-part-internal":`${n}-Item`,"data-id":i.id,children:typeof i.renderItem=="function"?i.renderItem({useListenToCustomEvent:Ie,index:l,isClonedItem:!!i.isClonedItem,isActiveItem:$t}):i.renderItem},`${i.id}-${l}`))})]}),useListenToCustomEvent:Ie,slideToNextItem:()=>se(),slideToPrevItem:()=>ie(),slideToItem:i=>{if(typeof i=="number"){if(!e[i]){console.warn(`The item you're trying to slide doesn't exist. index: ${i}`);return}i>h.current?se(i):ie(i)}if(typeof i=="string"){const l=e.findIndex(_=>_.id===i);if(l<0){console.warn(`The item you're trying to slide doesn't exist. id: ${i}`);return}l>h.current?se(l):ie(l)}}}}function Tt(t){let e=0;const r=getComputedStyle(t).getPropertyValue("gap");return r.includes("px")&&(e=Number(r.replace("px",""))),e}function Se(t){return t.scrollWidth-t.clientWidth}function re(t){const e=t.children[0],r=Tt(t);return e.getBoundingClientRect().width+r}function St({container:t,onReach:e}){const r=m.useRef("start"),n=m.useRef(0),[,s]=J.useSpring(()=>({x:0}));function o(c){s.start({from:{x:t.current.scrollLeft},to:{x:c},onChange({value:f}){t.current&&(t.current.scrollLeft=f.x)}})}function a(c){if(!t.current||c==="next"&&r.current==="end"||c==="prev"&&r.current==="start")return;let f=0;if(c==="next"&&(n.current+=1),c==="prev"&&(n.current-=1),f=n.current*re(t.current),c==="next"){const d=Se(t.current);f>d&&(r.current="end",f=d,e&&e("end"))}c==="prev"&&f<=0&&(r.current="start",n.current=0,f=0,e&&e("start")),o(f)}return m.useEffect(()=>{function c(){var j;const C=re(t.current),P=((j=[...t.current.children].at(0))==null?void 0:j.getBoundingClientRect().width)||0,O=Array(t.current.childElementCount).fill(0).map((v,k)=>({index:k,start:C*k,end:C*(k+1)})),x=t.current.scrollLeft+P,E=O.find(v=>x>=v.start&&x<v.end);n.current=(E==null?void 0:E.index)||0}function f(){s.stop()}function d(C){const P=C.target;P.scrollLeft===0?(n.current=0,r.current="start",e&&e("start")):P.scrollLeft>=Se(P)?(r.current="end",e&&e("end")):r.current!=="idle"&&(r.current="idle",e&&e("idle"))}let u,w=0;function g(){w=t.current.scrollLeft,clearTimeout(u),u=setTimeout(function(){t.current.scrollLeft===w&&c()},200)}if(t.current)return t.current.addEventListener("wheel",f,{passive:!0}),t.current.addEventListener("scroll",d),t.current.addEventListener("scroll",g),()=>{t.current&&(t.current.removeEventListener("scroll",g),t.current.removeEventListener("scroll",d),t.current.removeEventListener("wheel",f))}},[t,e]),m.useEffect(()=>{if(t.current){const c=new ResizeObserver(()=>{o(n.current*re(t.current))});return c.observe(t.current),()=>{c.disconnect()}}},[]),{scrollToNext(){a("next")},scrollToPrev(){a("prev")}}}N.useSpringCarousel=Et,N.useSpringScroll=St,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-spring-carousel",
|
|
3
|
-
"version": "3.0.0-beta-2.0.
|
|
3
|
+
"version": "3.0.0-beta-2.0.99",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.umd.js",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"react-dom": "^18.0.0 || ^19"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
+
"@react-spring/web": "^10.0.3",
|
|
37
38
|
"@chromatic-com/storybook": "^3.2.6",
|
|
38
39
|
"@eslint/js": "^9.23.0",
|
|
39
40
|
"@storybook/addon-essentials": "^8.6.12",
|