motion-dom 14.12.0 → 14.13.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.
@@ -1 +1 @@
1
- {"version":3,"file":"size-rollup-pinch.js","sources":["../../motion-utils/dist/es/clamp.mjs","../../motion-utils/dist/es/global-config.mjs","../../motion-utils/dist/es/is-object.mjs","../../motion-utils/dist/es/subscription-manager.mjs","../../motion-utils/dist/es/array.mjs","../../motion-utils/dist/es/time-conversion.mjs","../lib/animation/generators/utils/calc-duration.js","../lib/animation/generators/spring.js","../lib/animation/waapi/utils/linear.js","../lib/animation/generators/utils/create-generator-easing.js","../lib/animation/waapi/transforms/groups.js","../lib/render/dom/is-css-var.js","../lib/render/dom/parse-transform.js","../lib/render/utils/keys-transform.js","../lib/utils/is-html-element.js","../lib/utils/is-svg-element.js","../lib/frameloop/order.js","../lib/frameloop/batcher.js","../lib/frameloop/render-step.js","../lib/frameloop/frame-data.js","../lib/frameloop/frame.js","../../motion-utils/dist/es/noop.mjs","../lib/frameloop/sync-time.js","../lib/value/index.js","../../motion-utils/dist/es/velocity-per-second.mjs","../lib/value/types/numbers/index.js","../lib/value/types/int.js","../lib/value/types/numbers/units.js","../lib/value/types/maps/transform.js","../lib/value/types/maps/number.js","../lib/value/types/utils/get-as-type.js","../lib/scope/active.js","../lib/effects/MotionValueState.js","../lib/effects/utils/create-effect.js","../lib/render/html/utils/build-transform.js","../lib/effects/style/index.js","../lib/effects/style/transform.js","../lib/render/dom/utils/camel-to-dash.js","../lib/render/svg/utils/build-attrs.js","../lib/effects/attr/index.js","../lib/effects/svg/index.js","../lib/render/store.js","../lib/utils/mix/number.js","../lib/gestures/drag/state/is-active.js","../lib/gestures/drag/utils/constraints.js","../lib/gestures/drag/VisualElementDragControls.js","../lib/gestures/pinch/index.js","../lib/gestures/drag/state/set-active.js","../lib/utils/resolve-elements.js"],"sourcesContent":["const clamp = (min, max, v) => {\n if (v > max)\n return max;\n if (v < min)\n return min;\n return v;\n};\n\nexport { clamp };\n//# sourceMappingURL=clamp.mjs.map\n","const MotionGlobalConfig = {};\n\nexport { MotionGlobalConfig };\n//# sourceMappingURL=global-config.mjs.map\n","const isObject = (value) => typeof value === \"object\" && value !== null;\n\nexport { isObject };\n//# sourceMappingURL=is-object.mjs.map\n","import { addUniqueItem, removeItem } from './array.mjs';\n\nclass SubscriptionManager {\n constructor() {\n this.subscriptions = [];\n }\n add(handler) {\n addUniqueItem(this.subscriptions, handler);\n return () => this.remove(handler);\n }\n remove(handler) {\n removeItem(this.subscriptions, handler);\n }\n notify(a, b, c) {\n const numSubscriptions = this.subscriptions.length;\n if (!numSubscriptions)\n return;\n if (numSubscriptions === 1) {\n /**\n * If there's only a single handler we can just call it without invoking a loop.\n */\n this.subscriptions[0](a, b, c);\n }\n else {\n for (let i = 0; i < numSubscriptions; i++) {\n /**\n * Check whether the handler exists before firing as it's possible\n * the subscriptions were modified during this loop running.\n */\n const handler = this.subscriptions[i];\n handler && handler(a, b, c);\n }\n }\n }\n getSize() {\n return this.subscriptions.length;\n }\n clear() {\n this.subscriptions.length = 0;\n }\n}\n\nexport { SubscriptionManager };\n//# sourceMappingURL=subscription-manager.mjs.map\n","function addUniqueItem(arr, item) {\n if (arr.indexOf(item) === -1)\n arr.push(item);\n}\nfunction removeItem(arr, item) {\n const index = arr.indexOf(item);\n if (index > -1)\n arr.splice(index, 1);\n}\n// Adapted from array-move\nfunction moveItem([...arr], fromIndex, toIndex) {\n const startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex;\n if (startIndex >= 0 && startIndex < arr.length) {\n const endIndex = toIndex < 0 ? arr.length + toIndex : toIndex;\n const [item] = arr.splice(fromIndex, 1);\n arr.splice(endIndex, 0, item);\n }\n return arr;\n}\n\nexport { addUniqueItem, moveItem, removeItem };\n//# sourceMappingURL=array.mjs.map\n","/**\n * Converts seconds to milliseconds\n *\n * @param seconds - Time in seconds.\n * @return milliseconds - Converted time in milliseconds.\n */\n/*#__NO_SIDE_EFFECTS__*/\nconst secondsToMilliseconds = (seconds) => seconds * 1000;\n/*#__NO_SIDE_EFFECTS__*/\nconst millisecondsToSeconds = (milliseconds) => milliseconds / 1000;\n\nexport { millisecondsToSeconds, secondsToMilliseconds };\n//# sourceMappingURL=time-conversion.mjs.map\n","/**\n * Implement a practical max duration for keyframe generation\n * to prevent infinite loops\n */\nexport const maxGeneratorDuration = 20000;\nexport function calcGeneratorDuration(generator, timeStep = 50, maxDuration = maxGeneratorDuration, keyframes) {\n let duration = 0;\n let state = generator.next(duration);\n keyframes?.push(state.value);\n while (!state.done && duration < maxDuration) {\n duration += timeStep;\n state = generator.next(duration);\n keyframes?.push(state.value);\n }\n return duration >= maxDuration ? Infinity : duration;\n}\n//# sourceMappingURL=calc-duration.js.map","import { clamp, millisecondsToSeconds, secondsToMilliseconds, warning, } from \"motion-utils\";\nimport { generateLinearEasing } from \"../waapi/utils/linear\";\nimport { calcGeneratorDuration, maxGeneratorDuration, } from \"./utils/calc-duration\";\nimport { createGeneratorEasing } from \"./utils/create-generator-easing\";\n// Default spring physics\nconst defaultStiffness = 100;\nconst defaultDamping = 10;\nconst defaultMass = 1.0;\n// Default duration/bounce-based options\nconst defaultDuration = 800; // in ms\nconst defaultBounce = 0.3;\nconst defaultVisualDuration = 0.3; // in seconds\n// Rest thresholds\nconst restSpeedGranular = 0.01;\nconst restSpeedDefault = 2;\nconst restDeltaGranular = 0.005;\nconst restDeltaDefault = 0.5;\n// Limits\nconst minDuration = 0.01; // in seconds\nconst maxDuration = 10.0; // in seconds\nconst minDamping = 0.05;\n/**\n * Maps bounce to a damping ratio as SwiftUI does: 0 is critically damped, and\n * it approaches undamped towards 1 and infinitely overdamped towards -1. Both\n * ends are limited so the spring still moves and settles.\n */\nconst bounceToDampingRatio = (bounce) => bounce < 0\n ? 1 / Math.max(1 + bounce, minDamping)\n : Math.max(1 - bounce, minDamping);\n/**\n * Scales an overdamped spring's undamped frequency so that, at its defining\n * time, it has as far left to go as the critically damped spring that's\n * criticalFreqTime radians in by then. A negative bounce then changes the\n * shape of the curve, not when it arrives. 1 at a damping ratio of 1, so\n * there's no jump at a bounce of 0.\n *\n * Solved by Newton on the remaining distance (times fast - slow), which is\n * convex from criticalFreqTime onwards. criticalFreqTime is always below the\n * answer, so it converges from below without overshooting.\n */\nfunction overdampedFreqScale(dampingRatio, criticalFreqTime) {\n if (!(dampingRatio > 1))\n return 1;\n const root = Math.sqrt(dampingRatio * dampingRatio - 1);\n const slow = dampingRatio - root;\n const fast = dampingRatio + root;\n const target = 2 * root * Math.exp(-criticalFreqTime) * (1 + criticalFreqTime);\n return (approximateRoot((freqTime) => fast * Math.exp(-slow * freqTime) -\n slow * Math.exp(-fast * freqTime) -\n target, (freqTime) => Math.exp(-fast * freqTime) - Math.exp(-slow * freqTime), criticalFreqTime) / criticalFreqTime);\n}\nfunction calcAngularFreq(undampedFreq, dampingRatio) {\n return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);\n}\nconst rootIterations = 12;\nfunction approximateRoot(envelope, derivative, initialGuess) {\n let result = initialGuess;\n for (let i = 1; i < rootIterations; i++) {\n result = result - envelope(result) / derivative(result);\n }\n return result;\n}\n/**\n * This is ported from the Framer implementation of duration-based spring resolution.\n */\nconst safeMin = 0.001;\n/**\n * Assumes zero initial velocity and the default mass: duration springs start\n * from rest so they end exactly at their duration. Only resolves without\n * valid physics. Returns NaN physics when the root search doesn't converge.\n */\nfunction findSpring({ duration = defaultDuration, bounce = defaultBounce, }) {\n let envelope;\n let derivative;\n process.env.NODE_ENV !== \"production\" &&\n warning(duration <= secondsToMilliseconds(maxDuration), \"Spring duration must be 10 seconds or less\", \"spring-duration-limit\");\n const dampingRatio = bounceToDampingRatio(bounce);\n duration = clamp(minDuration, maxDuration, millisecondsToSeconds(duration));\n if (dampingRatio < 1) {\n /**\n * Underdamped spring\n */\n envelope = (undampedFreq) => {\n const exponentialDecay = undampedFreq * dampingRatio;\n const delta = exponentialDecay * duration;\n const b = calcAngularFreq(undampedFreq, dampingRatio);\n const c = Math.exp(-delta);\n return safeMin - (exponentialDecay / b) * c;\n };\n derivative = (undampedFreq) => {\n const exponentialDecay = undampedFreq * dampingRatio;\n const delta = exponentialDecay * duration;\n const e = dampingRatio *\n dampingRatio *\n undampedFreq *\n undampedFreq *\n duration;\n const f = Math.exp(-delta);\n const g = calcAngularFreq(undampedFreq * undampedFreq, dampingRatio);\n const factor = -envelope(undampedFreq) + safeMin > 0 ? -1 : 1;\n return (factor * -e * f) / g;\n };\n }\n else {\n /**\n * Critically-damped spring. Overdamped springs reuse this root,\n * scaled below.\n */\n envelope = (undampedFreq) => {\n const a = Math.exp(-undampedFreq * duration);\n const b = undampedFreq * duration + 1;\n return -safeMin + a * b;\n };\n derivative = (undampedFreq) => {\n const a = Math.exp(-undampedFreq * duration);\n const b = -undampedFreq * (duration * duration);\n return a * b;\n };\n }\n const initialGuess = 5 / duration;\n const criticalFreq = approximateRoot(envelope, derivative, initialGuess);\n const undampedFreq = criticalFreq *\n overdampedFreqScale(dampingRatio, criticalFreq * duration);\n const stiffness = undampedFreq * undampedFreq;\n return {\n stiffness,\n damping: dampingRatio * 2 * Math.sqrt(stiffness),\n duration: secondsToMilliseconds(duration),\n };\n}\n/**\n * Spring physics must be finite. stiffness and mass are also divisors so must\n * be positive, whereas a damping of 0 is a valid, perpetually oscillating\n * spring. Relational rather than Number.isFinite so numeric strings still\n * coerce.\n */\nconst isValidPhysics = (value, canBeZero) => (canBeZero ? value >= 0 : value > 0) && value < Infinity;\n/**\n * Returns value if it's usable spring physics, otherwise undefined so callers\n * fall back to the default. An explicit `undefined`, e.g. from a forwarded\n * optional prop, must fall back too. Invalid physics would otherwise resolve\n * to NaN spring values that never report done.\n */\nfunction resolvePhysics(value, canBeZero) {\n if (isValidPhysics(value, canBeZero))\n return value;\n if (process.env.NODE_ENV !== \"production\") {\n warning(value === undefined, \"Spring stiffness and mass must be positive, damping 0 or greater\", \"spring-invalid-physics\");\n }\n return undefined;\n}\nfunction getSpringOptions(options) {\n /**\n * Resolve physics before choosing between physics- and duration-based\n * resolution, so an invalid stiffness doesn't also silently discard a\n * valid duration/bounce.\n */\n const validStiffness = resolvePhysics(options.stiffness);\n const validDamping = resolvePhysics(options.damping, true);\n const validMass = resolvePhysics(options.mass);\n const springOptions = {\n ...options,\n stiffness: validStiffness ?? defaultStiffness,\n damping: validDamping ?? defaultDamping,\n mass: validMass ?? defaultMass,\n isResolvedFromDuration: false,\n // stiffness/damping/mass overrides duration/bounce\n isTimeDefined: (validStiffness ?? validDamping ?? validMass) === undefined &&\n (options.duration !== undefined || options.bounce !== undefined),\n };\n if (springOptions.isTimeDefined) {\n if (options.visualDuration) {\n const dampingRatio = bounceToDampingRatio(options.bounce || 0);\n const root = ((2 * Math.PI) / (options.visualDuration * 1.2)) *\n overdampedFreqScale(dampingRatio, (2 * Math.PI) / 1.2);\n springOptions.stiffness = root * root;\n springOptions.damping =\n 2 * dampingRatio * Math.sqrt(springOptions.stiffness);\n }\n else {\n Object.assign(springOptions, findSpring(springOptions));\n springOptions.isResolvedFromDuration = true;\n }\n /**\n * Time options can degenerate: a NaN bounce gives a NaN damping, an\n * infinite visualDuration a 0 stiffness, and findSpring NaN for both\n * when it doesn't converge. Replace the two together, so the\n * relationship duration resolution establishes between them is never\n * left half-overwritten.\n */\n if (!isValidPhysics(springOptions.stiffness) ||\n !isValidPhysics(springOptions.damping, true)) {\n springOptions.stiffness = defaultStiffness;\n springOptions.damping = defaultDamping;\n }\n }\n return springOptions;\n}\nfunction springGenerator(optionsOrVisualDuration = defaultVisualDuration, bounce = defaultBounce) {\n const options = typeof optionsOrVisualDuration !== \"object\"\n ? {\n visualDuration: optionsOrVisualDuration,\n keyframes: [0, 1],\n bounce,\n }\n : optionsOrVisualDuration;\n const origin = options.keyframes[0];\n const target = options.keyframes[options.keyframes.length - 1];\n /**\n * This is the Iterator-spec return value. We ensure it's mutable rather than using a generator\n * to reduce GC during animation.\n */\n const state = { done: false, value: origin };\n const { stiffness, damping, mass, duration, isResolvedFromDuration, isTimeDefined, } = getSpringOptions({ ...options });\n /**\n * A duration spring must end exactly at its duration, and it's settled\n * from rest by then. Inherited velocity could leave it still moving, so\n * it starts from rest. Every other spring, visualDuration included, ends\n * when it comes to rest, so inherits velocity as its initial condition.\n */\n const inheritVelocity = (velocity) => isResolvedFromDuration ? 0 : -millisecondsToSeconds(velocity);\n const dampingRatio = damping / (2 * Math.sqrt(stiffness * mass));\n const undampedAngularFreq = millisecondsToSeconds(Math.sqrt(stiffness / mass));\n const decay = dampingRatio * undampedAngularFreq;\n /**\n * Everything that changes when the spring is retargeted: written by\n * retarget() and update(), read by the resolvers. Grouped on one object,\n * like the coefficients (c) below. Writing doubles to object fields\n * measured marginally faster than to captured let variables in optimised\n * code; neither allocates, so this is a grouping choice, not a GC one.\n */\n const s = {\n target,\n delta: target - origin,\n velocity: inheritVelocity(options.velocity) || 0,\n restSpeed: 0,\n restDelta: 0,\n };\n /**\n * If we're working on a granular scale, use smaller defaults for determining\n * when the spring is finished.\n *\n * These defaults have been selected empirically based on what strikes a good\n * ratio between feeling good and finishing as soon as changes are imperceptible.\n */\n const setRestThresholds = () => {\n const isGranularScale = Math.abs(s.delta) < 5;\n s.restSpeed =\n options.restSpeed ||\n (isGranularScale ? restSpeedGranular : restSpeedDefault);\n s.restDelta =\n options.restDelta ||\n (isGranularScale ? restDeltaGranular : restDeltaDefault);\n };\n setRestThresholds();\n let resolveSpring;\n let resolveVelocity;\n /**\n * Derives the coefficients that depend on origin, target and initial\n * velocity. Called once now and again whenever the spring is retargeted.\n */\n let update;\n if (dampingRatio < 1) {\n const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);\n /**\n * A is the position coefficient, sinC/cosC the coefficients of the\n * analytical derivative (px/ms). The exp/sin/cos terms depend only\n * on t, so they're memoized by t independently of the target: a\n * spring retargeted every frame samples the same t each frame and\n * skips the transcendentals entirely.\n */\n const c = { A: 0, sinC: 0, cosC: 0, t: -1, env: 0, sin: 0, cos: 0 };\n update = () => {\n c.A = (s.velocity + decay * s.delta) / angularFreq;\n c.sinC = decay * c.A + s.delta * angularFreq;\n c.cosC = decay * s.delta - c.A * angularFreq;\n };\n const sample = (t) => {\n if (t !== c.t) {\n c.t = t;\n c.env = Math.exp(-decay * t);\n c.sin = Math.sin(angularFreq * t);\n c.cos = Math.cos(angularFreq * t);\n }\n };\n // Underdamped spring\n resolveSpring = (t) => {\n sample(t);\n return s.target - c.env * (c.A * c.sin + s.delta * c.cos);\n };\n resolveVelocity = (t) => {\n sample(t);\n return c.env * (c.sinC * c.sin + c.cosC * c.cos);\n };\n }\n else if (dampingRatio === 1) {\n // Critically damped spring\n resolveSpring = (t) => s.target -\n Math.exp(-undampedAngularFreq * t) *\n (s.delta + (s.velocity + undampedAngularFreq * s.delta) * t);\n // Analytical derivative of critically damped spring (px/ms)\n const c = { C: 0 };\n update = () => {\n c.C = s.velocity + undampedAngularFreq * s.delta;\n };\n resolveVelocity = (t) => Math.exp(-undampedAngularFreq * t) *\n (undampedAngularFreq * c.C * t - s.velocity);\n }\n else {\n /**\n * Overdamped spring: the sum of a slow and a fast decaying\n * exponential, so no term can overflow however heavily it's damped.\n */\n const dampedAngularFreq = undampedAngularFreq * Math.sqrt(dampingRatio * dampingRatio - 1);\n const slow = decay - dampedAngularFreq;\n const fast = decay + dampedAngularFreq;\n /**\n * Physics-defined springs keep a non-physical limit: once\n * dampedAngularFreq * t passes 300, both terms decay at the damping\n * rate. Heavily overdamped drag springs (dragElastic: 0,\n * dragTransition) rely on this to settle almost at once rather than\n * creep at stiffness / damping. It only applies when reached within\n * 300ms (a dampedAngularFreq of 1 rad/ms), so it reads as a stiff\n * spring snapping into place: any later and it cuts off a slow spring\n * that's visibly still moving (#1207). Negative bounce needs the\n * exact curve, so time-defined springs are exempt.\n */\n const limit = dampedAngularFreq < 1 || isTimeDefined\n ? Infinity\n : 300 / dampedAngularFreq;\n const decayAt = (rate, t) => Math.exp(t > limit ? (decay - rate) * limit - decay * t : -rate * t);\n const c = { S: 0, F: 0 };\n update = () => {\n const P = (s.velocity + decay * s.delta) / dampedAngularFreq;\n c.S = (s.delta + P) / 2;\n c.F = (s.delta - P) / 2;\n };\n resolveSpring = (t) => s.target - c.S * decayAt(slow, t) - c.F * decayAt(fast, t);\n // Analytical derivative of overdamped spring (px/ms)\n resolveVelocity = (t) => slow * c.S * decayAt(slow, t) + fast * c.F * decayAt(fast, t);\n }\n update();\n const calculatedDuration = isResolvedFromDuration ? duration || null : null;\n const generator = {\n calculatedDuration,\n /**\n * Aim the spring at a new target from its current position and\n * velocity, reusing the resolved physics and closures.\n */\n retarget: (keyframes, newVelocity) => {\n s.target = keyframes[keyframes.length - 1];\n s.delta = s.target - keyframes[0];\n s.velocity = inheritVelocity(newVelocity);\n // Default thresholds depend on the scale of the new delta\n if (!(options.restSpeed && options.restDelta))\n setRestThresholds();\n // Invalidate any duration lazily cached by JSAnimation\n generator.calculatedDuration = calculatedDuration;\n state.done = false;\n update();\n },\n velocity: (t) => secondsToMilliseconds(resolveVelocity(t)),\n next: (t) => {\n const current = resolveSpring(t);\n if (!isResolvedFromDuration) {\n const currentVelocity = secondsToMilliseconds(resolveVelocity(t));\n state.done =\n Math.abs(currentVelocity) <= s.restSpeed &&\n Math.abs(s.target - current) <= s.restDelta;\n }\n else {\n state.done = t >= duration;\n }\n state.value = state.done ? s.target : current;\n return state;\n },\n toString: () => {\n const easingDuration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);\n const easing = generateLinearEasing((progress) => generator.next(easingDuration * progress).value, easingDuration, 30);\n return easingDuration + \"ms \" + easing;\n },\n };\n return generator;\n}\nconst spring = /* @__PURE__ */ Object.assign(springGenerator, {\n applyToOptions: (options) => {\n const generatorOptions = createGeneratorEasing(options, 100, springGenerator);\n options.ease = generatorOptions.ease;\n options.duration = secondsToMilliseconds(generatorOptions.duration);\n options.type = \"keyframes\";\n return options;\n },\n});\nexport { spring };\n//# sourceMappingURL=spring.js.map","export const generateLinearEasing = (easing, duration, // as milliseconds\nresolution = 10 // as milliseconds\n) => {\n let points = \"\";\n const numPoints = Math.max(Math.round(duration / resolution), 2);\n for (let i = 0; i < numPoints; i++) {\n points += Math.round(easing(i / (numPoints - 1)) * 10000) / 10000 + \", \";\n }\n return `linear(${points.substring(0, points.length - 2)})`;\n};\n//# sourceMappingURL=linear.js.map","import { millisecondsToSeconds } from \"motion-utils\";\nimport { calcGeneratorDuration, maxGeneratorDuration } from \"./calc-duration\";\n/**\n * Create a progress => progress easing function from a generator.\n */\nexport function createGeneratorEasing(options, scale = 100, createGenerator) {\n /**\n * The easing is generated over 0 - scale, but velocity is in the\n * value's own units, so scale it to match. Otherwise an interrupted\n * spring hands off the wrong speed, or direction. Keyframes with\n * units (colours, filters, mixed units) give NaN, which is falsy,\n * so their velocity passes through unscaled.\n */\n const { keyframes: k, velocity: v } = options;\n const delta = k && k[k.length - 1] - k[0];\n const generator = createGenerator({\n ...options,\n velocity: v && delta ? (v * scale) / delta : v,\n keyframes: [0, scale],\n });\n const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);\n return {\n type: \"keyframes\",\n ease: (progress) => {\n return generator.next(duration * progress).value / scale;\n },\n duration: millisecondsToSeconds(duration),\n };\n}\n//# sourceMappingURL=create-generator-easing.js.map","export const transformGroups = new WeakMap();\n//# sourceMappingURL=groups.js.map","export const isCSSVar = (name) => name.startsWith(\"--\");\n//# sourceMappingURL=is-css-var.js.map","const radToDeg = (rad) => (rad * 180) / Math.PI;\nconst rotate = (v) => {\n const angle = radToDeg(Math.atan2(v[1], v[0]));\n return rebaseAngle(angle);\n};\nconst matrix2dParsers = {\n x: 4,\n y: 5,\n translateX: 4,\n translateY: 5,\n scaleX: 0,\n scaleY: 3,\n scaleZ: () => 1,\n scale: (v) => (Math.abs(v[0]) + Math.abs(v[3])) / 2,\n rotate,\n rotateZ: rotate,\n skewX: (v) => radToDeg(Math.atan(v[1])),\n skewY: (v) => radToDeg(Math.atan(v[2])),\n skew: (v) => (Math.abs(v[1]) + Math.abs(v[2])) / 2,\n};\nconst rebaseAngle = (angle) => {\n angle = angle % 360;\n if (angle < 0)\n angle += 360;\n return angle;\n};\nconst rotateZ = rotate;\nconst scaleX = (v) => Math.hypot(v[0], v[1]);\nconst scaleY = (v) => Math.hypot(v[4], v[5]);\nconst matrix3dParsers = {\n x: 12,\n y: 13,\n z: 14,\n translateX: 12,\n translateY: 13,\n translateZ: 14,\n scaleX,\n scaleY,\n scaleZ: (v) => Math.hypot(v[8], v[9], v[10]),\n scale: (v) => (scaleX(v) + scaleY(v)) / 2,\n rotateX: (v) => rebaseAngle(radToDeg(Math.atan2(v[6], v[5]))),\n rotateY: (v) => rebaseAngle(radToDeg(Math.atan2(-v[2], v[0]))),\n rotateZ,\n rotate: rotateZ,\n skewX: (v) => radToDeg(Math.atan(v[4])),\n skewY: (v) => radToDeg(Math.atan(v[1])),\n skew: (v) => (Math.abs(v[1]) + Math.abs(v[4])) / 2,\n};\nexport function defaultTransformValue(name) {\n return name.includes(\"scale\") ? 1 : 0;\n}\nexport function parseValueFromTransform(transform, name) {\n if (!transform || transform === \"none\") {\n return defaultTransformValue(name);\n }\n const match = transform.match(/^matrix(3d)?\\(([-\\d.e\\s,]+)\\)$/u);\n if (!match) {\n return defaultTransformValue(name);\n }\n const valueParser = (match[1] ? matrix3dParsers : matrix2dParsers)[name];\n /**\n * parseFloat skips leading whitespace and stops at trailing whitespace.\n */\n const values = match[2].split(\",\").map((v) => parseFloat(v));\n return typeof valueParser === \"function\"\n ? valueParser(values)\n : values[valueParser];\n}\nexport const readTransformValue = (instance, name) => {\n const { transform = \"none\" } = getComputedStyle(instance);\n return parseValueFromTransform(transform, name);\n};\n//# sourceMappingURL=parse-transform.js.map","/**\n * Generate a list of every possible transform key.\n */\nexport const transformPropOrder = [\n \"transformPerspective\",\n \"x\",\n \"y\",\n \"z\",\n \"translateX\",\n \"translateY\",\n \"translateZ\",\n \"scale\",\n \"scaleX\",\n \"scaleY\",\n \"scaleZ\",\n \"rotate\",\n \"rotateX\",\n \"rotateY\",\n \"rotateZ\",\n \"skew\",\n \"skewX\",\n \"skewY\",\n];\n/**\n * A quick lookup for transform props.\n *\n * `pathRotation` is a transform for routing purposes (skipped from raw\n * style application, wired to the transform composite, flags transform\n * dirty) but is intentionally NOT in `transformPropOrder` — it is\n * composed onto `rotate` at the build sites, not serialized in its own\n * slot, and must stay out of the order-array consumers (parse-transform,\n * unit-conversion, keys-position).\n */\nexport const transformProps = /*@__PURE__*/ (() => new Set([...transformPropOrder, \"pathRotation\"]))();\n//# sourceMappingURL=keys-transform.js.map","import { isObject } from \"motion-utils\";\n/**\n * Checks if an element is an HTML element in a way\n * that works across iframes\n */\nexport function isHTMLElement(element) {\n return (isObject(element) &&\n \"offsetHeight\" in element &&\n !(\"ownerSVGElement\" in element));\n}\n//# sourceMappingURL=is-html-element.js.map","import { isObject } from \"motion-utils\";\n/**\n * Checks if an element is an SVG element in a way\n * that works across iframes\n */\nexport function isSVGElement(element) {\n return isObject(element) && \"ownerSVGElement\" in element;\n}\n//# sourceMappingURL=is-svg-element.js.map","export const stepsOrder = [\n \"setup\", // Compute\n \"read\", // Read\n \"resolveKeyframes\", // Write/Read/Write/Read\n \"preUpdate\", // Compute\n \"update\", // Compute\n \"preRender\", // Compute\n \"render\", // Write\n \"postRender\", // Compute\n];\n//# sourceMappingURL=order.js.map","import { MotionGlobalConfig } from \"motion-utils\";\nimport { stepsOrder } from \"./order\";\nimport { createRenderStep } from \"./render-step\";\nconst maxElapsed = 40;\nexport function createRenderBatcher(scheduleNextBatch, allowKeepAlive, state = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n}) {\n let runNextFrame = false;\n let useDefaultElapsed = true;\n const flagRunNextFrame = () => (runNextFrame = true);\n const steps = stepsOrder.reduce((acc, key) => {\n acc[key] = createRenderStep(flagRunNextFrame);\n return acc;\n }, {});\n const { setup, read, resolveKeyframes, preUpdate, update, preRender, render, postRender, } = steps;\n const processBatch = () => {\n const useManualTiming = MotionGlobalConfig.useManualTiming;\n const timestamp = useManualTiming\n ? state.timestamp\n : performance.now();\n runNextFrame = false;\n if (!useManualTiming) {\n state.delta = useDefaultElapsed\n ? 1000 / 60\n : Math.max(Math.min(timestamp - state.timestamp, maxElapsed), 1);\n }\n state.timestamp = timestamp;\n state.isProcessing = true;\n // Unrolled render loop for better per-frame performance\n setup.process(state);\n read.process(state);\n resolveKeyframes.process(state);\n preUpdate.process(state);\n update.process(state);\n preRender.process(state);\n render.process(state);\n postRender.process(state);\n state.isProcessing = false;\n if (runNextFrame && allowKeepAlive) {\n useDefaultElapsed = false;\n scheduleNextBatch(processBatch);\n }\n };\n const wake = () => {\n runNextFrame = true;\n useDefaultElapsed = true;\n if (!state.isProcessing) {\n scheduleNextBatch(processBatch);\n }\n };\n const schedule = stepsOrder.reduce((acc, key) => {\n const step = steps[key];\n acc[key] = (process, keepAlive = false, immediate = false) => {\n if (!runNextFrame)\n wake();\n return step.schedule(process, keepAlive, immediate);\n };\n return acc;\n }, {});\n const cancel = (process) => {\n for (let i = 0; i < stepsOrder.length; i++) {\n steps[stepsOrder[i]].cancel(process);\n }\n };\n return { schedule, cancel, state, steps };\n}\n//# sourceMappingURL=batcher.js.map","export function createRenderStep(runNextFrame) {\n /**\n * We create and reuse two queues, one to queue jobs for the current frame\n * and one for the next. We reuse to avoid triggering GC after x frames.\n */\n let thisFrame = new Set();\n let nextFrame = new Set();\n /**\n * Track whether we're currently processing jobs in this step. This way\n * we can decide whether to schedule new jobs for this frame or next.\n */\n let isProcessing = false;\n let flushNextFrame = false;\n /**\n * The callback currently running. If it schedules itself with `immediate`\n * it's left in place, so as before it doesn't run again this step.\n */\n let running;\n /**\n * A set of processes which were marked keepAlive when scheduled.\n * A keepAlive process is always also held by a frame queue until\n * it's cancelled, so a Set has the same lifetime semantics as a\n * WeakSet here while being considerably faster to query every frame.\n */\n const toKeepAlive = new Set();\n let latestFrameData = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n };\n function triggerCallback(callback) {\n if (toKeepAlive.has(callback)) {\n nextFrame.add(callback);\n runNextFrame();\n }\n ;\n (running = callback)(latestFrameData);\n }\n const step = {\n /**\n * Schedule a process to run on the next frame.\n */\n schedule: (callback, keepAlive = false, immediate = false) => {\n const addToCurrentFrame = immediate && isProcessing;\n const queue = addToCurrentFrame ? thisFrame : nextFrame;\n if (keepAlive)\n toKeepAlive.add(callback);\n /**\n * A callback scheduled with `immediate` during processing may\n * already have run this step (for instance, a value it reads was\n * changed by a later callback). Re-adding moves it to the end of\n * the queue, so it runs again. The running callback is excluded,\n * so one that re-schedules itself can't loop forever.\n */\n addToCurrentFrame && callback !== running && queue.delete(callback);\n queue.add(callback);\n return callback;\n },\n /**\n * Cancel the provided callback from running on the next frame.\n */\n cancel: (callback) => {\n nextFrame.delete(callback);\n toKeepAlive.delete(callback);\n },\n /**\n * Execute all schedule callbacks.\n */\n process: (frameData) => {\n latestFrameData = frameData;\n /**\n * If we're already processing we've probably been triggered by a flushSync\n * inside an existing process. Instead of executing, mark flushNextFrame\n * as true and ensure we flush the following frame at the end of this one.\n */\n if (isProcessing) {\n flushNextFrame = true;\n return;\n }\n isProcessing = true;\n // Swap this frame and the next to avoid GC\n const prevFrame = thisFrame;\n thisFrame = nextFrame;\n nextFrame = prevFrame;\n // Execute this frame\n thisFrame.forEach(triggerCallback);\n // Clear the frame so no callbacks remain. This is to avoid\n // memory leaks should this render step not run for a while.\n thisFrame.clear();\n running = undefined;\n isProcessing = false;\n if (flushNextFrame) {\n flushNextFrame = false;\n step.process(frameData);\n }\n },\n };\n return step;\n}\n//# sourceMappingURL=render-step.js.map","/**\n * The frameloop's state, kept apart from the frameloop itself so that\n * reading it doesn't bundle the scheduler.\n */\nexport const frameData = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n};\n//# sourceMappingURL=frame-data.js.map","import { noop } from \"motion-utils\";\nimport { createRenderBatcher } from \"./batcher\";\nimport { frameData } from \"./frame-data\";\nexport const { schedule: frame, cancel: cancelFrame, steps: frameSteps, } = /* @__PURE__ */ createRenderBatcher(typeof requestAnimationFrame !== \"undefined\" ? requestAnimationFrame : noop, true, frameData);\n//# sourceMappingURL=frame.js.map","/*#__NO_SIDE_EFFECTS__*/\nconst noop = (any) => any;\n\nexport { noop };\n//# sourceMappingURL=noop.mjs.map\n","import { MotionGlobalConfig } from \"motion-utils\";\nimport { frameData } from \"./frame-data\";\nlet now;\nfunction clearTime() {\n now = undefined;\n}\n/**\n * An eventloop-synchronous alternative to performance.now().\n *\n * Ensures that time measurements remain consistent within a synchronous context.\n * Usually calling performance.now() twice within the same synchronous context\n * will return different values which isn't useful for animations when we're usually\n * trying to sync animations to the same frame.\n */\nexport const time = {\n now: () => {\n if (now === undefined) {\n time.set(frameData.isProcessing || MotionGlobalConfig.useManualTiming\n ? frameData.timestamp\n : performance.now());\n }\n return now;\n },\n set: (newTime) => {\n now = newTime;\n queueMicrotask(clearTime);\n },\n};\n//# sourceMappingURL=sync-time.js.map","import { SubscriptionManager, velocityPerSecond, warnOnce, } from \"motion-utils\";\nimport { frame } from \"../frameloop\";\nimport { time } from \"../frameloop/sync-time\";\n/**\n * Maximum time between the value of two frames, beyond which we\n * assume the velocity has since been 0.\n */\nconst MAX_VELOCITY_DELTA = 30;\nconst isFloat = (value) => {\n return !isNaN(parseFloat(value));\n};\nexport const collectMotionValues = {\n current: undefined,\n};\n/**\n * `MotionValue` is used to track the state and velocity of motion values.\n *\n * @public\n */\nexport class MotionValue {\n /**\n * @param init - The initiating value\n * @param config - Optional configuration options\n *\n * - `transformer`: A function to transform incoming values with.\n */\n constructor(init, options = {}) {\n /**\n * Tracks whether this value can output a velocity. Currently this is only true\n * if the value is numerical, but we might be able to widen the scope here and support\n * other value types.\n *\n * @internal\n */\n this.canTrackVelocity = null;\n /**\n * An object containing a SubscriptionManager for each active event.\n */\n this.events = {};\n this.updateAndNotify = (v) => {\n const currentTime = time.now();\n /**\n * If we're updating the value during another frame or eventloop\n * than the previous frame, then the we set the previous frame value\n * to current.\n */\n if (this.updatedAt !== currentTime) {\n this.setPrevFrameValue();\n }\n this.prev = this.current;\n this.setCurrent(v);\n // Update update subscribers\n if (this.current !== this.prev) {\n this.dirty();\n if (this.dependents) {\n for (const dependent of this.dependents) {\n dependent.dirty();\n }\n }\n }\n };\n this.hasAnimated = false;\n this.setCurrent(init);\n this.owner = options.owner;\n }\n setCurrent(current) {\n this.current = current;\n this.updatedAt = time.now();\n if (this.canTrackVelocity === null && current !== undefined) {\n this.canTrackVelocity = isFloat(this.current);\n }\n }\n setPrevFrameValue(prevFrameValue = this.current) {\n this.prevFrameValue = prevFrameValue;\n this.prevUpdatedAt = this.updatedAt;\n }\n /**\n * Adds a function that will be notified when the `MotionValue` is updated.\n *\n * It returns a function that, when called, will cancel the subscription.\n *\n * When calling `onChange` inside a React component, it should be wrapped with the\n * `useEffect` hook. As it returns an unsubscribe function, this should be returned\n * from the `useEffect` function to ensure you don't add duplicate subscribers..\n *\n * ```jsx\n * export const MyComponent = () => {\n * const x = useMotionValue(0)\n * const y = useMotionValue(0)\n * const opacity = useMotionValue(1)\n *\n * useEffect(() => {\n * function updateOpacity() {\n * const maxXY = Math.max(x.get(), y.get())\n * const newOpacity = transform(maxXY, [0, 100], [1, 0])\n * opacity.set(newOpacity)\n * }\n *\n * const unsubscribeX = x.on(\"change\", updateOpacity)\n * const unsubscribeY = y.on(\"change\", updateOpacity)\n *\n * return () => {\n * unsubscribeX()\n * unsubscribeY()\n * }\n * }, [])\n *\n * return <motion.div style={{ x }} />\n * }\n * ```\n *\n * @param subscriber - A function that receives the latest value.\n * @returns A function that, when called, will cancel this subscription.\n *\n * @deprecated\n */\n onChange(subscription) {\n if (process.env.NODE_ENV !== \"production\") {\n warnOnce(false, `value.onChange(callback) is deprecated. Switch to value.on(\"change\", callback).`);\n }\n return this.on(\"change\", subscription);\n }\n on(eventName, callback) {\n var _a;\n if (eventName === \"change\")\n return this.onChangeSubscribe(callback);\n return ((_a = this.events)[eventName] || (_a[eventName] = new SubscriptionManager())).add(callback);\n }\n onChangeSubscribe(callback) {\n const { events } = this;\n if (!events.change && !this.changeSubscriber) {\n this.changeSubscriber = callback;\n }\n else {\n if (!events.change) {\n events.change = new SubscriptionManager();\n events.change.add(this.changeSubscriber);\n this.changeSubscriber = undefined;\n }\n events.change.add(callback);\n }\n return () => {\n if (this.changeSubscriber === callback) {\n this.changeSubscriber = undefined;\n }\n else {\n events.change?.remove(callback);\n }\n this.stopIfUnobserved();\n };\n }\n /**\n * If we have no more change listeners by the start\n * of the next frame, stop active animations.\n */\n stopIfUnobserved() {\n frame.read(() => {\n if (!this.changeSubscriber && !this.events.change?.getSize()) {\n this.stop();\n }\n });\n }\n clearListeners() {\n this.changeSubscriber = undefined;\n for (const eventManagers in this.events) {\n this.events[eventManagers].clear();\n }\n }\n /**\n * Attaches a passive effect to the `MotionValue`.\n */\n attach(passiveEffect, stopPassiveEffect) {\n this.passiveEffect = passiveEffect;\n this.stopPassiveEffect = stopPassiveEffect;\n }\n /**\n * Sets the state of the `MotionValue`.\n *\n * @remarks\n *\n * ```jsx\n * const x = useMotionValue(0)\n * x.set(10)\n * ```\n *\n * @param latest - Latest value to set.\n * @param render - Whether to notify render subscribers. Defaults to `true`\n *\n * @public\n */\n set(v) {\n this.passiveEffect\n ? this.passiveEffect(v, this.updateAndNotify)\n : this.updateAndNotify(v);\n }\n setWithVelocity(prev, current, delta) {\n this.set(current);\n this.prev = undefined;\n this.prevFrameValue = prev;\n this.prevUpdatedAt = this.updatedAt - delta;\n }\n /**\n * Set the state of the `MotionValue`, stopping any active animations,\n * effects, and resets velocity to `0`.\n */\n jump(v, endAnimation = true) {\n if (endAnimation) {\n /**\n * Stop first, as stopping a running animation can set the\n * value it's showing, which would replace v. Marking the value\n * as updated now skips a JS animation's catch-up tick on stop,\n * which could otherwise complete it.\n */\n this.updatedAt = time.now();\n this.stop();\n }\n this.updateAndNotify(v);\n this.prev = v;\n this.prevUpdatedAt = this.prevFrameValue = undefined;\n this.stopPassiveEffect?.();\n }\n dirty() {\n const { current, changeSubscriber } = this;\n /**\n * One or the other exists. Subscribing during the direct\n * subscriber's call moves it into a new manager, which must not\n * then be notified for the same change.\n */\n if (changeSubscriber) {\n changeSubscriber(current);\n }\n else {\n this.events.change?.notify(current);\n }\n }\n addDependent(dependent) {\n ;\n (this.dependents || (this.dependents = new Set())).add(dependent);\n }\n removeDependent(dependent) {\n this.dependents?.delete(dependent);\n }\n /**\n * Returns the latest state of `MotionValue`\n *\n * @returns - The latest state of `MotionValue`\n *\n * @public\n */\n get() {\n collectMotionValues.current?.push(this);\n /**\n * A value animating on the compositor isn't updated every frame,\n * so read it from its animation.\n */\n const sampled = this.animation?.liveValue?.();\n return sampled === undefined ? this.current : sampled;\n }\n /**\n * The value as last set. Unlike get(), this doesn't read an animation\n * running on the compositor, which renders the value itself.\n */\n getCurrent() {\n return this.current;\n }\n /**\n * @public\n */\n getPrevious() {\n return this.prev;\n }\n /**\n * Returns the latest velocity of `MotionValue`\n *\n * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.\n *\n * @public\n */\n getVelocity() {\n const currentTime = time.now();\n if (!this.canTrackVelocity ||\n this.prevFrameValue === undefined ||\n currentTime - this.updatedAt > MAX_VELOCITY_DELTA) {\n return 0;\n }\n const delta = Math.min(this.updatedAt - this.prevUpdatedAt, MAX_VELOCITY_DELTA);\n // Casts because of parseFloat's poor typing\n return velocityPerSecond(parseFloat(this.current) -\n parseFloat(this.prevFrameValue), delta);\n }\n /**\n * Registers a new animation to control this `MotionValue`. Only one\n * animation can drive a `MotionValue` at one time.\n *\n * ```jsx\n * value.start()\n * ```\n *\n * @param animation - A function that starts the provided animation\n */\n start(startAnimation) {\n return new Promise((resolve) => this.run(startAnimation, resolve));\n }\n /**\n * As start(), without making a promise, for animations started\n * internally, which complete through their own controls.\n */\n run(startAnimation, onComplete) {\n this.stop();\n this.hasAnimated = true;\n /**\n * Guard against animations that complete before startAnimation\n * has returned.\n */\n let isComplete = false;\n let animation;\n // eslint-disable-next-line prefer-const -- read by the callback before assignment when completing synchronously\n animation = startAnimation(() => {\n isComplete = true;\n this.events.animationComplete?.notify();\n if (this.animation === animation)\n this.animation = undefined;\n onComplete?.();\n });\n if (!isComplete)\n this.animation = animation;\n this.events.animationStart?.notify();\n }\n /**\n * Stop the currently active animation.\n *\n * @public\n */\n stop() {\n if (this.animation) {\n this.animation.stop();\n this.events.animationCancel?.notify();\n }\n // Assign rather than delete to keep the object's shape stable\n this.animation = undefined;\n }\n /**\n * Returns `true` if this value is currently animating.\n *\n * @public\n */\n isAnimating() {\n return !!this.animation;\n }\n /**\n * Destroy and clean up subscribers to this `MotionValue`.\n *\n * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically\n * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually\n * created a `MotionValue` via the `motionValue` function.\n *\n * @public\n */\n destroy() {\n this.dependents?.clear();\n this.events.destroy?.notify();\n this.clearListeners();\n this.stop();\n this.stopPassiveEffect?.();\n }\n}\nexport function motionValue(init, options) {\n return new MotionValue(init, options);\n}\n//# sourceMappingURL=index.js.map","/*\n Convert velocity into velocity per second\n*/\n/*#__NO_SIDE_EFFECTS__*/\nconst velocityPerSecond = (velocity, frameDuration) => frameDuration ? velocity * (1000 / frameDuration) : 0;\n\nexport { velocityPerSecond };\n//# sourceMappingURL=velocity-per-second.mjs.map\n","import { clamp } from \"motion-utils\";\nexport const number = {\n test: (v) => typeof v === \"number\",\n parse: parseFloat,\n transform: (v) => v,\n};\nexport const alpha = {\n ...number,\n transform: (v) => clamp(0, 1, v),\n};\nexport const scale = {\n ...number,\n default: 1,\n};\n//# sourceMappingURL=index.js.map","import { number } from \"./numbers\";\nexport const int = {\n ...number,\n transform: Math.round,\n};\n//# sourceMappingURL=int.js.map","/*#__NO_SIDE_EFFECTS__*/\nconst createUnitType = (unit) => ({\n test: (v) => typeof v === \"string\" && v.endsWith(unit) && v.split(\" \").length === 1,\n parse: parseFloat,\n transform: (v) => `${v}${unit}`,\n});\nexport const degrees = /*@__PURE__*/ createUnitType(\"deg\");\nexport const percent = /*@__PURE__*/ createUnitType(\"%\");\nexport const px = /*@__PURE__*/ createUnitType(\"px\");\nexport const vh = /*@__PURE__*/ createUnitType(\"vh\");\nexport const vw = /*@__PURE__*/ createUnitType(\"vw\");\nexport const progressPercentage = /*@__PURE__*/ (() => ({\n ...percent,\n parse: (v) => percent.parse(v) / 100,\n transform: (v) => percent.transform(v * 100),\n}))();\n//# sourceMappingURL=units.js.map","import { alpha, scale } from \"../numbers\";\nimport { degrees, progressPercentage, px } from \"../numbers/units\";\nexport const transformValueTypes = {\n rotate: degrees,\n /**\n * Internal channel for `transition.path` orientToPath. Composed onto\n * `rotate` at the transform-build sites so the user's `rotate` is\n * never read or overwritten. Not part of `transformPropOrder`.\n */\n pathRotation: degrees,\n rotateX: degrees,\n rotateY: degrees,\n rotateZ: degrees,\n scale,\n scaleX: scale,\n scaleY: scale,\n scaleZ: scale,\n skew: degrees,\n skewX: degrees,\n skewY: degrees,\n distance: px,\n translateX: px,\n translateY: px,\n translateZ: px,\n x: px,\n y: px,\n z: px,\n perspective: px,\n transformPerspective: px,\n opacity: alpha,\n originX: progressPercentage,\n originY: progressPercentage,\n originZ: px,\n};\n//# sourceMappingURL=transform.js.map","import { int } from \"../int\";\nimport { alpha } from \"../numbers\";\nimport { px } from \"../numbers/units\";\nimport { transformValueTypes } from \"./transform\";\nexport const numberValueTypes = {\n // Border props\n borderWidth: px,\n borderTopWidth: px,\n borderRightWidth: px,\n borderBottomWidth: px,\n borderLeftWidth: px,\n borderRadius: px,\n borderTopLeftRadius: px,\n borderTopRightRadius: px,\n borderBottomRightRadius: px,\n borderBottomLeftRadius: px,\n // Positioning props\n width: px,\n maxWidth: px,\n height: px,\n maxHeight: px,\n top: px,\n right: px,\n bottom: px,\n left: px,\n inset: px,\n insetBlock: px,\n insetBlockStart: px,\n insetBlockEnd: px,\n insetInline: px,\n insetInlineStart: px,\n insetInlineEnd: px,\n // Spacing props\n padding: px,\n paddingTop: px,\n paddingRight: px,\n paddingBottom: px,\n paddingLeft: px,\n paddingBlock: px,\n paddingBlockStart: px,\n paddingBlockEnd: px,\n paddingInline: px,\n paddingInlineStart: px,\n paddingInlineEnd: px,\n margin: px,\n marginTop: px,\n marginRight: px,\n marginBottom: px,\n marginLeft: px,\n marginBlock: px,\n marginBlockStart: px,\n marginBlockEnd: px,\n marginInline: px,\n marginInlineStart: px,\n marginInlineEnd: px,\n // Typography\n fontSize: px,\n // Misc\n backgroundPositionX: px,\n backgroundPositionY: px,\n ...transformValueTypes,\n zIndex: int,\n // SVG\n fillOpacity: alpha,\n strokeOpacity: alpha,\n numOctaves: int,\n};\n//# sourceMappingURL=number.js.map","/**\n * Provided a value and a ValueType, returns the value as that value type.\n */\nexport const getValueAsType = (value, type) => {\n return type && typeof value === \"number\"\n ? type.transform(value)\n : value;\n};\n//# sourceMappingURL=get-as-type.js.map","export const activeScope = {};\n/**\n * Register `cleanup` with the active scope, if there is one, so stopping\n * the scope also runs it.\n */\nexport function addToScope(cleanup) {\n activeScope.current?.add(cleanup);\n return cleanup;\n}\n/**\n * Collect the animation a builder like `animateLayout()` or\n * `animateView()` resolves with. If the scope stops first, the animation\n * is stopped as soon as it starts.\n */\nexport function addBuilderToScope(builder) {\n const scope = activeScope.current;\n if (!scope)\n return;\n let isStopped = false;\n let stop;\n const remove = scope.add(() => {\n isStopped = true;\n stop?.();\n });\n builder.then((animation) => {\n if (!animation)\n return;\n stop = () => animation.stop();\n isStopped ? stop() : animation.finished.then(remove);\n }, remove);\n}\n/**\n * Bind `callback` to the active scope, so anything it starts later (for\n * instance an animation in an `inView()` callback) is collected too.\n */\nexport const bindToScope = (callback) => activeScope.current ? activeScope.current.bind(callback) : callback;\n//# sourceMappingURL=active.js.map","import { frame } from \"../frameloop/frame\";\nexport class MotionValueState {\n /**\n * @param step - The frameloop step renders are scheduled in. Defaults\n * to `frame.render`. Effects that feed a render loop running in\n * `frame.render` (GPU scenes) should write in `frame.preRender`.\n */\n constructor(step = frame.render) {\n this.step = step;\n this.values = new Map();\n /**\n * Renders scheduled for the next flush, usually one or two (values\n * bound to the same computed render, e.g. `x` and `y` to `transform`,\n * share an entry). Tracked with a count rather than truncating the\n * array so no backing store is reallocated every frame. Kept per\n * state so pending writes can be flushed synchronously before the\n * subject is measured.\n */\n this.pending = [];\n this.numPending = 0;\n /**\n * Run the pending renders. Resetting the count first means a render\n * scheduled while flushing lands in the next frame, as with the\n * frameloop itself.\n */\n this.flush = () => {\n const { pending, numPending } = this;\n this.numPending = 0;\n for (let i = 0; i < numPending; i++)\n pending[i]();\n };\n }\n /**\n * @param render - Writes the value to the subject. Renders read the\n * motion value directly rather than a cached copy, so there is one\n * place a value lives.\n * @param computed - A value already in this state (e.g. `transform`)\n * whose render should run whenever `value` changes.\n */\n set(name, value, render, computed) {\n this.values.get(name)?.onRemove();\n if (computed) {\n for (const entry of this.values.values()) {\n if (entry.value === computed)\n render = entry.render;\n }\n }\n const onChange = () => render && this.schedule(render);\n /**\n * Values created ahead of a DOM read start out undefined and\n * have nothing to render until they're set.\n */\n value.get() !== undefined && onChange();\n const cancelOnChange = value.on(\"change\", onChange);\n const onRemove = () => {\n cancelOnChange();\n render && !computed && this.cancel(render);\n /**\n * A later set() of the same name has already removed this\n * entry, so leave the one that replaced it.\n */\n this.values.get(name)?.onRemove === onRemove &&\n this.values.delete(name);\n };\n this.values.set(name, {\n value,\n render: computed ? undefined : render,\n onRemove,\n });\n return onRemove;\n }\n get(name) {\n return this.values.get(name)?.value;\n }\n /**\n * Detach every value from this state and return them, so another\n * renderer can take them over. The state stays cached by its effect,\n * so the bound transforms are reset too rather than leaking into\n * values bound later.\n */\n release() {\n const values = new Map();\n this.values.forEach((entry, name) => {\n values.set(name, entry.value);\n entry.onRemove();\n });\n this.transformKeys = this.transformValues = undefined;\n return values;\n }\n schedule(render) {\n const { pending, numPending } = this;\n for (let i = 0; i < numPending; i++) {\n if (pending[i] === render)\n return;\n }\n numPending || this.step(this.flush);\n pending[this.numPending++] = render;\n }\n cancel(render) {\n const { pending } = this;\n for (let i = 0; i < this.numPending; i++) {\n if (pending[i] === render) {\n pending[i] = pending[--this.numPending];\n return;\n }\n }\n }\n}\n//# sourceMappingURL=MotionValueState.js.map","import { MotionValueState } from \"../MotionValueState\";\nexport function createEffect(addValue, { step, ...options } = {}) {\n const stateCache = new WeakMap();\n const effect = (subject, values) => {\n const state = stateCache.get(subject) ?? new MotionValueState(step);\n stateCache.set(subject, state);\n const subscriptions = [];\n for (const key in values) {\n const value = values[key];\n const remove = addValue(subject, state, key, value);\n subscriptions.push(remove);\n }\n return () => {\n for (const cancel of subscriptions)\n cancel();\n };\n };\n return Object.assign(effect, options, {\n get: (subject, key) => stateCache.get(subject)?.get(key),\n flush: (subject) => stateCache.get(subject)?.flush(),\n state: (subject) => stateCache.get(subject),\n });\n}\n//# sourceMappingURL=create-effect.js.map","import { getValueAsType } from \"../../../value/types/utils/get-as-type\";\nimport { numberValueTypes } from \"../../../value/types/maps/number\";\nimport { transformValueTypes } from \"../../../value/types/maps/transform\";\nimport { transformPropOrder } from \"../../utils/keys-transform\";\nexport const translateAlias = {\n x: \"translateX\",\n y: \"translateY\",\n z: \"translateZ\",\n transformPerspective: \"perspective\",\n};\nconst numTransforms = transformPropOrder.length;\n/**\n * Cache of `translateX(`-style openers so each transform function is a few\n * string concatenations rather than a template.\n */\nconst openers = {};\n/**\n * A transform function, e.g. `translateX(10px)` for `x: 10`.\n */\nexport const transformFunction = (key, value, valueAsType = getValueAsType(value, transformValueTypes[key])) => (openers[key] || (openers[key] = (translateAlias[key] || key) + \"(\")) + valueAsType + \")\";\n/**\n * Whether a transform value is at its default, so can be left out.\n */\nexport const isDefaultTransform = (key, value) => (typeof value === \"number\" ? value : parseFloat(value)) ===\n (key.startsWith(\"scale\") ? 1 : 0);\n/**\n * Build a CSS transform style from individual x/y/scale etc properties.\n *\n * This outputs with a default order of transforms/scales/rotations, this can be customised by\n * providing a transformTemplate function.\n */\nexport function buildTransform(latestValues, transform, transformTemplate) {\n // The transform string we're going to build into.\n let transformString = \"\";\n /**\n * Loop over all possible transforms in order, adding the ones that\n * are present to the transform string.\n */\n for (let i = 0; i < numTransforms; i++) {\n const key = transformPropOrder[i];\n const value = latestValues[key];\n if (value === undefined)\n continue;\n const valueAsType = transformTemplate &&\n (transform[key] = getValueAsType(value, numberValueTypes[key]));\n if (!isDefaultTransform(key, value)) {\n transformString +=\n transformFunction(key, value, valueAsType || undefined) + \" \";\n }\n }\n // `pathRotation` composes onto `rotate` as a separate additive term so\n // the user's `rotate` is never clobbered. Deliberately not a slot in\n // `transformPropOrder`.\n const pathRotation = latestValues.pathRotation;\n if (pathRotation) {\n transformString += transformFunction(\"rotate\", pathRotation);\n }\n transformString = transformString.trim();\n // If we have a custom `transform` template, pass our transform values and\n // generated transformString to that before returning\n return transformTemplate\n ? transformTemplate(transform, transformString)\n : transformString || \"none\";\n}\n//# sourceMappingURL=build-transform.js.map","import { transformGroups } from \"../../animation/waapi/transforms/groups\";\nimport { isCSSVar } from \"../../render/dom/is-css-var\";\nimport { readTransformValue } from \"../../render/dom/parse-transform\";\nimport { transformPropOrder, transformProps, } from \"../../render/utils/keys-transform\";\nimport { isHTMLElement } from \"../../utils/is-html-element\";\nimport { isSVGElement } from \"../../utils/is-svg-element\";\nimport { MotionValue } from \"../../value\";\nimport { numberValueTypes } from \"../../value/types/maps/number\";\nimport { getValueAsType } from \"../../value/types/utils/get-as-type\";\nimport { createSelectorEffect } from \"../utils/create-dom-effect\";\nimport { createEffect } from \"../utils/create-effect\";\nimport { buildTransform } from \"./transform\";\nexport const originProps = new Set([\"originX\", \"originY\", \"originZ\"]);\n/**\n * A bound value in its default unit, e.g. `originX: 50` -> `\"50%\"`.\n */\nconst styleValue = (state, key) => getValueAsType(state.get(key)?.get(), numberValueTypes[key]);\nexport const addStyleValue = (element, state, key, value) => {\n let render = undefined;\n let computed = undefined;\n if (transformProps.has(key)) {\n if (key !== \"pathRotation\") {\n const keys = (state.transformKeys ?? (state.transformKeys = []));\n (state.transformValues ?? (state.transformValues = {}))[key] = value;\n if (!keys.includes(key)) {\n keys.push(key);\n keys.sort((a, b) => transformPropOrder.indexOf(a) -\n transformPropOrder.indexOf(b));\n }\n }\n if (!state.get(\"transform\")) {\n // If this is an HTML element, we need to set the transform-box to fill-box\n // to normalise the transform relative to the element's bounding box\n if (!isHTMLElement(element) && !state.get(\"transformBox\")) {\n addStyleValue(element, state, \"transformBox\", new MotionValue(\"fill-box\"));\n }\n state.set(\"transform\", new MotionValue(\"none\"), () => {\n transformGroups.get(element)?.check();\n element.style.transform = buildTransform(state);\n });\n }\n computed = state.get(\"transform\");\n }\n else if (originProps.has(key)) {\n if (!state.get(\"transformOrigin\")) {\n state.set(\"transformOrigin\", new MotionValue(\"\"), () => {\n const originX = styleValue(state, \"originX\") ?? \"50%\";\n const originY = styleValue(state, \"originY\") ?? \"50%\";\n const originZ = styleValue(state, \"originZ\") ?? 0;\n element.style.transformOrigin = `${originX} ${originY} ${originZ}`;\n });\n }\n computed = state.get(\"transformOrigin\");\n }\n else if (isCSSVar(key)) {\n render = () => {\n element.style.setProperty(key, value.getCurrent());\n };\n }\n else {\n render = () => {\n element.style[key] = getValueAsType(value.getCurrent(), numberValueTypes[key]);\n };\n }\n return state.set(key, value, render, computed);\n};\nconst isStyleSubject = (subject) => isHTMLElement(subject) || isSVGElement(subject);\n/**\n * Reads the current value of a style from the element, as the initial\n * keyframe when `animate()` targets an element via this effect. Transforms\n * are parsed out of the computed matrix; everything else is the computed\n * style. Units aren't converted to match the target keyframes. A style\n * the browser can't report is 0, as a VisualElement reports it.\n */\nexport const readStyleValue = (element, key) => {\n if (transformProps.has(key)) {\n return readTransformValue(element, key);\n }\n const computedStyle = getComputedStyle(element);\n const value = isCSSVar(key)\n ? computedStyle.getPropertyValue(key)\n : computedStyle[key];\n return (typeof value === \"string\" && value.trim()) || 0;\n};\n/**\n * The per-element effect `animate()` binds through, so HTML values share\n * state with a direct `styleEffect()` call. The exported `styleEffect`\n * is this wrapped to also accept selectors.\n */\nexport const styleSubjectEffect = /*@__PURE__*/ createEffect(addStyleValue, {\n test: isStyleSubject,\n read: readStyleValue,\n});\nexport const styleEffect = \n/*@__PURE__*/ createSelectorEffect(styleSubjectEffect);\n//# sourceMappingURL=index.js.map","import { isDefaultTransform, transformFunction, } from \"../../render/html/utils/build-transform\";\nexport function buildTransform(state) {\n let transform = \"\";\n const { transformKeys: keys = [], transformValues: values = {} } = state;\n /**\n * Loop over the bound transforms in order, adding the ones that\n * aren't at their default value to the transform string.\n */\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = values[key].getCurrent();\n if (value === undefined)\n continue;\n if (!isDefaultTransform(key, value)) {\n transform += (transform && \" \") + transformFunction(key, value);\n }\n }\n // See build-transform.ts: additive `rotate()` so user `rotate` isn't\n // clobbered. Not a `transformPropOrder` slot.\n const pathRotation = state.get(\"pathRotation\")?.get();\n if (pathRotation) {\n transform +=\n (transform && \" \") + transformFunction(\"rotate\", pathRotation);\n }\n return transform || \"none\";\n}\n//# sourceMappingURL=transform.js.map","export function camelToDash(str) {\n return str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);\n}\n//# sourceMappingURL=camel-to-dash.js.map","import { buildHTMLStyles } from \"../../html/utils/build-styles\";\nimport { buildSVGPath } from \"./path\";\n/**\n * Values rendered via style rather than as attributes. This must include\n * every value WAAPI can accelerate, as WAAPI writes its final value to\n * style, which would otherwise override later attribute writes.\n */\nexport const cssStyleProperties = [\n \"transform\",\n \"opacity\",\n \"clipPath\",\n \"filter\",\n \"offsetDistance\",\n \"offsetPath\",\n \"offsetRotate\",\n \"offsetAnchor\",\n];\n/**\n * Build SVG visual attributes, like cx and style.transform\n */\nexport function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing = 1, pathOffset = 0, \n// This is object creation, which we try to avoid per-frame.\n...latest }, isSVGTag, transformTemplate, styleProp) {\n buildHTMLStyles(state, latest, transformTemplate);\n /**\n * For svg tags we just want to make sure viewBox is animatable and treat all the styles\n * as normal HTML tags.\n */\n if (isSVGTag) {\n if (state.style.viewBox) {\n state.attrs.viewBox = state.style.viewBox;\n }\n return;\n }\n state.attrs = state.style;\n state.style = {};\n const { attrs, style } = state;\n for (const key of cssStyleProperties) {\n if (attrs[key] !== undefined) {\n style[key] = attrs[key];\n delete attrs[key];\n }\n }\n if (style.transform || attrs.transformOrigin) {\n style.transformOrigin = attrs.transformOrigin ?? \"50% 50%\";\n delete attrs.transformOrigin;\n }\n if (style.transform) {\n /**\n * SVG's element transform-origin uses its own median as a reference.\n * Therefore, transformBox becomes a fill-box\n */\n style.transformBox = styleProp?.transformBox ?? \"fill-box\";\n delete attrs.transformBox;\n }\n // Render attrX/attrY/attrScale as attributes\n if (attrX !== undefined)\n attrs.x = attrX;\n if (attrY !== undefined)\n attrs.y = attrY;\n if (attrScale !== undefined)\n attrs.scale = attrScale;\n // Build SVG path if one has been defined\n if (pathLength !== undefined) {\n buildSVGPath(attrs, pathLength, pathSpacing, pathOffset, false);\n }\n}\n//# sourceMappingURL=build-attrs.js.map","import { camelToDash } from \"../../render/dom/utils/camel-to-dash\";\nimport { numberValueTypes } from \"../../value/types/maps/number\";\nimport { getValueAsType } from \"../../value/types/utils/get-as-type\";\nimport { createSelectorEffect } from \"../utils/create-dom-effect\";\nimport { createEffect } from \"../utils/create-effect\";\nfunction canSetAsProperty(element, name) {\n if (!(name in element))\n return false;\n const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(element), name) ||\n Object.getOwnPropertyDescriptor(element, name);\n // Check if it has a setter\n return descriptor && typeof descriptor.set === \"function\";\n}\n/**\n * `name` is the attribute written when it differs from the key the value\n * is stored under, e.g. `attrX` -> `x`. Numbers take the attribute's\n * default unit (`x: 100` -> `\"100px\"`), as they do when key and name match.\n */\nexport const addAttrValue = (element, state, key, value, name = key) => {\n const isProp = canSetAsProperty(element, name);\n if (!isProp && (name.startsWith(\"data\") || name.startsWith(\"aria\"))) {\n name = camelToDash(name);\n }\n const type = numberValueTypes[key] || numberValueTypes[name];\n /**\n * Set attribute directly via property if available\n */\n const render = isProp\n ? () => {\n ;\n element[name] = getValueAsType(value.get(), numberValueTypes[key]);\n }\n : () => {\n const v = getValueAsType(value.get(), type);\n if (v === null || v === undefined) {\n element.removeAttribute(name);\n }\n else {\n element.setAttribute(name, String(v));\n }\n };\n return state.set(key, value, render);\n};\nexport const attrEffect = /*@__PURE__*/ createSelectorEffect(\n/*@__PURE__*/ createEffect(addAttrValue));\n//# sourceMappingURL=index.js.map","import { frame } from \"../../frameloop\";\nimport { isCSSVar } from \"../../render/dom/is-css-var\";\nimport { camelToDash } from \"../../render/dom/utils/camel-to-dash\";\nimport { cssStyleProperties } from \"../../render/svg/utils/build-attrs\";\nimport { transformProps } from \"../../render/utils/keys-transform\";\nimport { isSVGElement } from \"../../utils/is-svg-element\";\nimport { MotionValue } from \"../../value\";\nimport { numberValueTypes } from \"../../value/types/maps/number\";\nimport { addAttrValue } from \"../attr\";\nimport { addStyleValue, originProps, readStyleValue } from \"../style\";\nimport { createSelectorEffect } from \"../utils/create-dom-effect\";\nimport { createEffect } from \"../utils/create-effect\";\nfunction addSVGPathValue(element, state, key, value) {\n frame.render(() => element.setAttribute(\"pathLength\", \"1\"));\n if (key === \"pathOffset\") {\n return state.set(key, value, () => {\n // Use unitless value to avoid Safari zoom bug\n const offset = value.get();\n element.setAttribute(\"stroke-dashoffset\", `${-offset}`);\n });\n }\n else {\n if (!state.get(\"stroke-dasharray\")) {\n state.set(\"stroke-dasharray\", new MotionValue(\"1 1\"), () => {\n const pathLength = state.get(\"pathLength\")?.get() ?? 1;\n const pathSpacing = state.get(\"pathSpacing\")?.get();\n // Use unitless values to avoid Safari zoom bug\n element.setAttribute(\"stroke-dasharray\", `${pathLength} ${pathSpacing ?? 1 - Number(pathLength)}`);\n });\n }\n return state.set(key, value, undefined, state.get(\"stroke-dasharray\"));\n }\n}\nexport const addSVGValue = (element, state, key, value) => {\n if (key.startsWith(\"path\") && !transformProps.has(key)) {\n return addSVGPathValue(element, state, key, value);\n }\n else if (key.startsWith(\"attr\")) {\n return addAttrValue(element, state, key, value, convertAttrKey(key));\n }\n else if (key === \"d\") {\n /**\n * `d` is a CSS property in Chrome and Firefox, but only as\n * `path(...)`, so path data goes to the attribute, taken out of\n * `path(...)` if it's written that way. Path data itself has no\n * quotes or brackets.\n */\n return state.set(key, value, () => {\n const d = value.get()?.replace(/path\\(|[\"')]/g, \"\");\n d === undefined\n ? element.removeAttribute(key)\n : element.setAttribute(key, d);\n });\n }\n /**\n * Transforms and origins aren't CSS properties (bar `x`/`y` in some\n * browsers), so check them by name rather than `key in element.style`.\n */\n const handler = transformProps.has(key) ||\n originProps.has(key) ||\n isCSSVar(key) ||\n key in element.style\n ? addStyleValue\n : addAttrValue;\n return handler(element, state, key, value);\n};\n/**\n * Reads the current value of `key` from an SVG element as the origin of\n * an animation, as the SVG VisualElement does: transforms start from\n * their defaults, CSS variables and the few CSS-only properties come from\n * computed style, falling back to the attribute when that's empty (e.g.\n * the element isn't rendered), and everything else is read from the\n * attribute, dash-cased (`strokeWidth` -> `stroke-width`) or, failing\n * that, as written (`baseFrequency`).\n */\nexport const readSVGValue = (element, key) => {\n if (transformProps.has(key)) {\n return numberValueTypes[key]?.default || 0;\n }\n if (isCSSVar(key) || cssStyleProperties.includes(key)) {\n return (readStyleValue(element, key) ||\n element.getAttribute(camelToDash(key)) ||\n 0);\n }\n key = convertAttrKey(key);\n return (element.getAttribute(camelToDash(key)) ??\n element.getAttribute(key) ??\n undefined);\n};\n/**\n * The per-element effect `animate()` binds through, so SVG values share\n * state with a direct `svgEffect()` call.\n */\nexport const svgSubjectEffect = /*@__PURE__*/ createEffect(addSVGValue, {\n test: isSVGElement,\n read: readSVGValue,\n});\nexport const svgEffect = /*@__PURE__*/ createSelectorEffect(svgSubjectEffect);\nfunction convertAttrKey(key) {\n return key.replace(/^attr([A-Z])/, (_, firstChar) => firstChar.toLowerCase());\n}\n//# sourceMappingURL=index.js.map","export const visualElementStore = new WeakMap();\n//# sourceMappingURL=store.js.map","/*\n Value in range from progress\n\n Given a lower limit and an upper limit, we return the value within\n that range as expressed by progress (usually a number from 0 to 1)\n\n So progress = 0.5 would change\n\n from -------- to\n\n to\n\n from ---- to\n\n E.g. from = 10, to = 20, progress = 0.5 => 15\n\n @param [number]: Lower limit of range\n @param [number]: Upper limit of range\n @param [number]: The progress between lower and upper limits expressed 0-1\n @return [number]: Value as calculated from progress within range (not limited within range)\n*/\nexport const mixNumber = (from, to, progress) => {\n return from + (to - from) * progress;\n};\n//# sourceMappingURL=number.js.map","export const isDragging = {\n x: false,\n y: false,\n};\nexport function isDragActive() {\n return isDragging.x || isDragging.y;\n}\n//# sourceMappingURL=is-active.js.map","import { calcLength } from \"../../../projection/geometry/delta-calc\";\nimport { mixNumber } from \"../../../utils/mix/number\";\nimport { progress as calcProgress, clamp, } from \"motion-utils\";\n/**\n * Apply constraints to a point. These constraints are both physical along an\n * axis, and an elastic factor that determines how much to constrain the point\n * by if it does lie outside the defined parameters.\n */\nexport function applyConstraints(point, { min, max }, elastic) {\n if (min !== undefined && point < min) {\n // If we have a min point defined, and this is outside of that, constrain\n point = elastic\n ? mixNumber(min, point, elastic.min)\n : Math.max(point, min);\n }\n else if (max !== undefined && point > max) {\n // If we have a max point defined, and this is outside of that, constrain\n point = elastic\n ? mixNumber(max, point, elastic.max)\n : Math.min(point, max);\n }\n return point;\n}\n/**\n * Calculates a min projection point based on a pointer, pointer progress\n * within the drag target, and constraints.\n *\n * For instance if an element was 100px width, we were dragging from 0.25\n * along this axis, the pointer is at 200px, and there were no constraints,\n * we would calculate a min projection point of 175px.\n */\nexport function calcConstrainedMinPoint(point, length, progress, constraints, elastic) {\n // Calculate a min point for this axis and apply it to the current pointer\n const min = point - length * progress;\n return constraints ? applyConstraints(min, constraints, elastic) : min;\n}\n/**\n * Calculate constraints in terms of the viewport when defined relatively to the\n * measured axis. This is measured from the nearest edge, so a max constraint of 200\n * on an axis with a max value of 300 would return a constraint of 500 - axis length\n */\nexport function calcRelativeAxisConstraints(axis, min, max) {\n return {\n min: min !== undefined ? axis.min + min : undefined,\n max: max !== undefined\n ? axis.max + max - (axis.max - axis.min)\n : undefined,\n };\n}\n/**\n * Calculate constraints in terms of the viewport when\n * defined relatively to the measured bounding box.\n */\nexport function calcRelativeConstraints(layoutBox, { top, left, bottom, right }) {\n return {\n x: calcRelativeAxisConstraints(layoutBox.x, left, right),\n y: calcRelativeAxisConstraints(layoutBox.y, top, bottom),\n };\n}\n/**\n * Calculate viewport constraints when defined as another viewport-relative axis\n */\nexport function calcViewportAxisConstraints(layoutAxis, constraintsAxis) {\n let min = constraintsAxis.min - layoutAxis.min;\n let max = constraintsAxis.max - layoutAxis.max;\n // If the constraints axis is actually smaller than the layout axis then we can\n // flip the constraints\n if (constraintsAxis.max - constraintsAxis.min <\n layoutAxis.max - layoutAxis.min) {\n ;\n [min, max] = [max, min];\n }\n return { min, max };\n}\n/**\n * Calculate viewport constraints when defined as another viewport-relative box\n */\nexport function calcViewportConstraints(layoutBox, constraintsBox) {\n return {\n x: calcViewportAxisConstraints(layoutBox.x, constraintsBox.x),\n y: calcViewportAxisConstraints(layoutBox.y, constraintsBox.y),\n };\n}\n/**\n * Calculate a transform origin relative to the source axis, between 0-1, that results\n * in an aesthetically pleasing scale/transform needed to project from source to target.\n */\nexport function calcOrigin(source, target) {\n let origin = 0.5;\n const sourceLength = calcLength(source);\n const targetLength = calcLength(target);\n if (targetLength > sourceLength) {\n origin = calcProgress(target.min, target.max - sourceLength, source.min);\n }\n else if (sourceLength > targetLength) {\n origin = calcProgress(source.min, source.max - targetLength, target.min);\n }\n return clamp(0, 1, origin);\n}\n/**\n * Calculate the relative progress of one constraints box relative to another.\n * Imagine a page scroll bar. At the top, this would return 0, at the bottom, 1.\n * Anywhere in-between, a value between 0 and 1.\n *\n * This also handles flipped constraints, for instance a draggable container within\n * a smaller viewport like a scrollable view.\n */\nexport function calcProgressWithinConstraints(layoutBox, constraintsBox) {\n return {\n x: calcOrigin(layoutBox.x, constraintsBox.x),\n y: calcOrigin(layoutBox.y, constraintsBox.y),\n };\n}\n/**\n * Calculate the an axis position based on two axes and a progress value.\n */\nexport function calcPositionFromProgress(axis, constraints, progress) {\n const axisLength = axis.max - axis.min;\n const min = mixNumber(constraints.min, constraints.max - axisLength, progress);\n return { min, max: min + axisLength };\n}\n/**\n * Rebase the calculated viewport constraints relative to the layout.min point.\n */\nexport function rebaseAxisConstraints(layout, constraints) {\n const relativeConstraints = {};\n if (constraints.min !== undefined) {\n relativeConstraints.min = constraints.min - layout.min;\n }\n if (constraints.max !== undefined) {\n relativeConstraints.max = constraints.max - layout.min;\n }\n return relativeConstraints;\n}\nexport const defaultElastic = 0.35;\n/**\n * Accepts a dragElastic prop and returns resolved elastic values for each axis.\n */\nexport function resolveDragElastic(dragElastic = defaultElastic) {\n if (dragElastic === false) {\n dragElastic = 0;\n }\n else if (dragElastic === true) {\n dragElastic = defaultElastic;\n }\n return {\n x: resolveAxisElastic(dragElastic, \"left\", \"right\"),\n y: resolveAxisElastic(dragElastic, \"top\", \"bottom\"),\n };\n}\nexport function resolveAxisElastic(dragElastic, minLabel, maxLabel) {\n return {\n min: resolvePointElastic(dragElastic, minLabel),\n max: resolvePointElastic(dragElastic, maxLabel),\n };\n}\nexport function resolvePointElastic(dragElastic, label) {\n return typeof dragElastic === \"number\"\n ? dragElastic\n : dragElastic[label] || 0;\n}\n//# sourceMappingURL=constraints.js.map","import { invariant } from \"motion-utils\";\nimport { animateMotionValue } from \"../../animation/interfaces/motion-value\";\nimport { getVariableValue } from \"../../animation/utils/css-variables-conversion\";\nimport { isCSSVariableToken } from \"../../animation/utils/is-css-variable\";\nimport { addDomEvent } from \"../../events/add-dom-event\";\nimport { addPointerEvent } from \"../../events/add-pointer-event\";\nimport { frame } from \"../../frameloop/frame\";\nimport { convertBoundingBoxToBox, convertBoxToBoundingBox, } from \"../../projection/geometry/conversion\";\nimport { calcLength } from \"../../projection/geometry/delta-calc\";\nimport { createBox } from \"../../projection/geometry/models\";\nimport { eachAxis } from \"../../projection/utils/each-axis\";\nimport { measurePageBox } from \"../../projection/utils/measure\";\nimport { resize } from \"../../resize\";\nimport { mixNumber } from \"../../utils/mix/number\";\nimport { percent, px } from \"../../value/types/numbers/units\";\nimport { addValueToWillChange } from \"../../value/will-change/add-will-change\";\nimport { PanSession } from \"../pan/PanSession\";\nimport { isElementTextInput } from \"../press/utils/is-keyboard-accessible\";\nimport { setDragLock } from \"./state/set-active\";\nimport { applyConstraints, calcOrigin, calcRelativeConstraints, calcViewportConstraints, defaultElastic, rebaseAxisConstraints, resolveDragElastic, } from \"./utils/constraints\";\n/**\n * Re-read the scroll of the projection's ancestors, and return that of the\n * `layoutScroll` ones as a key that changes when any of them scroll.\n *\n * Clear the cached scroll first so `updateScroll` bypasses its\n * per-animationId cache and re-reads the live value.\n */\nfunction measureScroll(projection) {\n let key = \"\";\n for (const node of projection.path) {\n node.scroll = undefined;\n node.updateScroll();\n const { scroll } = node;\n if (node !== projection.root && scroll) {\n key += scroll.offset.x + \",\" + scroll.offset.y + \",\";\n }\n }\n return key;\n}\nexport const elementDragControls = new WeakMap();\nexport class VisualElementDragControls {\n constructor(visualElement, readProps = () => visualElement.getProps()) {\n this.openDragLock = null;\n this.isDragging = false;\n this.currentDirection = null;\n /**\n * Where the drag started, which pointer offsets are added to. Public\n * so pinch() can restart a drag from where it leaves the element.\n */\n this.originPoint = { x: 0, y: 0 };\n /**\n * The permitted boundaries of travel, in pixels.\n */\n this.constraints = false;\n this.hasMutatedConstraints = false;\n /**\n * The per-axis resolved elastic values.\n */\n this.elastic = createBox();\n /**\n * The latest pointer event. Used as fallback when the `cancel` and `stop` functions are called without arguments.\n */\n this.latestPointerEvent = null;\n /**\n * The latest pan info. Used as fallback when the `cancel` and `stop` functions are called without arguments.\n */\n this.latestPanInfo = null;\n this.visualElement = visualElement;\n this.readProps = readProps;\n }\n start(originEvent, options = {}) {\n /**\n * Don't start dragging if this component is exiting\n */\n if (this.visualElement.presenceContext?.isPresent === false)\n return;\n const onSessionStart = (event) => {\n if (options.snapToCursor)\n this.snapToCursor(event);\n this.stopAnimation();\n };\n const onStart = (event, info) => {\n // Attempt to grab the global drag gesture lock - maybe make this part of PanSession\n const { drag, dragConstraints, dragPropagation, onDragStart } = this.getProps();\n if (drag && !dragPropagation) {\n this.openDragLock?.();\n this.openDragLock = setDragLock(drag);\n // If we don 't have the lock, don't start dragging\n if (!this.openDragLock)\n return;\n }\n this.latestPointerEvent = event;\n this.latestPanInfo = info;\n this.isDragging = true;\n this.currentDirection = null;\n this.resolveConstraints();\n const { projection } = this.visualElement;\n if (projection) {\n projection.isAnimationBlocked = true;\n projection.target = undefined;\n }\n /**\n * Record gesture origin and pointer offset\n */\n eachAxis((axis) => {\n let current = this.getAxisMotionValue(axis).get() || 0;\n /**\n * If the MotionValue is a CSS variable, like \"var(--y)\",\n * resolve it so it can be converted to px below.\n */\n if (isCSSVariableToken(current)) {\n current =\n getVariableValue(current, this.visualElement.current) || 0;\n }\n /**\n * If the MotionValue is a px or percentage value convert to px\n */\n if (px.test(current)) {\n current = parseFloat(current);\n }\n else if (percent.test(current)) {\n const measuredAxis = projection?.layout?.layoutBox[axis];\n if (measuredAxis) {\n current =\n calcLength(measuredAxis) *\n (parseFloat(current) / 100);\n }\n }\n this.originPoint[axis] = current;\n });\n this.point =\n typeof dragConstraints === \"function\" && dragConstraints(this);\n // Fire onDragStart event\n if (onDragStart) {\n frame.update(() => onDragStart(event, info), false, true);\n }\n addValueToWillChange(this.visualElement, \"transform\");\n this.visualElement.animationState?.setActive(\"whileDrag\", true);\n };\n const onMove = (event, info) => {\n this.latestPointerEvent = event;\n this.latestPanInfo = info;\n const { dragPropagation, dragDirectionLock, onDirectionLock, onDrag, } = this.getProps();\n // If we didn't successfully receive the gesture lock, early return.\n if (!dragPropagation && !this.openDragLock)\n return;\n const { offset } = info;\n // Attempt to detect drag direction if directionLock is true\n if (dragDirectionLock && this.currentDirection === null) {\n this.currentDirection = getCurrentDirection(offset);\n /**\n * Wait for more movement until a direction is set. Once\n * it is, apply this move too: it can be the last before\n * release when the browser coalesces a fast gesture.\n */\n if (this.currentDirection === null)\n return;\n onDirectionLock && onDirectionLock(this.currentDirection);\n }\n // Update each point with the latest position\n this.updateAxis(\"x\", offset);\n this.updateAxis(\"y\", offset);\n this.point && this.point.move();\n /**\n * Ideally we would leave the renderer to fire naturally at the end of\n * this frame but if the element is about to change layout as the result\n * of a re-render we want to ensure the browser can read the latest\n * bounding box to ensure the pointer and element don't fall out of sync.\n */\n this.visualElement.render();\n /**\n * This must fire after the render call as it might trigger a state\n * change which itself might trigger a layout update.\n */\n if (onDrag) {\n frame.update(() => onDrag(event, info), false, true);\n }\n };\n const onSessionEnd = (event, info) => {\n this.latestPointerEvent = event;\n this.latestPanInfo = info;\n this.stop(event, info);\n this.latestPointerEvent = null;\n this.latestPanInfo = null;\n };\n const resumeAnimation = () => {\n const { dragSnapToOrigin: snap } = this.getProps();\n if (snap || this.constraints || this.point) {\n this.startAnimation({ x: 0, y: 0 });\n }\n };\n const { dragSnapToOrigin } = this.getProps();\n this.panSession = new PanSession(originEvent, {\n onSessionStart,\n onStart,\n onMove,\n onSessionEnd,\n resumeAnimation,\n }, {\n ...options,\n transformPagePoint: this.visualElement.getTransformPagePoint(),\n dragSnapToOrigin,\n contextWindow: this.visualElement.current?.ownerDocument.defaultView,\n element: this.visualElement.current,\n });\n }\n /**\n * @param dragAxes - The axes to animate on release, if not the `drag`\n * prop's, e.g. when drag was disabled mid-gesture.\n */\n stop(event, panInfo, dragAxes) {\n const finalEvent = event || this.latestPointerEvent;\n const finalPanInfo = panInfo || this.latestPanInfo;\n const isDragging = this.isDragging;\n this.cancel();\n if (!isDragging || !finalPanInfo || !finalEvent)\n return;\n const { velocity } = finalPanInfo;\n this.startAnimation(velocity, dragAxes);\n const { onDragEnd } = this.getProps();\n if (onDragEnd) {\n frame.postRender(() => onDragEnd(finalEvent, finalPanInfo));\n }\n }\n cancel() {\n this.isDragging = false;\n const { projection, animationState } = this.visualElement;\n if (projection) {\n projection.isAnimationBlocked = false;\n }\n this.endPanSession();\n if (!this.getProps().dragPropagation && this.openDragLock) {\n this.openDragLock();\n this.openDragLock = null;\n }\n animationState?.setActive(\"whileDrag\", false);\n }\n /**\n * Clean up the pan session without modifying other drag state.\n * This is used during unmount to ensure event listeners are removed\n * without affecting projection animations or drag locks.\n */\n endPanSession() {\n this.panSession?.end();\n this.panSession = undefined;\n }\n updateAxis(axis, offset) {\n /**\n * Read drag per axis: a callback fired while updating the x axis\n * can synchronously re-render with new props.\n */\n const { drag } = this.readProps();\n // If we're not dragging this axis, do an early return.\n if (!offset || !shouldDrag(axis, drag, this.currentDirection))\n return;\n const axisValue = this.getAxisMotionValue(axis);\n let next = this.originPoint[axis] + offset[axis];\n // Apply constraints\n const constraints = this.constraints && this.constraints[axis];\n if (constraints) {\n next = applyConstraints(next, constraints, this.elastic[axis]);\n }\n this.point ? (this.point[axis] = next) : axisValue.set(next);\n }\n resolveConstraints() {\n const { dragConstraints, dragElastic } = this.getProps();\n const { projection } = this.visualElement;\n const layout = projection && (projection.layout || projection.measure(false));\n const prevConstraints = this.constraints;\n if (isElementConstraints(dragConstraints)) {\n /**\n * Ref constraints are measured with the layout. Scrolling a\n * `layoutScroll` ancestor since can move the element relative\n * to them without a layout measurement, so measure them again\n * (#2024). Otherwise keep them: they and the layout can both\n * have moved on the page since, e.g. when content above grows.\n */\n if (!this.constraints ||\n this.scroll !== measureScroll(projection)) {\n this.constraints = this.resolveRefConstraints();\n }\n }\n else {\n if (dragConstraints &&\n layout &&\n typeof dragConstraints === \"object\") {\n this.constraints = calcRelativeConstraints(layout.layoutBox, dragConstraints);\n }\n else {\n this.constraints = false;\n }\n }\n this.elastic = resolveDragElastic(dragElastic);\n /**\n * If we're outputting to external MotionValues, we want to rebase the measured constraints\n * from viewport-relative to component-relative. This only applies to relative (non-ref)\n * constraints, as ref-based constraints from calcViewportConstraints are already in the\n * correct coordinate space for the motion value transform offset.\n */\n if (prevConstraints !== this.constraints &&\n !isElementConstraints(dragConstraints) &&\n layout &&\n this.constraints &&\n !this.hasMutatedConstraints) {\n eachAxis((axis) => {\n if (this.constraints !== false &&\n this.getAxisMotionValue(axis)) {\n this.constraints[axis] = rebaseAxisConstraints(layout.layoutBox[axis], this.constraints[axis]);\n }\n });\n }\n }\n resolveRefConstraints() {\n const { dragConstraints: constraints, onMeasureDragConstraints } = this.getProps();\n if (!isElementConstraints(constraints))\n return false;\n const constraintsElement = resolveConstraintsElement(constraints);\n process.env.NODE_ENV !== \"production\" &&\n invariant(!!constraintsElement, \"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.\", \"drag-constraints-ref\");\n const { projection } = this.visualElement;\n // TODO\n if (!projection || !projection.layout)\n return false;\n /**\n * Refresh the scroll offsets of the root and `layoutScroll`\n * ancestors so the constraint's viewport box translates to the\n * layout's coordinates. The scroll captured when the layout was\n * measured can be stale if they've scrolled since — e.g. via the\n * browser restoring scroll on refresh, or an ancestor layout effect\n * running after this element's mount (#2829).\n */\n this.scroll = measureScroll(projection);\n const constraintsBox = measurePageBox(constraintsElement, projection.root, this.visualElement.getTransformPagePoint());\n /**\n * layoutBox removes the scroll of `layoutScroll` ancestors, so\n * remove it from the constraints box too.\n */\n let measuredConstraints = calcViewportConstraints(projection.layout.layoutBox, projection.removeElementScroll(constraintsBox));\n /**\n * If there's an onMeasureDragConstraints listener we call it and\n * if different constraints are returned, set constraints to that\n */\n if (onMeasureDragConstraints) {\n const userConstraints = onMeasureDragConstraints(convertBoxToBoundingBox(measuredConstraints));\n this.hasMutatedConstraints = !!userConstraints;\n if (userConstraints) {\n measuredConstraints = convertBoundingBoxToBox(userConstraints);\n }\n }\n return measuredConstraints;\n }\n startAnimation(velocity, dragAxes) {\n const { drag, dragMomentum, dragElastic, dragTransition, dragSnapToOrigin, onDragTransitionEnd, } = this.getProps();\n /**\n * Overdamp the boundary spring if `dragElastic` is disabled. There's still a frame\n * of spring animations so we should look into adding a disable spring option to `inertia`.\n * We could do something here where we affect the `bounceStiffness` and `bounceDamping`\n * using the value of `dragElastic`.\n */\n const options = {\n bounceStiffness: dragElastic ? 200 : 1000000,\n bounceDamping: dragElastic ? 40 : 10000000,\n timeConstant: 750,\n restDelta: 1,\n restSpeed: 10,\n ...dragTransition,\n };\n const axisVelocity = (axis) => dragMomentum &&\n !(this.point && dragSnapToOrigin) &&\n shouldDrag(axis, dragAxes || drag, this.currentDirection)\n ? velocity[axis]\n : 0;\n if (this.point && !dragSnapToOrigin) {\n return this.point\n .release({ x: axisVelocity(\"x\"), y: axisVelocity(\"y\") }, options)\n .then(onDragTransitionEnd);\n }\n const constraints = this.constraints || {};\n const momentumAnimations = eachAxis((axis) => {\n if (!shouldDrag(axis, dragAxes || drag, this.currentDirection)) {\n return;\n }\n let transition = constraints[axis] || {};\n if (dragSnapToOrigin === true ||\n dragSnapToOrigin === axis)\n transition = { min: 0, max: 0 };\n const inertia = {\n type: \"inertia\",\n velocity: axisVelocity(axis),\n ...options,\n ...transition,\n };\n // If we're not animating on an externally-provided `MotionValue` we can use the\n // component's animation controls which will handle interactions with whileHover (etc),\n // otherwise we just have to animate the `MotionValue` itself.\n return this.startAxisValueAnimation(axis, inertia);\n });\n // Run all animations and then resolve the new drag constraints.\n return Promise.all(momentumAnimations).then(onDragTransitionEnd);\n }\n startAxisValueAnimation(axis, transition) {\n const axisValue = this.getAxisMotionValue(axis);\n addValueToWillChange(this.visualElement, axis);\n return axisValue.start(animateMotionValue(axis, axisValue, 0, transition, this.visualElement, false));\n }\n stopAnimation() {\n eachAxis((axis) => this.getAxisMotionValue(axis).stop());\n }\n /**\n * Drag works differently depending on which props are provided.\n *\n * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.\n * - Otherwise, we apply the delta to the x/y motion values.\n */\n getAxisMotionValue(axis) {\n const dragKey = `_drag${axis.toUpperCase()}`;\n const props = this.readProps();\n const externalMotionValue = props[dragKey];\n return externalMotionValue\n ? externalMotionValue\n : this.visualElement.getValue(axis, this.visualElement.latestValues[axis] ?? 0);\n }\n /**\n * Measure the live box - projection.layout may or may not include the\n * drag transform, depending on when it was measured.\n */\n snapToCursor({ clientX, clientY }) {\n const { drag } = this.getProps();\n const point = { x: clientX, y: clientY };\n const cursor = this.visualElement.getTransformPagePoint()?.(point) || point;\n const box = this.visualElement.measureViewportBox();\n eachAxis((axis) => {\n if (!shouldDrag(axis, drag, this.currentDirection))\n return;\n const axisValue = this.getAxisMotionValue(axis);\n const { min, max } = box[axis];\n axisValue.set((axisValue.get() || 0) + cursor[axis] - mixNumber(min, max, 0.5));\n });\n }\n /**\n * When the viewport resizes we want to check if the measured constraints\n * have changed and, if so, reposition the element within those new constraints\n * relative to where it was before the resize.\n */\n scalePositionWithinConstraints() {\n if (!this.visualElement.current)\n return;\n const { drag, dragConstraints } = this.getProps();\n const { projection } = this.visualElement;\n if (!isElementConstraints(dragConstraints) ||\n !projection ||\n !this.constraints)\n return;\n /**\n * Stop current animations as there can be visual glitching if we try to do\n * this mid-animation\n */\n this.stopAnimation();\n /**\n * Record the relative position of the dragged element relative to the\n * constraints box and save as a progress value.\n */\n const constraints = this.constraints;\n const boxProgress = { x: 0, y: 0 };\n eachAxis((axis) => {\n const latest = this.getAxisMotionValue(axis).get();\n boxProgress[axis] = calcOrigin({ min: latest, max: latest }, constraints[axis]);\n });\n /**\n * Update the layout of this element and resolve the latest drag constraints\n */\n const { transformTemplate } = this.visualElement.getProps();\n this.visualElement.current.style.transform = transformTemplate\n ? transformTemplate({}, \"\")\n : \"none\";\n projection.root?.updateScroll();\n projection.updateLayout();\n /**\n * Reset constraints so resolveConstraints() will recalculate them\n * with the freshly measured layout rather than returning the cached value.\n */\n this.constraints = false;\n this.resolveConstraints();\n /**\n * For each axis, calculate the current progress of the layout axis\n * within the new constraints.\n */\n eachAxis((axis) => {\n const axisValue = this.getAxisMotionValue(axis);\n /**\n * An element resting at its origin has no offset to preserve,\n * and re-projecting 0 into the new constraints would move it.\n */\n if (!shouldDrag(axis, drag, null) || !axisValue.get())\n return;\n /**\n * Calculate a new transform based on the previous box progress\n */\n const { min, max } = this.constraints[axis];\n axisValue.set(mixNumber(min, max, boxProgress[axis]));\n });\n /**\n * Flush the updated transform to the DOM synchronously to prevent\n * a visual flash at the element's CSS layout position (0,0) when\n * the transform was stripped for measurement.\n */\n this.visualElement.render();\n }\n addListeners() {\n if (!this.visualElement.current)\n return;\n elementDragControls.set(this.visualElement, this);\n const element = this.visualElement.current;\n /**\n * Attach a pointerdown event listener on this DOM element to initiate drag tracking.\n */\n const stopPointerListener = addPointerEvent(element, \"pointerdown\", (event) => {\n const { drag, dragListener = true } = this.getProps();\n const target = event.target;\n /**\n * Only block drag if clicking on a text input child element\n * (input, textarea, select, contenteditable) where users might\n * want to select text or interact with the control.\n *\n * Buttons and links don't block drag since they don't have\n * click-and-move actions of their own.\n */\n const isClickingTextInputChild = target !== element && isElementTextInput(target);\n if (drag && dragListener && !isClickingTextInputChild) {\n this.start(event);\n }\n });\n /**\n * If using ref-based constraints, observe both the draggable element\n * and the constraint container for size changes via ResizeObserver.\n * Setup is deferred because dragConstraints.current is null when\n * addListeners first runs (React hasn't committed the ref yet).\n */\n let stopResizeObservers;\n const measureDragConstraints = () => {\n const { dragConstraints } = this.getProps();\n const constraintsElement = isElementConstraints(dragConstraints) &&\n resolveConstraintsElement(dragConstraints);\n if (constraintsElement) {\n this.constraints = this.resolveRefConstraints();\n if (!stopResizeObservers) {\n stopResizeObservers = startResizeObservers(element, constraintsElement, () => this.scalePositionWithinConstraints());\n }\n }\n };\n const { projection } = this.visualElement;\n const stopMeasureLayoutListener = projection.addEventListener(\"measure\", measureDragConstraints);\n if (!projection.layout) {\n projection.root?.updateScroll();\n projection.updateLayout();\n }\n frame.read(measureDragConstraints);\n /**\n * Attach a window resize listener to scale the draggable target within its defined\n * constraints as the window resizes.\n */\n const stopResizeListener = addDomEvent(window, \"resize\", () => this.scalePositionWithinConstraints());\n /**\n * If the element's layout changes, calculate the delta and apply that to\n * the drag gesture's origin point.\n */\n const stopLayoutUpdateListener = projection.addEventListener(\"didUpdate\", (({ delta, hasLayoutChanged }) => {\n if (this.isDragging && hasLayoutChanged) {\n eachAxis((axis) => {\n /**\n * Only compensate axes this gesture drags. A\n * non-drag axis follows its layout instead, as\n * nothing would ever move it back (e.g. snapping\n * to origin only animates drag axes).\n */\n if (!shouldDrag(axis, this.getProps().drag, this.currentDirection))\n return;\n const motionValue = this.getAxisMotionValue(axis);\n this.originPoint[axis] += delta[axis].translate;\n motionValue.set(motionValue.get() + delta[axis].translate);\n });\n this.visualElement.render();\n }\n }));\n return () => {\n stopResizeListener();\n stopPointerListener();\n stopMeasureLayoutListener();\n stopLayoutUpdateListener();\n stopResizeObservers?.();\n };\n }\n getProps() {\n const props = this.readProps();\n const { dragElastic = defaultElastic, dragMomentum = true } = props;\n return { ...props, dragElastic, dragMomentum };\n }\n}\n/**\n * `dragConstraints` can be an element, or a ref (`{ current }`) to one.\n */\nfunction isElementConstraints(constraints) {\n return (!!constraints &&\n typeof constraints === \"object\" &&\n (\"current\" in constraints || \"nodeType\" in constraints));\n}\nconst resolveConstraintsElement = (constraints) => \"current\" in constraints ? constraints.current : constraints;\nfunction skipFirstCall(callback) {\n let isFirst = true;\n return () => {\n if (isFirst) {\n isFirst = false;\n return;\n }\n callback();\n };\n}\nfunction startResizeObservers(element, constraintsElement, onResize) {\n const stopElement = resize(element, skipFirstCall(onResize));\n const stopContainer = resize(constraintsElement, skipFirstCall(onResize));\n return () => {\n stopElement();\n stopContainer();\n };\n}\nfunction shouldDrag(direction, drag, currentDirection) {\n return ((drag === true || drag === direction) &&\n (currentDirection === null || currentDirection === direction));\n}\n/**\n * Based on an x/y offset determine the current drag direction. If both axis' offsets are lower\n * than the provided threshold, return `null`.\n *\n * @param offset - The x/y offset from origin.\n * @param lockThreshold - (Optional) - the minimum absolute offset before we can determine a drag direction.\n */\nfunction getCurrentDirection(offset, lockThreshold = 10) {\n let direction = null;\n if (Math.abs(offset.y) > lockThreshold) {\n direction = \"y\";\n }\n else if (Math.abs(offset.x) > lockThreshold) {\n direction = \"x\";\n }\n return direction;\n}\nexport function expectsResolvedDragConstraints({ dragConstraints, onMeasureDragConstraints, }) {\n return isElementConstraints(dragConstraints) && !!onMeasureDragConstraints;\n}\n//# sourceMappingURL=VisualElementDragControls.js.map","import { clamp } from \"motion-utils\";\nimport { spring } from \"../../animation/generators/spring\";\nimport { readStyleValue, styleSubjectEffect } from \"../../effects/style\";\nimport { svgSubjectEffect } from \"../../effects/svg\";\nimport { cancelFrame, frame } from \"../../frameloop\";\nimport { time } from \"../../frameloop/sync-time\";\nimport { visualElementStore } from \"../../render/store\";\nimport { activeScope, addToScope } from \"../../scope/active\";\nimport { isSVGElement } from \"../../utils/is-svg-element\";\nimport { mixNumber } from \"../../utils/mix/number\";\nimport { resolveElements, } from \"../../utils/resolve-elements\";\nimport { motionValue } from \"../../value\";\nimport { setDragLock } from \"../drag/state/set-active\";\nimport { applyConstraints, defaultElastic } from \"../drag/utils/constraints\";\nimport { elementDragControls } from \"../drag/VisualElementDragControls\";\n/**\n * A trackpad pinch arrives as a stream of `wheel` events with no end\n * event, so it ends once none have arrived for this long.\n */\nconst wheelTimeout = 150;\n/**\n * Convert an `x`/`y` set in other units (e.g. `\"-50%\"` to centre an\n * element) to pixels, so the gesture can add to it.\n */\nconst toPixels = (value, size) => {\n const latest = value.get();\n if (typeof latest === \"string\") {\n value.set(parseFloat(latest) * (latest.endsWith(\"%\") ? size / 100 : 1));\n }\n};\nconst limitsOf = (option) => typeof option === \"object\" ? option : {};\n/**\n * Resolve `elastic` to a resistance for each side, as for `dragElastic`.\n */\nconst resolveElastic = (elastic = defaultElastic) => {\n const side = (value) => value === true ? defaultElastic : +(value || 0);\n return typeof elastic === \"object\"\n ? { min: side(elastic.min), max: side(elastic.max) }\n : { min: side(elastic), max: side(elastic) };\n};\n/**\n * Whether the gesture writes `x`/`y`: to follow the focal point, or to\n * keep an `origin` on the element in place.\n */\nconst writesXY = ({ pan, origin }) => pan !== false || !!origin;\nconst clampTo = (value, { min = -Infinity, max = Infinity }) => clamp(min, max, value);\n/**\n * The raw gesture value that elastic shows as `value`. A pinch that starts\n * while a value is still past its limit (like during a spring back) carries\n * on from it, rather than jumping.\n */\nconst unconstrain = (value, option, resistance) => {\n const limit = clampTo(value, limitsOf(option));\n const elastic = resistance[value < limit ? \"min\" : \"max\"];\n return elastic ? limit + (value - limit) / elastic : value;\n};\n/**\n * Listen for pinch gestures on `element`: two touches (or pens), a trackpad\n * pinch (`wheel` with `ctrlKey`, as Chrome, Edge and Firefox report it),\n * and Safari's `gesture*` events.\n *\n * `getValues` is called each time a gesture starts, in the frame's read\n * step, for the scale/rotate/x/y values to write to. It runs alongside the\n * element measurement so neither forces a layout.\n *\n * `getOptions` is read whenever it's needed, so options can change while\n * listening. Return `false` to disable the gesture, which also ends one in\n * progress.\n *\n * `onPinchStart` is called once as each gesture starts, with the gesture's\n * info as a third argument. It can return the gesture's handlers, as for\n * `pinch()`.\n */\nexport function addPinchListeners(element, getValues, getEnabledOptions, onPinchStart) {\n const pointers = new Map();\n /**\n * The gesture as last reported: focal point, log of a distance and an\n * angle. Only changes in distance and angle matter, so trackpad and\n * Safari input write a virtual distance (the scale) here. Logs keep\n * a long trackpad pinch from overflowing.\n */\n const current = { x: 0, y: 0, l: 0, a: 0 };\n const start = { ...current };\n const prev = { ...current };\n let source;\n let lastEvent;\n let values;\n let originX = 0;\n let originY = 0;\n let width = 0;\n let height = 0;\n let lastX = 0;\n let lastY = 0;\n let hasMoved = false;\n let wheelTime = 0;\n let handlers = {};\n let unlock;\n /**\n * The gesture's scale and rotation before limits and elastic apply.\n */\n let rawScale = 1;\n let rawRotate = 0;\n let stopSnap = () => { };\n /**\n * The latest enabled options, so a gesture disabled mid-way can still\n * report its end.\n */\n let options = {};\n const getOptions = () => (options = getEnabledOptions() || options);\n const info = () => ({\n point: { x: current.x, y: current.y },\n offset: { x: current.x - start.x, y: current.y - start.y },\n scale: Math.exp(current.l - start.l),\n rotate: current.a - start.a,\n });\n /**\n * Read the element's box and values, and find its layout origin: its\n * centre without `x`/`y`. Scale and rotate are applied around the\n * centre (the default transform origin), so they don't move it.\n */\n const measure = () => {\n const box = element.getBoundingClientRect();\n const { left, top } = box;\n const { scale, rotate, elastic } = getOptions();\n const [s, r, x, y] = (values = getValues());\n const resistance = resolveElastic(elastic);\n /**\n * Stop animations on values this gesture writes, and leave the\n * rest running.\n */\n scale !== false && s.stop();\n rotate !== false && r.stop();\n rawScale = unconstrain(s.get(), scale, resistance);\n rawRotate = unconstrain(r.get(), rotate, resistance);\n width = element.offsetWidth ?? box.width;\n height = element.offsetHeight ?? box.height;\n if (writesXY(options)) {\n x.stop();\n y.stop();\n toPixels(x, width);\n toPixels(y, height);\n }\n lastX = x.get();\n lastY = y.get();\n originX = left + box.width / 2 - lastX;\n originY = top + box.height / 2 - lastY;\n };\n /**\n * The point scale and rotation pivot around, in client coordinates:\n * the focal point, or `origin` on the element at scale `s`, rotation\n * `r` and offset `x`/`y`.\n */\n const pivot = (focal, s, r, x, y) => {\n const { origin } = options;\n if (typeof origin !== \"object\")\n return focal;\n const a = (r * Math.PI) / 180;\n const u = (origin.x - 0.5) * width * s;\n const v = (origin.y - 0.5) * height * s;\n return {\n x: originX + x + Math.cos(a) * u - Math.sin(a) * v,\n y: originY + y + Math.sin(a) * u + Math.cos(a) * v,\n };\n };\n const dragControls = () => elementDragControls.get(visualElementStore.get(element));\n /**\n * On release, spring scale and rotation back inside their limits (or\n * to a `snap` angle), keeping the focal point in place, or everything\n * back to its origin with `snapToOrigin`.\n */\n const snap = () => {\n const { scale: scaleOption, rotate: rotateOption, snapToOrigin, transition, } = options;\n const [scale, rotate, x, y] = values;\n const s0 = scale.get();\n const r0 = rotate.get();\n const x0 = x.get();\n const y0 = y.get();\n const { snap: step } = limitsOf(rotateOption);\n let s1 = clampTo(s0, limitsOf(scaleOption));\n /**\n * Snap to the step nearest where the release velocity would carry\n * the rotation, found as inertia finds its target (with a lower power\n * than inertia's 0.8).\n */\n let r1 = clampTo(step\n ? Math.round((r0 + 0.2 * rotate.getVelocity()) / step) * step\n : r0, limitsOf(rotateOption));\n if (snapToOrigin) {\n s1 = 1;\n // The nearest upright angle, so it turns the shortest way\n r1 = Math.round(r0 / 360) * 360;\n }\n /**\n * Keep the focal point in place, unless the element doesn't move\n * with it, or a drag carries on and owns x/y.\n */\n const moves = writesXY(options) && !dragControls()?.isDragging;\n const p0 = pivot(current, s0, r0, x0, y0);\n const vx = originX + x0 - p0.x;\n const vy = originY + y0 - p0.y;\n /**\n * Scale, rotation and x/y at progress `p` of the snap, keeping the\n * focal point in place.\n */\n const at = (p) => {\n const k = mixNumber(s0, s1, p);\n const r = mixNumber(r0, r1, p);\n const angle = ((r - r0) * Math.PI) / 180;\n const cos = (Math.cos(angle) * k) / s0;\n const sin = (Math.sin(angle) * k) / s0;\n return [\n k,\n r,\n x0 + cos * vx - sin * vy - vx,\n y0 + sin * vx + cos * vy - vy,\n ];\n };\n if (!s0 ||\n (s1 === s0 && r1 === r0 && !(snapToOrigin && moves && (x0 || y0)))) {\n return;\n }\n const generator = spring({\n keyframes: [0, 1],\n stiffness: 200,\n damping: 40,\n ...transition,\n });\n const startTime = time.now();\n /**\n * Drive the values from one spring, from 0 to 1, so they stay in\n * step and the focal point stays in place.\n */\n const tick = () => {\n if (dragControls()?.isDragging)\n return stopSnap();\n const { value: p, done } = generator.next(time.now() - startTime);\n if (done)\n stopSnap();\n const [k, r, fx, fy] = at(p);\n scaleOption !== false && scale.set(k);\n rotateOption !== false && rotate.set(r);\n if (moves) {\n x.set(snapToOrigin ? mixNumber(x0, 0, p) : fx);\n y.set(snapToOrigin ? mixNumber(y0, 0, p) : fy);\n }\n };\n stopSnap = () => cancelFrame(tick);\n frame.update(tick, true);\n };\n /**\n * Apply the change in the gesture since the last frame as an\n * incremental scale and rotation around the previous focal point,\n * plus the focal point's movement.\n */\n const apply = () => {\n if (!values || !hasMoved)\n return;\n hasMoved = false;\n const { rotate: rotateOption, scale: scaleOption, pan, elastic, } = getOptions();\n const [scale, rotate, x, y] = values;\n const resistance = resolveElastic(elastic);\n const latest = scale.get();\n const drag = dragControls();\n const isDragging = drag?.isDragging;\n if (!isDragging) {\n lastX = x.get();\n lastY = y.get();\n }\n const p = pivot(prev, latest, rotate.get(), lastX, lastY);\n let theta = 0;\n let k = 1;\n /**\n * Apply limits and elastic to the gesture's raw scale and rotation.\n * At a hard limit, the raw value stops too, so moving back responds\n * straight away.\n */\n const constrain = (raw, option) => {\n const limits = limitsOf(option);\n const limit = clampTo(raw, limits);\n return resistance[raw < limit ? \"min\" : \"max\"]\n ? [applyConstraints(raw, limits, resistance), raw]\n : [limit, limit];\n };\n if (scaleOption !== false && latest) {\n const [next, raw] = constrain(clamp(1e-9, 1e9, rawScale * Math.exp(current.l - prev.l)), scaleOption);\n rawScale = raw;\n k = next / latest;\n scale.set(next);\n }\n if (rotateOption !== false) {\n const [next, raw] = constrain(rawRotate + current.a - prev.a, rotateOption);\n rawRotate = raw;\n theta = next - rotate.get();\n if (theta)\n rotate.set(next);\n }\n if (writesXY(options)) {\n /**\n * Pinch owns x/y while it runs, so stop any animation started\n * on them since (like a drag's snap back) taking over after.\n */\n x.stop();\n y.stop();\n /**\n * If drag() or the drag prop is dragging this element with one\n * of the touches, it has set x/y this frame to where it started\n * plus the touch's offset. Carry on from our own values instead,\n * and restart the drag from them and the touch's latest point.\n * That way it continues from wherever the pinch leaves the\n * element, and its release velocity only counts movement after\n * the pinch, so a zoom doesn't end in a fling.\n */\n const angle = (theta * Math.PI) / 180;\n const cos = Math.cos(angle) * k;\n const sin = Math.sin(angle) * k;\n const dx = p.x - originX - lastX;\n const dy = p.y - originY - lastY;\n const panX = pan !== false ? current.x - prev.x : 0;\n const panY = pan !== false ? current.y - prev.y : 0;\n /**\n * Move the centre so the pivot, scaled and rotated around the\n * centre, stays in place, plus the focal point's movement.\n */\n lastX += dx + panX - (cos * dx - sin * dy);\n lastY += dy + panY - (sin * dx + cos * dy);\n if (isDragging) {\n const history = drag.panSession.history;\n history.splice(0, history.length - 1);\n /**\n * Date the point long ago, so drag only measures release\n * velocity from moves after the pinch. A move that drag\n * processes as the touch lifts is part of the pinch.\n */\n history[0].timestamp = -Infinity;\n drag.originPoint.x = lastX;\n drag.originPoint.y = lastY;\n }\n x.set(lastX);\n y.set(lastY);\n }\n Object.assign(prev, current);\n handlers.onPinch?.(lastEvent, info());\n };\n /**\n * Runs after the update step, where drag sets x/y, so it has the final\n * say on them each frame.\n */\n const update = () => {\n if (!getEnabledOptions())\n return end(lastEvent);\n apply();\n if (source === \"wheel\" && time.now() - wheelTime > wheelTimeout) {\n end(lastEvent);\n }\n };\n const begin = (event, from) => {\n if (!getEnabledOptions())\n return;\n stopSnap();\n source = from;\n lastEvent = event;\n hasMoved = false;\n values = undefined;\n handlers = {};\n Object.assign(start, current);\n Object.assign(prev, current);\n frame.read(measure);\n frame.preRender(update, true);\n const result = onPinchStart(element, event, info());\n handlers =\n typeof result === \"function\" ? { onComplete: result } : result || {};\n };\n const end = (event) => {\n if (!source)\n return;\n cancelFrame(measure);\n cancelFrame(update);\n if (getEnabledOptions()) {\n apply();\n values && snap();\n }\n source = undefined;\n handlers.onComplete?.(event, info());\n };\n const moved = (event) => {\n lastEvent = event;\n hasMoved = true;\n };\n const readPointers = () => {\n const [a, b] = pointers.values();\n const angle = (Math.atan2(b.y - a.y, b.x - a.x) * 180) / Math.PI;\n const delta = angle - current.a;\n current.x = (a.x + b.x) / 2;\n current.y = (a.y + b.y) / 2;\n current.l = Math.log(Math.hypot(b.x - a.x, b.y - a.y) || 1);\n /**\n * Take the shortest way round, so rotation keeps counting past\n * 180deg rather than flipping to -180deg.\n */\n current.a += delta - 360 * Math.round(delta / 360);\n };\n const setPointer = (event) => pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });\n const onPointerMove = (event) => {\n if (!pointers.has(event.pointerId))\n return;\n setPointer(event);\n if (source === \"pointer\") {\n readPointers();\n moved(event);\n }\n };\n const onPointerUp = (event) => {\n if (!pointers.delete(event.pointerId))\n return;\n if (source === \"pointer\")\n end(event);\n if (!pointers.size) {\n toggleWindowListeners();\n release();\n }\n };\n /**\n * Once a touch is down on the element, listen on the window too, so\n * the second touch can land beside it (for instance on a small image).\n */\n const onPointerDown = (event) => {\n if (source ||\n pointers.size > 1 ||\n pointers.has(event.pointerId) ||\n event.pointerType === \"mouse\") {\n return;\n }\n if (!pointers.size)\n toggleWindowListeners(true);\n setPointer(event);\n if (pointers.size === 2) {\n readPointers();\n begin(event, \"pointer\");\n /**\n * Unless this element drags, hold the drag lock until every\n * touch lifts. A press on it then ends as a cancel, rather than\n * a tap, and a draggable parent doesn't drag.\n */\n if (source &&\n !unlock &&\n !elementDragControls.get(visualElementStore.get(element))) {\n unlock = setDragLock(true);\n }\n }\n };\n /**\n * Release the drag lock a frame later, so a press ending on this same\n * pointerup still sees it.\n */\n const release = () => {\n const done = unlock;\n unlock = undefined;\n done && frame.postRender(done);\n };\n const toggleWindowListeners = (add) => {\n const method = add ? \"addEventListener\" : \"removeEventListener\";\n window[method](\"pointerdown\", onPointerDown);\n window[method](\"pointermove\", onPointerMove);\n window[method](\"pointerup\", onPointerUp);\n window[method](\"pointercancel\", onPointerUp);\n };\n const onWheel = (event) => {\n if (!event.ctrlKey || (source && source !== \"wheel\"))\n return;\n current.x = event.clientX;\n current.y = event.clientY;\n if (!source) {\n current.l = 0;\n begin(event, \"wheel\");\n if (!source)\n return;\n }\n event.preventDefault();\n /**\n * Lines (Firefox's mouse wheel) to pixels, and cap each event so a\n * mouse wheel notch with ctrl held (about 100px) zooms a step.\n */\n current.l -=\n clamp(-50, 50, event.deltaY * (event.deltaMode ? 16 : 1)) / 100;\n wheelTime = time.now();\n moved(event);\n };\n /**\n * Safari reports trackpad pinches as `gesture*` events. iOS Safari\n * fires them for touches too, alongside the pointer events we track.\n */\n const onGesture = (event) => {\n if (!pointers.size && (!source || source === \"gesture\")) {\n const { scale, rotation, clientX, clientY } = event;\n current.x = clientX;\n current.y = clientY;\n current.l = Math.log(scale);\n current.a = rotation;\n if (source) {\n moved(event);\n if (event.type === \"gestureend\")\n end(event);\n }\n else if (event.type === \"gesturestart\") {\n begin(event, \"gesture\");\n }\n }\n if (source)\n event.preventDefault();\n };\n const listeners = {\n pointerdown: onPointerDown,\n wheel: onWheel,\n gesturestart: onGesture,\n gesturechange: onGesture,\n gestureend: onGesture,\n };\n for (const name in listeners) {\n element.addEventListener(name, listeners[name], { passive: false });\n }\n return () => {\n for (const name in listeners) {\n element.removeEventListener(name, listeners[name]);\n }\n toggleWindowListeners();\n end(lastEvent);\n stopSnap();\n pointers.clear();\n release();\n };\n}\nconst valueKeys = [\"scale\", \"rotate\", \"x\", \"y\"];\n/**\n * The element's scale/rotate/x/y motion values: those of its\n * VisualElement if it has one (it's a <motion.*> component, or drag() or\n * animateLayout() own it), otherwise those animate() binds to it, created\n * from its current style if this is the first time.\n */\nconst getElementValues = (element) => {\n const visualElement = visualElementStore.get(element);\n const effect = isSVGElement(element) ? svgSubjectEffect : styleSubjectEffect;\n return valueKeys.map((key) => {\n if (visualElement) {\n return visualElement.getValue(key, key === \"scale\" ? 1 : 0);\n }\n let value = effect.get(element, key);\n if (!value) {\n value = motionValue(readStyleValue(element, key));\n effect(element, { [key]: value });\n }\n return value;\n });\n};\nexport function pinch(elementOrSelector, startOrOptions, options = {}) {\n let onPinchStart = () => { };\n if (typeof startOrOptions === \"function\") {\n onPinchStart = startOrOptions;\n }\n else if (startOrOptions) {\n options = startOrOptions;\n }\n const scope = activeScope.current;\n /**\n * Run the start callback and the handlers it returns in the active\n * scope, so work they start is collected. A returned function is\n * bound by `scope.bind` itself.\n */\n if (scope) {\n const start = scope.bind(onPinchStart);\n onPinchStart = (element, event) => {\n const result = start(element, event);\n if (typeof result !== \"object\")\n return result;\n const handlers = {};\n for (const key in result) {\n const name = key;\n const handler = result[name];\n handlers[name] = handler && scope.bind(handler);\n }\n return handlers;\n };\n }\n const cleanups = resolveElements(elementOrSelector).map((element) => {\n scope?.track(element);\n const { style } = element;\n const touchAction = style.touchAction;\n style.touchAction = \"none\";\n const remove = addPinchListeners(element, () => getElementValues(element), () => options, onPinchStart);\n return () => {\n remove();\n style.touchAction = touchAction;\n };\n });\n return addToScope(() => cleanups.forEach((cleanup) => cleanup()));\n}\n//# sourceMappingURL=index.js.map","import { isDragging } from \"./is-active\";\nexport function setDragLock(axis) {\n if (axis === \"x\" || axis === \"y\") {\n if (isDragging[axis]) {\n return null;\n }\n else {\n isDragging[axis] = true;\n return () => {\n isDragging[axis] = false;\n };\n }\n }\n else {\n if (isDragging.x || isDragging.y) {\n return null;\n }\n else {\n isDragging.x = isDragging.y = true;\n return () => {\n isDragging.x = isDragging.y = false;\n };\n }\n }\n}\n//# sourceMappingURL=set-active.js.map","import { activeScope } from \"../scope/active\";\nexport function resolveElements(elementOrSelector, scope, selectorCache) {\n if (elementOrSelector == null) {\n return [];\n }\n if (elementOrSelector instanceof EventTarget) {\n return [elementOrSelector];\n }\n else if (typeof elementOrSelector === \"string\") {\n const root = scope\n ? scope.current\n : activeScope.current?.root || document;\n const elements = selectorCache?.[elementOrSelector] ??\n root.querySelectorAll(elementOrSelector);\n return elements ? Array.from(elements) : [];\n }\n return Array.from(elementOrSelector).filter((element) => element != null);\n}\n//# sourceMappingURL=resolve-elements.js.map"],"names":["clamp","min","max","v","MotionGlobalConfig","isObject","value","SubscriptionManager","constructor","this","subscriptions","add","handler","arr","item","indexOf","push","remove","index","splice","removeItem","notify","a","b","c","numSubscriptions","length","i","getSize","clear","secondsToMilliseconds","seconds","millisecondsToSeconds","milliseconds","maxGeneratorDuration","calcGeneratorDuration","generator","timeStep","maxDuration","keyframes","duration","state","next","done","Infinity","bounceToDampingRatio","bounce","Math","overdampedFreqScale","dampingRatio","criticalFreqTime","root","sqrt","slow","fast","target","exp","approximateRoot","freqTime","calcAngularFreq","undampedFreq","rootIterations","envelope","derivative","initialGuess","result","safeMin","isValidPhysics","canBeZero","resolvePhysics","getSpringOptions","options","validStiffness","stiffness","validDamping","damping","validMass","mass","springOptions","isResolvedFromDuration","isTimeDefined","undefined","visualDuration","PI","Object","assign","exponentialDecay","delta","e","f","g","criticalFreq","findSpring","springGenerator","optionsOrVisualDuration","origin","inheritVelocity","velocity","undampedAngularFreq","decay","s","restSpeed","restDelta","setRestThresholds","isGranularScale","abs","resolveSpring","resolveVelocity","update","angularFreq","A","sinC","cosC","t","env","sin","cos","sample","C","dampedAngularFreq","limit","decayAt","rate","S","F","P","calculatedDuration","retarget","newVelocity","current","currentVelocity","toString","easingDuration","easing","resolution","points","numPoints","round","substring","generateLinearEasing","progress","spring","applyToOptions","generatorOptions","scale","createGenerator","k","type","ease","createGeneratorEasing","transformGroups","WeakMap","isCSSVar","name","startsWith","radToDeg","rad","rotate","angle","atan2","rebaseAngle","matrix2dParsers","x","y","translateX","translateY","scaleX","scaleY","scaleZ","rotateZ","skewX","atan","skewY","skew","hypot","matrix3dParsers","z","translateZ","rotateX","rotateY","defaultTransformValue","includes","readTransformValue","instance","transform","getComputedStyle","match","valueParser","values","split","map","parseFloat","parseValueFromTransform","transformPropOrder","transformProps","Set","isHTMLElement","element","isSVGElement","stepsOrder","createRenderBatcher","scheduleNextBatch","allowKeepAlive","timestamp","isProcessing","runNextFrame","useDefaultElapsed","flagRunNextFrame","steps","reduce","acc","key","running","thisFrame","nextFrame","flushNextFrame","toKeepAlive","latestFrameData","triggerCallback","callback","has","step","schedule","keepAlive","immediate","addToCurrentFrame","queue","delete","cancel","process","frameData","prevFrame","forEach","createRenderStep","setup","read","resolveKeyframes","preUpdate","preRender","render","postRender","processBatch","useManualTiming","performance","now","frame","cancelFrame","requestAnimationFrame","any","clearTime","time","set","newTime","queueMicrotask","MotionValue","init","canTrackVelocity","events","updateAndNotify","currentTime","updatedAt","setPrevFrameValue","prev","setCurrent","dirty","dependents","dependent","hasAnimated","owner","isNaN","prevFrameValue","prevUpdatedAt","onChange","subscription","on","eventName","_a","onChangeSubscribe","change","changeSubscriber","stopIfUnobserved","stop","clearListeners","eventManagers","attach","passiveEffect","stopPassiveEffect","setWithVelocity","jump","endAnimation","addDependent","removeDependent","get","sampled","animation","liveValue","getCurrent","getPrevious","getVelocity","frameDuration","start","startAnimation","Promise","resolve","run","onComplete","isComplete","animationComplete","animationStart","animationCancel","isAnimating","destroy","number","test","parse","alpha","default","int","createUnitType","unit","endsWith","degrees","percent","px","progressPercentage","transformValueTypes","pathRotation","distance","perspective","transformPerspective","opacity","originX","originY","originZ","numberValueTypes","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","width","maxWidth","height","maxHeight","top","right","bottom","left","inset","insetBlock","insetBlockStart","insetBlockEnd","insetInline","insetInlineStart","insetInlineEnd","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingBlock","paddingBlockStart","paddingBlockEnd","paddingInline","paddingInlineStart","paddingInlineEnd","margin","marginTop","marginRight","marginBottom","marginLeft","marginBlock","marginBlockStart","marginBlockEnd","marginInline","marginInlineStart","marginInlineEnd","fontSize","backgroundPositionX","backgroundPositionY","zIndex","fillOpacity","strokeOpacity","numOctaves","getValueAsType","activeScope","MotionValueState","Map","pending","numPending","flush","computed","onRemove","entry","cancelOnChange","release","transformKeys","transformValues","createEffect","addValue","stateCache","subject","translateAlias","openers","transformFunction","valueAsType","isDefaultTransform","originProps","styleValue","addStyleValue","keys","sort","check","style","buildTransform","transformOrigin","setProperty","readStyleValue","computedStyle","getPropertyValue","trim","styleSubjectEffect","camelToDash","str","replace","toLowerCase","cssStyleProperties","addAttrValue","isProp","descriptor","getOwnPropertyDescriptor","getPrototypeOf","canSetAsProperty","removeAttribute","setAttribute","String","svgSubjectEffect","offset","pathLength","pathSpacing","Number","addSVGPathValue","convertAttrKey","d","getAttribute","_","firstChar","visualElementStore","mixNumber","from","to","isDragging","applyConstraints","point","elastic","elementDragControls","toPixels","size","latest","limitsOf","option","resolveElastic","side","writesXY","pan","clampTo","unconstrain","resistance","addPinchListeners","getValues","getEnabledOptions","onPinchStart","pointers","l","source","lastEvent","unlock","lastX","lastY","hasMoved","wheelTime","handlers","rawScale","rawRotate","stopSnap","getOptions","info","measure","box","getBoundingClientRect","r","offsetWidth","offsetHeight","pivot","focal","u","dragControls","snap","scaleOption","rotateOption","snapToOrigin","transition","s0","r0","x0","y0","s1","r1","moves","p0","vx","vy","startTime","tick","p","fx","fy","at","apply","drag","theta","constrain","raw","limits","dx","dy","panX","panY","history","panSession","originPoint","onPinch","end","begin","event","moved","readPointers","log","setPointer","pointerId","clientX","clientY","onPointerMove","onPointerUp","toggleWindowListeners","onPointerDown","pointerType","method","window","onGesture","rotation","preventDefault","listeners","pointerdown","wheel","ctrlKey","deltaY","deltaMode","gesturestart","gesturechange","gestureend","addEventListener","passive","removeEventListener","valueKeys","getElementValues","visualElement","effect","getValue","pinch","elementOrSelector","startOrOptions","scope","bind","cleanups","selectorCache","EventTarget","document","elements","querySelectorAll","Array","filter","resolveElements","track","touchAction","cleanup"],"mappings":"AAAA,MAAMA,EAAQ,CAACC,EAAKC,EAAKC,IACjBA,EAAID,EACGA,EACPC,EAAIF,EACGA,EACJE,ECLLC,EAAqB,CAAA,ECArBC,EAAYC,GAA2B,iBAAVA,GAAgC,OAAVA,ECEzD,MAAMC,EACF,WAAAC,GACIC,KAAKC,cAAgB,EACzB,CACA,GAAAC,CAAIC,GCNR,IAAuBC,EAAKC,EDQpB,OCReD,EDODJ,KAAKC,cCPCI,EDOcF,GCNZ,IAAtBC,EAAIE,QAAQD,IACZD,EAAIG,KAAKF,GDMF,IAAML,KAAKQ,OAAOL,EAC7B,CACA,MAAAK,CAAOL,ICNX,SAAoBC,EAAKC,GACrB,MAAMI,EAAQL,EAAIE,QA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AUqD,EAAOwF,GACvB6U,EAAS7U,GAAQ7I,GAAWqjB,EAAMC,KAAKtjB,EAC3C,CACA,OAAO0d,EAEf,CACA,MAAM6F,EErkBH,SAAyBJ,EAAmBE,EAAOG,GACtD,GAAyB,MAArBL,EACA,MAAO,GAEX,GAAIA,aAA6BM,YAC7B,MAAO,CAACN,GAEP,GAAiC,iBAAtBA,EAAgC,CAC5C,MAAM5gB,EAAO8gB,EACPA,EAAMhc,QACNqQ,GAAYrQ,SAAS9E,MAAQmhB,SAC7BC,EAAWH,IAAgBL,IAC7B5gB,EAAKqhB,iBAAiBT,GAC1B,OAAOQ,EAAWE,MAAMnI,KAAKiI,GAAY,EAC7C,CACA,OAAOE,MAAMnI,KAAKyH,GAAmBW,OAAQrY,GAAuB,MAAXA,EAC7D,CFqjBqBsY,CAAgBZ,GAAmBjY,IAAKO,IACrD4X,GAAOW,MAAMvY,GACb,MAAM6N,MAAEA,GAAU7N,EACZwY,EAAc3K,EAAM2K,YAC1B3K,EAAM2K,YAAc,OACpB,MAAM5jB,EAASwc,GAAkBpR,EAAS,IAAMqX,GAAiBrX,GAAU,IAAM9H,EAASqZ,GAC1F,MAAO,KACH3c,IACAiZ,EAAM2K,YAAcA,KAG5B,Of5kBuBC,Ee4kBL,IAAMX,EAAS3V,QAASsW,GAAYA,Kf3kBtDxM,GAAYrQ,SAAStH,IAAImkB,GAClBA,EAFJ,IAAoBA,Ce6kB3B"}
1
+ {"version":3,"file":"size-rollup-pinch.js","sources":["../../motion-utils/dist/es/clamp.mjs","../../motion-utils/dist/es/global-config.mjs","../../motion-utils/dist/es/is-object.mjs","../../motion-utils/dist/es/subscription-manager.mjs","../../motion-utils/dist/es/array.mjs","../../motion-utils/dist/es/time-conversion.mjs","../lib/animation/generators/utils/calc-duration.js","../lib/animation/generators/spring.js","../lib/animation/waapi/utils/linear.js","../lib/animation/generators/utils/create-generator-easing.js","../lib/animation/waapi/transforms/groups.js","../lib/render/dom/is-css-var.js","../lib/render/dom/parse-transform.js","../lib/render/utils/keys-transform.js","../lib/utils/is-html-element.js","../lib/utils/is-svg-element.js","../lib/frameloop/order.js","../lib/frameloop/batcher.js","../lib/frameloop/render-step.js","../lib/frameloop/frame-data.js","../lib/frameloop/frame.js","../../motion-utils/dist/es/noop.mjs","../lib/frameloop/sync-time.js","../lib/value/index.js","../../motion-utils/dist/es/velocity-per-second.mjs","../lib/value/types/numbers/index.js","../lib/value/types/int.js","../lib/value/types/numbers/units.js","../lib/value/types/maps/transform.js","../lib/value/types/maps/number.js","../lib/value/types/utils/get-as-type.js","../lib/scope/active.js","../lib/effects/MotionValueState.js","../lib/effects/utils/create-effect.js","../lib/render/html/utils/build-transform.js","../lib/effects/style/index.js","../lib/effects/style/transform.js","../lib/render/dom/utils/camel-to-dash.js","../lib/render/svg/utils/build-attrs.js","../lib/effects/attr/index.js","../lib/effects/svg/index.js","../lib/render/store.js","../lib/utils/mix/number.js","../lib/gestures/drag/state/is-active.js","../lib/gestures/drag/utils/constraints.js","../lib/gestures/drag/VisualElementDragControls.js","../lib/gestures/pinch/index.js","../lib/gestures/drag/state/set-active.js","../lib/utils/resolve-elements.js"],"sourcesContent":["const clamp = (min, max, v) => {\n if (v > max)\n return max;\n if (v < min)\n return min;\n return v;\n};\n\nexport { clamp };\n//# sourceMappingURL=clamp.mjs.map\n","const MotionGlobalConfig = {};\n\nexport { MotionGlobalConfig };\n//# sourceMappingURL=global-config.mjs.map\n","const isObject = (value) => typeof value === \"object\" && value !== null;\n\nexport { isObject };\n//# sourceMappingURL=is-object.mjs.map\n","import { addUniqueItem, removeItem } from './array.mjs';\n\nclass SubscriptionManager {\n constructor() {\n this.subscriptions = [];\n }\n add(handler) {\n addUniqueItem(this.subscriptions, handler);\n return () => this.remove(handler);\n }\n remove(handler) {\n removeItem(this.subscriptions, handler);\n }\n notify(a, b, c) {\n const numSubscriptions = this.subscriptions.length;\n if (!numSubscriptions)\n return;\n if (numSubscriptions === 1) {\n /**\n * If there's only a single handler we can just call it without invoking a loop.\n */\n this.subscriptions[0](a, b, c);\n }\n else {\n for (let i = 0; i < numSubscriptions; i++) {\n /**\n * Check whether the handler exists before firing as it's possible\n * the subscriptions were modified during this loop running.\n */\n const handler = this.subscriptions[i];\n handler && handler(a, b, c);\n }\n }\n }\n getSize() {\n return this.subscriptions.length;\n }\n clear() {\n this.subscriptions.length = 0;\n }\n}\n\nexport { SubscriptionManager };\n//# sourceMappingURL=subscription-manager.mjs.map\n","function addUniqueItem(arr, item) {\n if (arr.indexOf(item) === -1)\n arr.push(item);\n}\nfunction removeItem(arr, item) {\n const index = arr.indexOf(item);\n if (index > -1)\n arr.splice(index, 1);\n}\n// Adapted from array-move\nfunction moveItem([...arr], fromIndex, toIndex) {\n const startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex;\n if (startIndex >= 0 && startIndex < arr.length) {\n const endIndex = toIndex < 0 ? arr.length + toIndex : toIndex;\n const [item] = arr.splice(fromIndex, 1);\n arr.splice(endIndex, 0, item);\n }\n return arr;\n}\n\nexport { addUniqueItem, moveItem, removeItem };\n//# sourceMappingURL=array.mjs.map\n","/**\n * Converts seconds to milliseconds\n *\n * @param seconds - Time in seconds.\n * @return milliseconds - Converted time in milliseconds.\n */\n/*#__NO_SIDE_EFFECTS__*/\nconst secondsToMilliseconds = (seconds) => seconds * 1000;\n/*#__NO_SIDE_EFFECTS__*/\nconst millisecondsToSeconds = (milliseconds) => milliseconds / 1000;\n\nexport { millisecondsToSeconds, secondsToMilliseconds };\n//# sourceMappingURL=time-conversion.mjs.map\n","/**\n * Implement a practical max duration for keyframe generation\n * to prevent infinite loops\n */\nexport const maxGeneratorDuration = 20000;\nexport function calcGeneratorDuration(generator, timeStep = 50, maxDuration = maxGeneratorDuration, keyframes) {\n let duration = 0;\n let state = generator.next(duration);\n keyframes?.push(state.value);\n while (!state.done && duration < maxDuration) {\n duration += timeStep;\n state = generator.next(duration);\n keyframes?.push(state.value);\n }\n return duration >= maxDuration ? Infinity : duration;\n}\n//# sourceMappingURL=calc-duration.js.map","import { clamp, millisecondsToSeconds, secondsToMilliseconds, warning, } from \"motion-utils\";\nimport { generateLinearEasing } from \"../waapi/utils/linear\";\nimport { calcGeneratorDuration, maxGeneratorDuration, } from \"./utils/calc-duration\";\nimport { createGeneratorEasing } from \"./utils/create-generator-easing\";\n// Default spring physics\nconst defaultStiffness = 100;\nconst defaultDamping = 10;\nconst defaultMass = 1.0;\n// Default duration/bounce-based options\nconst defaultDuration = 800; // in ms\nconst defaultBounce = 0.3;\nconst defaultVisualDuration = 0.3; // in seconds\n// Rest thresholds\nconst restSpeedGranular = 0.01;\nconst restSpeedDefault = 2;\nconst restDeltaGranular = 0.005;\nconst restDeltaDefault = 0.5;\n// Limits\nconst minDuration = 0.01; // in seconds\nconst maxDuration = 10.0; // in seconds\nconst minDamping = 0.05;\n/**\n * Maps bounce to a damping ratio as SwiftUI does: 0 is critically damped, and\n * it approaches undamped towards 1 and infinitely overdamped towards -1. Both\n * ends are limited so the spring still moves and settles.\n */\nconst bounceToDampingRatio = (bounce) => bounce < 0\n ? 1 / Math.max(1 + bounce, minDamping)\n : Math.max(1 - bounce, minDamping);\n/**\n * Scales an overdamped spring's undamped frequency so that, at its defining\n * time, it has as far left to go as the critically damped spring that's\n * criticalFreqTime radians in by then. A negative bounce then changes the\n * shape of the curve, not when it arrives. 1 at a damping ratio of 1, so\n * there's no jump at a bounce of 0.\n *\n * Solved by Newton on the remaining distance (times fast - slow), which is\n * convex from criticalFreqTime onwards. criticalFreqTime is always below the\n * answer, so it converges from below without overshooting.\n */\nfunction overdampedFreqScale(dampingRatio, criticalFreqTime) {\n if (!(dampingRatio > 1))\n return 1;\n const root = Math.sqrt(dampingRatio * dampingRatio - 1);\n const slow = dampingRatio - root;\n const fast = dampingRatio + root;\n const target = 2 * root * Math.exp(-criticalFreqTime) * (1 + criticalFreqTime);\n return (approximateRoot((freqTime) => fast * Math.exp(-slow * freqTime) -\n slow * Math.exp(-fast * freqTime) -\n target, (freqTime) => Math.exp(-fast * freqTime) - Math.exp(-slow * freqTime), criticalFreqTime) / criticalFreqTime);\n}\nfunction calcAngularFreq(undampedFreq, dampingRatio) {\n return undampedFreq * Math.sqrt(1 - dampingRatio * dampingRatio);\n}\nconst rootIterations = 12;\nfunction approximateRoot(envelope, derivative, initialGuess) {\n let result = initialGuess;\n for (let i = 1; i < rootIterations; i++) {\n result = result - envelope(result) / derivative(result);\n }\n return result;\n}\n/**\n * This is ported from the Framer implementation of duration-based spring resolution.\n */\nconst safeMin = 0.001;\n/**\n * Assumes zero initial velocity and the default mass: duration springs start\n * from rest so they end exactly at their duration. Only resolves without\n * valid physics. Returns NaN physics when the root search doesn't converge.\n */\nfunction findSpring({ duration = defaultDuration, bounce = defaultBounce, }) {\n let envelope;\n let derivative;\n process.env.NODE_ENV !== \"production\" &&\n warning(duration <= secondsToMilliseconds(maxDuration), \"Spring duration must be 10 seconds or less\", \"spring-duration-limit\");\n const dampingRatio = bounceToDampingRatio(bounce);\n duration = clamp(minDuration, maxDuration, millisecondsToSeconds(duration));\n if (dampingRatio < 1) {\n /**\n * Underdamped spring\n */\n envelope = (undampedFreq) => {\n const exponentialDecay = undampedFreq * dampingRatio;\n const delta = exponentialDecay * duration;\n const b = calcAngularFreq(undampedFreq, dampingRatio);\n const c = Math.exp(-delta);\n return safeMin - (exponentialDecay / b) * c;\n };\n derivative = (undampedFreq) => {\n const exponentialDecay = undampedFreq * dampingRatio;\n const delta = exponentialDecay * duration;\n const e = dampingRatio *\n dampingRatio *\n undampedFreq *\n undampedFreq *\n duration;\n const f = Math.exp(-delta);\n const g = calcAngularFreq(undampedFreq * undampedFreq, dampingRatio);\n const factor = -envelope(undampedFreq) + safeMin > 0 ? -1 : 1;\n return (factor * -e * f) / g;\n };\n }\n else {\n /**\n * Critically-damped spring. Overdamped springs reuse this root,\n * scaled below.\n */\n envelope = (undampedFreq) => {\n const a = Math.exp(-undampedFreq * duration);\n const b = undampedFreq * duration + 1;\n return -safeMin + a * b;\n };\n derivative = (undampedFreq) => {\n const a = Math.exp(-undampedFreq * duration);\n const b = -undampedFreq * (duration * duration);\n return a * b;\n };\n }\n const initialGuess = 5 / duration;\n const criticalFreq = approximateRoot(envelope, derivative, initialGuess);\n const undampedFreq = criticalFreq *\n overdampedFreqScale(dampingRatio, criticalFreq * duration);\n const stiffness = undampedFreq * undampedFreq;\n return {\n stiffness,\n damping: dampingRatio * 2 * Math.sqrt(stiffness),\n duration: secondsToMilliseconds(duration),\n };\n}\n/**\n * Spring physics must be finite. stiffness and mass are also divisors so must\n * be positive, whereas a damping of 0 is a valid, perpetually oscillating\n * spring. Relational rather than Number.isFinite so numeric strings still\n * coerce.\n */\nconst isValidPhysics = (value, canBeZero) => (canBeZero ? value >= 0 : value > 0) && value < Infinity;\n/**\n * Returns value if it's usable spring physics, otherwise undefined so callers\n * fall back to the default. An explicit `undefined`, e.g. from a forwarded\n * optional prop, must fall back too. Invalid physics would otherwise resolve\n * to NaN spring values that never report done.\n */\nfunction resolvePhysics(value, canBeZero) {\n if (isValidPhysics(value, canBeZero))\n return value;\n if (process.env.NODE_ENV !== \"production\") {\n warning(value === undefined || value === \"auto\", \"Spring stiffness and mass must be positive, damping 0 or greater\", \"spring-invalid-physics\");\n }\n return undefined;\n}\nexport function getSpringOptions(options) {\n /**\n * Resolve physics before choosing between physics- and duration-based\n * resolution, so an invalid stiffness doesn't also silently discard a\n * valid duration/bounce.\n */\n const validStiffness = resolvePhysics(options.stiffness);\n const validDamping = resolvePhysics(options.damping, true);\n const validMass = resolvePhysics(options.mass);\n const springOptions = {\n ...options,\n stiffness: validStiffness ?? defaultStiffness,\n damping: validDamping ?? defaultDamping,\n mass: validMass ?? defaultMass,\n isResolvedFromDuration: false,\n // stiffness/damping/mass overrides duration/bounce\n isTimeDefined: (validStiffness ?? validDamping ?? validMass) === undefined &&\n (options.duration !== undefined || options.bounce !== undefined),\n };\n if (springOptions.isTimeDefined) {\n if (options.visualDuration) {\n const dampingRatio = bounceToDampingRatio(options.bounce || 0);\n const root = ((2 * Math.PI) / (options.visualDuration * 1.2)) *\n overdampedFreqScale(dampingRatio, (2 * Math.PI) / 1.2);\n springOptions.stiffness = root * root;\n springOptions.damping =\n 2 * dampingRatio * Math.sqrt(springOptions.stiffness);\n }\n else {\n Object.assign(springOptions, findSpring(springOptions));\n springOptions.isResolvedFromDuration = true;\n }\n /**\n * Time options can degenerate: a NaN bounce gives a NaN damping, an\n * infinite visualDuration a 0 stiffness, and findSpring NaN for both\n * when it doesn't converge. Replace the two together, so the\n * relationship duration resolution establishes between them is never\n * left half-overwritten.\n */\n if (!isValidPhysics(springOptions.stiffness) ||\n !isValidPhysics(springOptions.damping, true)) {\n springOptions.stiffness = defaultStiffness;\n springOptions.damping = defaultDamping;\n }\n }\n return springOptions;\n}\nfunction springGenerator(optionsOrVisualDuration = defaultVisualDuration, bounce = defaultBounce) {\n const options = typeof optionsOrVisualDuration !== \"object\"\n ? {\n visualDuration: optionsOrVisualDuration,\n keyframes: [0, 1],\n bounce,\n }\n : optionsOrVisualDuration;\n const origin = options.keyframes[0];\n const target = options.keyframes[options.keyframes.length - 1];\n /**\n * This is the Iterator-spec return value. We ensure it's mutable rather than using a generator\n * to reduce GC during animation.\n */\n const state = { done: false, value: origin };\n const { stiffness, damping, mass, duration, isResolvedFromDuration, isTimeDefined, } = getSpringOptions({ ...options });\n /**\n * A duration spring must end exactly at its duration, and it's settled\n * from rest by then. Inherited velocity could leave it still moving, so\n * it starts from rest. Every other spring, visualDuration included, ends\n * when it comes to rest, so inherits velocity as its initial condition.\n */\n const inheritVelocity = (velocity) => isResolvedFromDuration ? 0 : -millisecondsToSeconds(velocity);\n const dampingRatio = damping / (2 * Math.sqrt(stiffness * mass));\n const undampedAngularFreq = millisecondsToSeconds(Math.sqrt(stiffness / mass));\n const decay = dampingRatio * undampedAngularFreq;\n /**\n * Everything that changes when the spring is retargeted: written by\n * retarget() and update(), read by the resolvers. Grouped on one object,\n * like the coefficients (c) below. Writing doubles to object fields\n * measured marginally faster than to captured let variables in optimised\n * code; neither allocates, so this is a grouping choice, not a GC one.\n */\n const s = {\n target,\n delta: target - origin,\n velocity: inheritVelocity(options.velocity) || 0,\n restSpeed: 0,\n restDelta: 0,\n };\n /**\n * If we're working on a granular scale, use smaller defaults for determining\n * when the spring is finished.\n *\n * These defaults have been selected empirically based on what strikes a good\n * ratio between feeling good and finishing as soon as changes are imperceptible.\n */\n const setRestThresholds = () => {\n const isGranularScale = Math.abs(s.delta) < 5;\n s.restSpeed =\n options.restSpeed ||\n (isGranularScale ? restSpeedGranular : restSpeedDefault);\n s.restDelta =\n options.restDelta ||\n (isGranularScale ? restDeltaGranular : restDeltaDefault);\n };\n setRestThresholds();\n let resolveSpring;\n let resolveVelocity;\n /**\n * Derives the coefficients that depend on origin, target and initial\n * velocity. Called once now and again whenever the spring is retargeted.\n */\n let update;\n if (dampingRatio < 1) {\n const angularFreq = calcAngularFreq(undampedAngularFreq, dampingRatio);\n /**\n * A is the position coefficient, sinC/cosC the coefficients of the\n * analytical derivative (px/ms). The exp/sin/cos terms depend only\n * on t, so they're memoized by t independently of the target: a\n * spring retargeted every frame samples the same t each frame and\n * skips the transcendentals entirely.\n */\n const c = { A: 0, sinC: 0, cosC: 0, t: -1, env: 0, sin: 0, cos: 0 };\n update = () => {\n c.A = (s.velocity + decay * s.delta) / angularFreq;\n c.sinC = decay * c.A + s.delta * angularFreq;\n c.cosC = decay * s.delta - c.A * angularFreq;\n };\n const sample = (t) => {\n if (t !== c.t) {\n c.t = t;\n c.env = Math.exp(-decay * t);\n c.sin = Math.sin(angularFreq * t);\n c.cos = Math.cos(angularFreq * t);\n }\n };\n // Underdamped spring\n resolveSpring = (t) => {\n sample(t);\n return s.target - c.env * (c.A * c.sin + s.delta * c.cos);\n };\n resolveVelocity = (t) => {\n sample(t);\n return c.env * (c.sinC * c.sin + c.cosC * c.cos);\n };\n }\n else if (dampingRatio === 1) {\n // Critically damped spring\n resolveSpring = (t) => s.target -\n Math.exp(-undampedAngularFreq * t) *\n (s.delta + (s.velocity + undampedAngularFreq * s.delta) * t);\n // Analytical derivative of critically damped spring (px/ms)\n const c = { C: 0 };\n update = () => {\n c.C = s.velocity + undampedAngularFreq * s.delta;\n };\n resolveVelocity = (t) => Math.exp(-undampedAngularFreq * t) *\n (undampedAngularFreq * c.C * t - s.velocity);\n }\n else {\n /**\n * Overdamped spring: the sum of a slow and a fast decaying\n * exponential, so no term can overflow however heavily it's damped.\n */\n const dampedAngularFreq = undampedAngularFreq * Math.sqrt(dampingRatio * dampingRatio - 1);\n const slow = decay - dampedAngularFreq;\n const fast = decay + dampedAngularFreq;\n /**\n * Physics-defined springs keep a non-physical limit: once\n * dampedAngularFreq * t passes 300, both terms decay at the damping\n * rate. Heavily overdamped drag springs (dragElastic: 0,\n * dragTransition) rely on this to settle almost at once rather than\n * creep at stiffness / damping. It only applies when reached within\n * 300ms (a dampedAngularFreq of 1 rad/ms), so it reads as a stiff\n * spring snapping into place: any later and it cuts off a slow spring\n * that's visibly still moving (#1207). Negative bounce needs the\n * exact curve, so time-defined springs are exempt.\n */\n const limit = dampedAngularFreq < 1 || isTimeDefined\n ? Infinity\n : 300 / dampedAngularFreq;\n const decayAt = (rate, t) => Math.exp(t > limit ? (decay - rate) * limit - decay * t : -rate * t);\n const c = { S: 0, F: 0 };\n update = () => {\n const P = (s.velocity + decay * s.delta) / dampedAngularFreq;\n c.S = (s.delta + P) / 2;\n c.F = (s.delta - P) / 2;\n };\n resolveSpring = (t) => s.target - c.S * decayAt(slow, t) - c.F * decayAt(fast, t);\n // Analytical derivative of overdamped spring (px/ms)\n resolveVelocity = (t) => slow * c.S * decayAt(slow, t) + fast * c.F * decayAt(fast, t);\n }\n update();\n const calculatedDuration = isResolvedFromDuration ? duration || null : null;\n const generator = {\n calculatedDuration,\n /**\n * Aim the spring at a new target from its current position and\n * velocity, reusing the resolved physics and closures.\n */\n retarget: (keyframes, newVelocity) => {\n s.target = keyframes[keyframes.length - 1];\n s.delta = s.target - keyframes[0];\n s.velocity = inheritVelocity(newVelocity);\n // Default thresholds depend on the scale of the new delta\n if (!(options.restSpeed && options.restDelta))\n setRestThresholds();\n // Invalidate any duration lazily cached by JSAnimation\n generator.calculatedDuration = calculatedDuration;\n state.done = false;\n update();\n },\n velocity: (t) => secondsToMilliseconds(resolveVelocity(t)),\n next: (t) => {\n const current = resolveSpring(t);\n if (!isResolvedFromDuration) {\n const currentVelocity = secondsToMilliseconds(resolveVelocity(t));\n state.done =\n Math.abs(currentVelocity) <= s.restSpeed &&\n Math.abs(s.target - current) <= s.restDelta;\n }\n else {\n state.done = t >= duration;\n }\n state.value = state.done ? s.target : current;\n return state;\n },\n toString: () => {\n const easingDuration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);\n const easing = generateLinearEasing((progress) => generator.next(easingDuration * progress).value, easingDuration, 30);\n return easingDuration + \"ms \" + easing;\n },\n };\n return generator;\n}\nconst spring = /* @__PURE__ */ Object.assign(springGenerator, {\n applyToOptions: (options) => {\n const generatorOptions = createGeneratorEasing(options, 100, springGenerator);\n options.ease = generatorOptions.ease;\n options.duration = secondsToMilliseconds(generatorOptions.duration);\n options.type = \"keyframes\";\n return options;\n },\n});\nexport { spring };\n//# sourceMappingURL=spring.js.map","export const generateLinearEasing = (easing, duration, // as milliseconds\nresolution = 10 // as milliseconds\n) => {\n let points = \"\";\n const numPoints = Math.max(Math.round(duration / resolution), 2);\n for (let i = 0; i < numPoints; i++) {\n points += Math.round(easing(i / (numPoints - 1)) * 10000) / 10000 + \", \";\n }\n return `linear(${points.substring(0, points.length - 2)})`;\n};\n//# sourceMappingURL=linear.js.map","import { millisecondsToSeconds } from \"motion-utils\";\nimport { calcGeneratorDuration, maxGeneratorDuration } from \"./calc-duration\";\n/**\n * Create a progress => progress easing function from a generator.\n */\nexport function createGeneratorEasing(options, scale = 100, createGenerator) {\n /**\n * The easing is generated over 0 - scale, but velocity is in the\n * value's own units, so scale it to match. Otherwise an interrupted\n * spring hands off the wrong speed, or direction. Keyframes with\n * units (colours, filters, mixed units) give NaN, which is falsy,\n * so their velocity passes through unscaled.\n */\n const { keyframes: k, velocity: v } = options;\n const delta = k && k[k.length - 1] - k[0];\n const generator = createGenerator({\n ...options,\n velocity: v && delta ? (v * scale) / delta : v,\n keyframes: [0, scale],\n });\n const duration = Math.min(calcGeneratorDuration(generator), maxGeneratorDuration);\n return {\n type: \"keyframes\",\n ease: (progress) => {\n return generator.next(duration * progress).value / scale;\n },\n duration: millisecondsToSeconds(duration),\n };\n}\n//# sourceMappingURL=create-generator-easing.js.map","export const transformGroups = new WeakMap();\n//# sourceMappingURL=groups.js.map","export const isCSSVar = (name) => name.startsWith(\"--\");\n//# sourceMappingURL=is-css-var.js.map","const radToDeg = (rad) => (rad * 180) / Math.PI;\nconst rotate = (v) => {\n const angle = radToDeg(Math.atan2(v[1], v[0]));\n return rebaseAngle(angle);\n};\nconst matrix2dParsers = {\n x: 4,\n y: 5,\n translateX: 4,\n translateY: 5,\n scaleX: 0,\n scaleY: 3,\n scaleZ: () => 1,\n scale: (v) => (Math.abs(v[0]) + Math.abs(v[3])) / 2,\n rotate,\n rotateZ: rotate,\n skewX: (v) => radToDeg(Math.atan(v[1])),\n skewY: (v) => radToDeg(Math.atan(v[2])),\n skew: (v) => (Math.abs(v[1]) + Math.abs(v[2])) / 2,\n};\nconst rebaseAngle = (angle) => {\n angle = angle % 360;\n if (angle < 0)\n angle += 360;\n return angle;\n};\nconst rotateZ = rotate;\nconst scaleX = (v) => Math.hypot(v[0], v[1]);\nconst scaleY = (v) => Math.hypot(v[4], v[5]);\nconst matrix3dParsers = {\n x: 12,\n y: 13,\n z: 14,\n translateX: 12,\n translateY: 13,\n translateZ: 14,\n scaleX,\n scaleY,\n scaleZ: (v) => Math.hypot(v[8], v[9], v[10]),\n scale: (v) => (scaleX(v) + scaleY(v)) / 2,\n rotateX: (v) => rebaseAngle(radToDeg(Math.atan2(v[6], v[5]))),\n rotateY: (v) => rebaseAngle(radToDeg(Math.atan2(-v[2], v[0]))),\n rotateZ,\n rotate: rotateZ,\n skewX: (v) => radToDeg(Math.atan(v[4])),\n skewY: (v) => radToDeg(Math.atan(v[1])),\n skew: (v) => (Math.abs(v[1]) + Math.abs(v[4])) / 2,\n};\nexport function defaultTransformValue(name) {\n return name.includes(\"scale\") ? 1 : 0;\n}\nexport function parseValueFromTransform(transform, name) {\n if (!transform || transform === \"none\") {\n return defaultTransformValue(name);\n }\n const match = transform.match(/^matrix(3d)?\\(([-\\d.e\\s,]+)\\)$/u);\n if (!match) {\n return defaultTransformValue(name);\n }\n const valueParser = (match[1] ? matrix3dParsers : matrix2dParsers)[name];\n /**\n * parseFloat skips leading whitespace and stops at trailing whitespace.\n */\n const values = match[2].split(\",\").map((v) => parseFloat(v));\n return typeof valueParser === \"function\"\n ? valueParser(values)\n : values[valueParser];\n}\nexport const readTransformValue = (instance, name) => {\n const { transform = \"none\" } = getComputedStyle(instance);\n return parseValueFromTransform(transform, name);\n};\n//# sourceMappingURL=parse-transform.js.map","/**\n * Generate a list of every possible transform key.\n */\nexport const transformPropOrder = [\n \"transformPerspective\",\n \"x\",\n \"y\",\n \"z\",\n \"translateX\",\n \"translateY\",\n \"translateZ\",\n \"scale\",\n \"scaleX\",\n \"scaleY\",\n \"scaleZ\",\n \"rotate\",\n \"rotateX\",\n \"rotateY\",\n \"rotateZ\",\n \"skew\",\n \"skewX\",\n \"skewY\",\n];\n/**\n * A quick lookup for transform props.\n *\n * `pathRotation` is a transform for routing purposes (skipped from raw\n * style application, wired to the transform composite, flags transform\n * dirty) but is intentionally NOT in `transformPropOrder` — it is\n * composed onto `rotate` at the build sites, not serialized in its own\n * slot, and must stay out of the order-array consumers (parse-transform,\n * unit-conversion, keys-position).\n */\nexport const transformProps = /*@__PURE__*/ (() => new Set([...transformPropOrder, \"pathRotation\"]))();\n//# sourceMappingURL=keys-transform.js.map","import { isObject } from \"motion-utils\";\n/**\n * Checks if an element is an HTML element in a way\n * that works across iframes\n */\nexport function isHTMLElement(element) {\n return (isObject(element) &&\n \"offsetHeight\" in element &&\n !(\"ownerSVGElement\" in element));\n}\n//# sourceMappingURL=is-html-element.js.map","import { isObject } from \"motion-utils\";\n/**\n * Checks if an element is an SVG element in a way\n * that works across iframes\n */\nexport function isSVGElement(element) {\n return isObject(element) && \"ownerSVGElement\" in element;\n}\n//# sourceMappingURL=is-svg-element.js.map","export const stepsOrder = [\n \"setup\", // Compute\n \"read\", // Read\n \"resolveKeyframes\", // Write/Read/Write/Read\n \"preUpdate\", // Compute\n \"update\", // Compute\n \"preRender\", // Compute\n \"render\", // Write\n \"postRender\", // Compute\n];\n//# sourceMappingURL=order.js.map","import { MotionGlobalConfig } from \"motion-utils\";\nimport { stepsOrder } from \"./order\";\nimport { createRenderStep } from \"./render-step\";\nconst maxElapsed = 40;\nexport function createRenderBatcher(scheduleNextBatch, allowKeepAlive, state = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n}) {\n let runNextFrame = false;\n let useDefaultElapsed = true;\n const flagRunNextFrame = () => (runNextFrame = true);\n const steps = stepsOrder.reduce((acc, key) => {\n acc[key] = createRenderStep(flagRunNextFrame);\n return acc;\n }, {});\n const { setup, read, resolveKeyframes, preUpdate, update, preRender, render, postRender, } = steps;\n const processBatch = () => {\n const useManualTiming = MotionGlobalConfig.useManualTiming;\n const timestamp = useManualTiming\n ? state.timestamp\n : performance.now();\n runNextFrame = false;\n if (!useManualTiming) {\n state.delta = useDefaultElapsed\n ? 1000 / 60\n : Math.max(Math.min(timestamp - state.timestamp, maxElapsed), 1);\n }\n state.timestamp = timestamp;\n state.isProcessing = true;\n // Unrolled render loop for better per-frame performance\n setup.process(state);\n read.process(state);\n resolveKeyframes.process(state);\n preUpdate.process(state);\n update.process(state);\n preRender.process(state);\n render.process(state);\n postRender.process(state);\n state.isProcessing = false;\n if (runNextFrame && allowKeepAlive) {\n useDefaultElapsed = false;\n scheduleNextBatch(processBatch);\n }\n };\n const wake = () => {\n runNextFrame = true;\n useDefaultElapsed = true;\n if (!state.isProcessing) {\n scheduleNextBatch(processBatch);\n }\n };\n const schedule = stepsOrder.reduce((acc, key) => {\n const step = steps[key];\n acc[key] = (process, keepAlive = false, immediate = false) => {\n if (!runNextFrame)\n wake();\n return step.schedule(process, keepAlive, immediate);\n };\n return acc;\n }, {});\n const cancel = (process) => {\n for (let i = 0; i < stepsOrder.length; i++) {\n steps[stepsOrder[i]].cancel(process);\n }\n };\n return { schedule, cancel, state, steps };\n}\n//# sourceMappingURL=batcher.js.map","export function createRenderStep(runNextFrame) {\n /**\n * We create and reuse two queues, one to queue jobs for the current frame\n * and one for the next. We reuse to avoid triggering GC after x frames.\n */\n let thisFrame = new Set();\n let nextFrame = new Set();\n /**\n * Track whether we're currently processing jobs in this step. This way\n * we can decide whether to schedule new jobs for this frame or next.\n */\n let isProcessing = false;\n let flushNextFrame = false;\n /**\n * The callback currently running. If it schedules itself with `immediate`\n * it's left in place, so as before it doesn't run again this step.\n */\n let running;\n /**\n * A set of processes which were marked keepAlive when scheduled.\n * A keepAlive process is always also held by a frame queue until\n * it's cancelled, so a Set has the same lifetime semantics as a\n * WeakSet here while being considerably faster to query every frame.\n */\n const toKeepAlive = new Set();\n let latestFrameData = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n };\n function triggerCallback(callback) {\n if (toKeepAlive.has(callback)) {\n nextFrame.add(callback);\n runNextFrame();\n }\n ;\n (running = callback)(latestFrameData);\n }\n const step = {\n /**\n * Schedule a process to run on the next frame.\n */\n schedule: (callback, keepAlive = false, immediate = false) => {\n const addToCurrentFrame = immediate && isProcessing;\n const queue = addToCurrentFrame ? thisFrame : nextFrame;\n if (keepAlive)\n toKeepAlive.add(callback);\n /**\n * A callback scheduled with `immediate` during processing may\n * already have run this step (for instance, a value it reads was\n * changed by a later callback). Re-adding moves it to the end of\n * the queue, so it runs again. The running callback is excluded,\n * so one that re-schedules itself can't loop forever.\n */\n addToCurrentFrame && callback !== running && queue.delete(callback);\n queue.add(callback);\n return callback;\n },\n /**\n * Cancel the provided callback from running on the next frame.\n */\n cancel: (callback) => {\n nextFrame.delete(callback);\n toKeepAlive.delete(callback);\n },\n /**\n * Execute all schedule callbacks.\n */\n process: (frameData) => {\n latestFrameData = frameData;\n /**\n * If we're already processing we've probably been triggered by a flushSync\n * inside an existing process. Instead of executing, mark flushNextFrame\n * as true and ensure we flush the following frame at the end of this one.\n */\n if (isProcessing) {\n flushNextFrame = true;\n return;\n }\n isProcessing = true;\n // Swap this frame and the next to avoid GC\n const prevFrame = thisFrame;\n thisFrame = nextFrame;\n nextFrame = prevFrame;\n // Execute this frame\n thisFrame.forEach(triggerCallback);\n // Clear the frame so no callbacks remain. This is to avoid\n // memory leaks should this render step not run for a while.\n thisFrame.clear();\n running = undefined;\n isProcessing = false;\n if (flushNextFrame) {\n flushNextFrame = false;\n step.process(frameData);\n }\n },\n };\n return step;\n}\n//# sourceMappingURL=render-step.js.map","/**\n * The frameloop's state, kept apart from the frameloop itself so that\n * reading it doesn't bundle the scheduler.\n */\nexport const frameData = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n};\n//# sourceMappingURL=frame-data.js.map","import { noop } from \"motion-utils\";\nimport { createRenderBatcher } from \"./batcher\";\nimport { frameData } from \"./frame-data\";\nexport const { schedule: frame, cancel: cancelFrame, steps: frameSteps, } = /* @__PURE__ */ createRenderBatcher(typeof requestAnimationFrame !== \"undefined\" ? requestAnimationFrame : noop, true, frameData);\n//# sourceMappingURL=frame.js.map","/*#__NO_SIDE_EFFECTS__*/\nconst noop = (any) => any;\n\nexport { noop };\n//# sourceMappingURL=noop.mjs.map\n","import { MotionGlobalConfig } from \"motion-utils\";\nimport { frameData } from \"./frame-data\";\nlet now;\nfunction clearTime() {\n now = undefined;\n}\n/**\n * An eventloop-synchronous alternative to performance.now().\n *\n * Ensures that time measurements remain consistent within a synchronous context.\n * Usually calling performance.now() twice within the same synchronous context\n * will return different values which isn't useful for animations when we're usually\n * trying to sync animations to the same frame.\n */\nexport const time = {\n now: () => {\n if (now === undefined) {\n time.set(frameData.isProcessing || MotionGlobalConfig.useManualTiming\n ? frameData.timestamp\n : performance.now());\n }\n return now;\n },\n set: (newTime) => {\n now = newTime;\n queueMicrotask(clearTime);\n },\n};\n//# sourceMappingURL=sync-time.js.map","import { SubscriptionManager, velocityPerSecond, warnOnce, } from \"motion-utils\";\nimport { frame } from \"../frameloop\";\nimport { time } from \"../frameloop/sync-time\";\n/**\n * Maximum time between the value of two frames, beyond which we\n * assume the velocity has since been 0.\n */\nconst MAX_VELOCITY_DELTA = 30;\nconst isFloat = (value) => {\n return !isNaN(parseFloat(value));\n};\nexport const collectMotionValues = {\n current: undefined,\n};\n/**\n * `MotionValue` is used to track the state and velocity of motion values.\n *\n * @public\n */\nexport class MotionValue {\n /**\n * @param init - The initiating value\n * @param config - Optional configuration options\n *\n * - `transformer`: A function to transform incoming values with.\n */\n constructor(init, options = {}) {\n /**\n * Tracks whether this value can output a velocity. Currently this is only true\n * if the value is numerical, but we might be able to widen the scope here and support\n * other value types.\n *\n * @internal\n */\n this.canTrackVelocity = null;\n /**\n * An object containing a SubscriptionManager for each active event.\n */\n this.events = {};\n this.updateAndNotify = (v) => {\n const currentTime = time.now();\n /**\n * If we're updating the value during another frame or eventloop\n * than the previous frame, then the we set the previous frame value\n * to current.\n */\n if (this.updatedAt !== currentTime) {\n this.setPrevFrameValue();\n }\n this.prev = this.current;\n this.setCurrent(v);\n // Update update subscribers\n if (this.current !== this.prev) {\n this.dirty();\n if (this.dependents) {\n for (const dependent of this.dependents) {\n dependent.dirty();\n }\n }\n }\n };\n this.hasAnimated = false;\n this.setCurrent(init);\n this.owner = options.owner;\n }\n setCurrent(current) {\n this.current = current;\n this.updatedAt = time.now();\n if (this.canTrackVelocity === null && current !== undefined) {\n this.canTrackVelocity = isFloat(this.current);\n }\n }\n setPrevFrameValue(prevFrameValue = this.current) {\n this.prevFrameValue = prevFrameValue;\n this.prevUpdatedAt = this.updatedAt;\n }\n /**\n * Adds a function that will be notified when the `MotionValue` is updated.\n *\n * It returns a function that, when called, will cancel the subscription.\n *\n * When calling `onChange` inside a React component, it should be wrapped with the\n * `useEffect` hook. As it returns an unsubscribe function, this should be returned\n * from the `useEffect` function to ensure you don't add duplicate subscribers..\n *\n * ```jsx\n * export const MyComponent = () => {\n * const x = useMotionValue(0)\n * const y = useMotionValue(0)\n * const opacity = useMotionValue(1)\n *\n * useEffect(() => {\n * function updateOpacity() {\n * const maxXY = Math.max(x.get(), y.get())\n * const newOpacity = transform(maxXY, [0, 100], [1, 0])\n * opacity.set(newOpacity)\n * }\n *\n * const unsubscribeX = x.on(\"change\", updateOpacity)\n * const unsubscribeY = y.on(\"change\", updateOpacity)\n *\n * return () => {\n * unsubscribeX()\n * unsubscribeY()\n * }\n * }, [])\n *\n * return <motion.div style={{ x }} />\n * }\n * ```\n *\n * @param subscriber - A function that receives the latest value.\n * @returns A function that, when called, will cancel this subscription.\n *\n * @deprecated\n */\n onChange(subscription) {\n if (process.env.NODE_ENV !== \"production\") {\n warnOnce(false, `value.onChange(callback) is deprecated. Switch to value.on(\"change\", callback).`);\n }\n return this.on(\"change\", subscription);\n }\n on(eventName, callback) {\n var _a;\n if (eventName === \"change\")\n return this.onChangeSubscribe(callback);\n return ((_a = this.events)[eventName] || (_a[eventName] = new SubscriptionManager())).add(callback);\n }\n onChangeSubscribe(callback) {\n const { events } = this;\n if (!events.change && !this.changeSubscriber) {\n this.changeSubscriber = callback;\n }\n else {\n if (!events.change) {\n events.change = new SubscriptionManager();\n events.change.add(this.changeSubscriber);\n this.changeSubscriber = undefined;\n }\n events.change.add(callback);\n }\n return () => {\n if (this.changeSubscriber === callback) {\n this.changeSubscriber = undefined;\n }\n else {\n events.change?.remove(callback);\n }\n this.stopIfUnobserved();\n };\n }\n /**\n * If we have no more change listeners by the start\n * of the next frame, stop active animations.\n */\n stopIfUnobserved() {\n frame.read(() => {\n if (!this.changeSubscriber && !this.events.change?.getSize()) {\n this.stop();\n }\n });\n }\n clearListeners() {\n this.changeSubscriber = undefined;\n for (const eventManagers in this.events) {\n this.events[eventManagers].clear();\n }\n }\n /**\n * Attaches a passive effect to the `MotionValue`.\n */\n attach(passiveEffect, stopPassiveEffect) {\n this.passiveEffect = passiveEffect;\n this.stopPassiveEffect = stopPassiveEffect;\n }\n /**\n * Sets the state of the `MotionValue`.\n *\n * @remarks\n *\n * ```jsx\n * const x = useMotionValue(0)\n * x.set(10)\n * ```\n *\n * @param latest - Latest value to set.\n * @param render - Whether to notify render subscribers. Defaults to `true`\n *\n * @public\n */\n set(v) {\n this.passiveEffect\n ? this.passiveEffect(v, this.updateAndNotify)\n : this.updateAndNotify(v);\n }\n setWithVelocity(prev, current, delta) {\n this.set(current);\n this.prev = undefined;\n this.prevFrameValue = prev;\n this.prevUpdatedAt = this.updatedAt - delta;\n }\n /**\n * Set the state of the `MotionValue`, stopping any active animations,\n * effects, and resets velocity to `0`.\n */\n jump(v, endAnimation = true) {\n if (endAnimation) {\n /**\n * Stop first, as stopping a running animation can set the\n * value it's showing, which would replace v. Marking the value\n * as updated now skips a JS animation's catch-up tick on stop,\n * which could otherwise complete it.\n */\n this.updatedAt = time.now();\n this.stop();\n }\n this.updateAndNotify(v);\n this.prev = v;\n this.prevUpdatedAt = this.prevFrameValue = undefined;\n this.stopPassiveEffect?.();\n }\n dirty() {\n const { current, changeSubscriber } = this;\n /**\n * One or the other exists. Subscribing during the direct\n * subscriber's call moves it into a new manager, which must not\n * then be notified for the same change.\n */\n if (changeSubscriber) {\n changeSubscriber(current);\n }\n else {\n this.events.change?.notify(current);\n }\n }\n addDependent(dependent) {\n ;\n (this.dependents || (this.dependents = new Set())).add(dependent);\n }\n removeDependent(dependent) {\n this.dependents?.delete(dependent);\n }\n /**\n * Returns the latest state of `MotionValue`\n *\n * @returns - The latest state of `MotionValue`\n *\n * @public\n */\n get() {\n collectMotionValues.current?.push(this);\n /**\n * A value animating on the compositor isn't updated every frame,\n * so read it from its animation.\n */\n const sampled = this.animation?.liveValue?.();\n return sampled === undefined ? this.current : sampled;\n }\n /**\n * The value as last set. Unlike get(), this doesn't read an animation\n * running on the compositor, which renders the value itself.\n */\n getCurrent() {\n return this.current;\n }\n /**\n * @public\n */\n getPrevious() {\n return this.prev;\n }\n /**\n * Returns the latest velocity of `MotionValue`\n *\n * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.\n *\n * @public\n */\n getVelocity() {\n const currentTime = time.now();\n if (!this.canTrackVelocity ||\n this.prevFrameValue === undefined ||\n currentTime - this.updatedAt > MAX_VELOCITY_DELTA) {\n return 0;\n }\n const delta = Math.min(this.updatedAt - this.prevUpdatedAt, MAX_VELOCITY_DELTA);\n // Casts because of parseFloat's poor typing\n return velocityPerSecond(parseFloat(this.current) -\n parseFloat(this.prevFrameValue), delta);\n }\n /**\n * Registers a new animation to control this `MotionValue`. Only one\n * animation can drive a `MotionValue` at one time.\n *\n * ```jsx\n * value.start()\n * ```\n *\n * @param animation - A function that starts the provided animation\n */\n start(startAnimation) {\n return new Promise((resolve) => this.run(startAnimation, resolve));\n }\n /**\n * As start(), without making a promise, for animations started\n * internally, which complete through their own controls.\n */\n run(startAnimation, onComplete) {\n this.stop();\n this.hasAnimated = true;\n /**\n * Guard against animations that complete before startAnimation\n * has returned.\n */\n let isComplete = false;\n let animation;\n // eslint-disable-next-line prefer-const -- read by the callback before assignment when completing synchronously\n animation = startAnimation(() => {\n isComplete = true;\n this.events.animationComplete?.notify();\n if (this.animation === animation)\n this.animation = undefined;\n onComplete?.();\n });\n if (!isComplete)\n this.animation = animation;\n this.events.animationStart?.notify();\n }\n /**\n * Stop the currently active animation.\n *\n * @public\n */\n stop() {\n if (this.animation) {\n this.animation.stop();\n this.events.animationCancel?.notify();\n }\n // Assign rather than delete to keep the object's shape stable\n this.animation = undefined;\n }\n /**\n * Returns `true` if this value is currently animating.\n *\n * @public\n */\n isAnimating() {\n return !!this.animation;\n }\n /**\n * Destroy and clean up subscribers to this `MotionValue`.\n *\n * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically\n * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually\n * created a `MotionValue` via the `motionValue` function.\n *\n * @public\n */\n destroy() {\n this.dependents?.clear();\n this.events.destroy?.notify();\n this.clearListeners();\n this.stop();\n this.stopPassiveEffect?.();\n }\n}\nexport function motionValue(init, options) {\n return new MotionValue(init, options);\n}\n//# sourceMappingURL=index.js.map","/*\n Convert velocity into velocity per second\n*/\n/*#__NO_SIDE_EFFECTS__*/\nconst velocityPerSecond = (velocity, frameDuration) => frameDuration ? velocity * (1000 / frameDuration) : 0;\n\nexport { velocityPerSecond };\n//# sourceMappingURL=velocity-per-second.mjs.map\n","import { clamp } from \"motion-utils\";\nexport const number = {\n test: (v) => typeof v === \"number\",\n parse: parseFloat,\n transform: (v) => v,\n};\nexport const alpha = {\n ...number,\n transform: (v) => clamp(0, 1, v),\n};\nexport const scale = {\n ...number,\n default: 1,\n};\n//# sourceMappingURL=index.js.map","import { number } from \"./numbers\";\nexport const int = {\n ...number,\n transform: Math.round,\n};\n//# sourceMappingURL=int.js.map","/*#__NO_SIDE_EFFECTS__*/\nconst createUnitType = (unit) => ({\n test: (v) => typeof v === \"string\" && v.endsWith(unit) && v.split(\" \").length === 1,\n parse: parseFloat,\n transform: (v) => `${v}${unit}`,\n});\nexport const degrees = /*@__PURE__*/ createUnitType(\"deg\");\nexport const percent = /*@__PURE__*/ createUnitType(\"%\");\nexport const px = /*@__PURE__*/ createUnitType(\"px\");\nexport const vh = /*@__PURE__*/ createUnitType(\"vh\");\nexport const vw = /*@__PURE__*/ createUnitType(\"vw\");\nexport const progressPercentage = /*@__PURE__*/ (() => ({\n ...percent,\n parse: (v) => percent.parse(v) / 100,\n transform: (v) => percent.transform(v * 100),\n}))();\n//# sourceMappingURL=units.js.map","import { alpha, scale } from \"../numbers\";\nimport { degrees, progressPercentage, px } from \"../numbers/units\";\nexport const transformValueTypes = {\n rotate: degrees,\n /**\n * Internal channel for `transition.path` orientToPath. Composed onto\n * `rotate` at the transform-build sites so the user's `rotate` is\n * never read or overwritten. Not part of `transformPropOrder`.\n */\n pathRotation: degrees,\n rotateX: degrees,\n rotateY: degrees,\n rotateZ: degrees,\n scale,\n scaleX: scale,\n scaleY: scale,\n scaleZ: scale,\n skew: degrees,\n skewX: degrees,\n skewY: degrees,\n distance: px,\n translateX: px,\n translateY: px,\n translateZ: px,\n x: px,\n y: px,\n z: px,\n perspective: px,\n transformPerspective: px,\n opacity: alpha,\n originX: progressPercentage,\n originY: progressPercentage,\n originZ: px,\n};\n//# sourceMappingURL=transform.js.map","import { int } from \"../int\";\nimport { alpha } from \"../numbers\";\nimport { px } from \"../numbers/units\";\nimport { transformValueTypes } from \"./transform\";\nexport const numberValueTypes = {\n // Border props\n borderWidth: px,\n borderTopWidth: px,\n borderRightWidth: px,\n borderBottomWidth: px,\n borderLeftWidth: px,\n borderRadius: px,\n borderTopLeftRadius: px,\n borderTopRightRadius: px,\n borderBottomRightRadius: px,\n borderBottomLeftRadius: px,\n // Positioning props\n width: px,\n maxWidth: px,\n height: px,\n maxHeight: px,\n top: px,\n right: px,\n bottom: px,\n left: px,\n inset: px,\n insetBlock: px,\n insetBlockStart: px,\n insetBlockEnd: px,\n insetInline: px,\n insetInlineStart: px,\n insetInlineEnd: px,\n // Spacing props\n padding: px,\n paddingTop: px,\n paddingRight: px,\n paddingBottom: px,\n paddingLeft: px,\n paddingBlock: px,\n paddingBlockStart: px,\n paddingBlockEnd: px,\n paddingInline: px,\n paddingInlineStart: px,\n paddingInlineEnd: px,\n margin: px,\n marginTop: px,\n marginRight: px,\n marginBottom: px,\n marginLeft: px,\n marginBlock: px,\n marginBlockStart: px,\n marginBlockEnd: px,\n marginInline: px,\n marginInlineStart: px,\n marginInlineEnd: px,\n // Typography\n fontSize: px,\n // Misc\n backgroundPositionX: px,\n backgroundPositionY: px,\n ...transformValueTypes,\n zIndex: int,\n // SVG\n fillOpacity: alpha,\n strokeOpacity: alpha,\n numOctaves: int,\n};\n//# sourceMappingURL=number.js.map","/**\n * Provided a value and a ValueType, returns the value as that value type.\n */\nexport const getValueAsType = (value, type) => {\n return type && typeof value === \"number\"\n ? type.transform(value)\n : value;\n};\n//# sourceMappingURL=get-as-type.js.map","export const activeScope = {};\n/**\n * Register `cleanup` with the active scope, if there is one, so stopping\n * the scope also runs it.\n */\nexport function addToScope(cleanup) {\n activeScope.current?.add(cleanup);\n return cleanup;\n}\n/**\n * Collect the animation a builder like `animateLayout()` or\n * `animateView()` resolves with. If the scope stops first, the animation\n * is stopped as soon as it starts.\n */\nexport function addBuilderToScope(builder) {\n const scope = activeScope.current;\n if (!scope)\n return;\n let isStopped = false;\n let stop;\n const remove = scope.add(() => {\n isStopped = true;\n stop?.();\n });\n builder.then((animation) => {\n if (!animation)\n return;\n stop = () => animation.stop();\n isStopped ? stop() : animation.finished.then(remove);\n }, remove);\n}\n/**\n * Bind `callback` to the active scope, so anything it starts later (for\n * instance an animation in an `inView()` callback) is collected too.\n */\nexport const bindToScope = (callback) => activeScope.current ? activeScope.current.bind(callback) : callback;\n//# sourceMappingURL=active.js.map","import { frame } from \"../frameloop/frame\";\nexport class MotionValueState {\n /**\n * @param step - The frameloop step renders are scheduled in. Defaults\n * to `frame.render`. Effects that feed a render loop running in\n * `frame.render` (GPU scenes) should write in `frame.preRender`.\n */\n constructor(step = frame.render) {\n this.step = step;\n this.values = new Map();\n /**\n * Renders scheduled for the next flush, usually one or two (values\n * bound to the same computed render, e.g. `x` and `y` to `transform`,\n * share an entry). Tracked with a count rather than truncating the\n * array so no backing store is reallocated every frame. Kept per\n * state so pending writes can be flushed synchronously before the\n * subject is measured.\n */\n this.pending = [];\n this.numPending = 0;\n /**\n * Run the pending renders. Resetting the count first means a render\n * scheduled while flushing lands in the next frame, as with the\n * frameloop itself.\n */\n this.flush = () => {\n const { pending, numPending } = this;\n this.numPending = 0;\n for (let i = 0; i < numPending; i++)\n pending[i]();\n };\n }\n /**\n * @param render - Writes the value to the subject. Renders read the\n * motion value directly rather than a cached copy, so there is one\n * place a value lives.\n * @param computed - A value already in this state (e.g. `transform`)\n * whose render should run whenever `value` changes.\n */\n set(name, value, render, computed) {\n this.values.get(name)?.onRemove();\n if (computed) {\n for (const entry of this.values.values()) {\n if (entry.value === computed)\n render = entry.render;\n }\n }\n const onChange = () => render && this.schedule(render);\n /**\n * Values created ahead of a DOM read start out undefined and\n * have nothing to render until they're set.\n */\n value.get() !== undefined && onChange();\n const cancelOnChange = value.on(\"change\", onChange);\n const onRemove = () => {\n cancelOnChange();\n render && !computed && this.cancel(render);\n /**\n * A later set() of the same name has already removed this\n * entry, so leave the one that replaced it.\n */\n this.values.get(name)?.onRemove === onRemove &&\n this.values.delete(name);\n };\n this.values.set(name, {\n value,\n render: computed ? undefined : render,\n onRemove,\n });\n return onRemove;\n }\n get(name) {\n return this.values.get(name)?.value;\n }\n /**\n * Detach every value from this state and return them, so another\n * renderer can take them over. The state stays cached by its effect,\n * so the bound transforms are reset too rather than leaking into\n * values bound later.\n */\n release() {\n const values = new Map();\n this.values.forEach((entry, name) => {\n values.set(name, entry.value);\n entry.onRemove();\n });\n this.transformKeys = this.transformValues = undefined;\n return values;\n }\n schedule(render) {\n const { pending, numPending } = this;\n for (let i = 0; i < numPending; i++) {\n if (pending[i] === render)\n return;\n }\n numPending || this.step(this.flush);\n pending[this.numPending++] = render;\n }\n cancel(render) {\n const { pending } = this;\n for (let i = 0; i < this.numPending; i++) {\n if (pending[i] === render) {\n pending[i] = pending[--this.numPending];\n return;\n }\n }\n }\n}\n//# sourceMappingURL=MotionValueState.js.map","import { MotionValueState } from \"../MotionValueState\";\nexport function createEffect(addValue, { step, ...options } = {}) {\n const stateCache = new WeakMap();\n const effect = (subject, values) => {\n const state = stateCache.get(subject) ?? new MotionValueState(step);\n stateCache.set(subject, state);\n const subscriptions = [];\n for (const key in values) {\n const value = values[key];\n const remove = addValue(subject, state, key, value);\n subscriptions.push(remove);\n }\n return () => {\n for (const cancel of subscriptions)\n cancel();\n };\n };\n return Object.assign(effect, options, {\n get: (subject, key) => stateCache.get(subject)?.get(key),\n flush: (subject) => stateCache.get(subject)?.flush(),\n state: (subject) => stateCache.get(subject),\n });\n}\n//# sourceMappingURL=create-effect.js.map","import { getValueAsType } from \"../../../value/types/utils/get-as-type\";\nimport { numberValueTypes } from \"../../../value/types/maps/number\";\nimport { transformValueTypes } from \"../../../value/types/maps/transform\";\nimport { transformPropOrder } from \"../../utils/keys-transform\";\nexport const translateAlias = {\n x: \"translateX\",\n y: \"translateY\",\n z: \"translateZ\",\n transformPerspective: \"perspective\",\n};\nconst numTransforms = transformPropOrder.length;\n/**\n * Cache of `translateX(`-style openers so each transform function is a few\n * string concatenations rather than a template.\n */\nconst openers = {};\n/**\n * A transform function, e.g. `translateX(10px)` for `x: 10`.\n */\nexport const transformFunction = (key, value, valueAsType = getValueAsType(value, transformValueTypes[key])) => (openers[key] || (openers[key] = (translateAlias[key] || key) + \"(\")) + valueAsType + \")\";\n/**\n * Whether a transform value is at its default, so can be left out.\n */\nexport const isDefaultTransform = (key, value) => (typeof value === \"number\" ? value : parseFloat(value)) ===\n (key.startsWith(\"scale\") ? 1 : 0);\n/**\n * Build a CSS transform style from individual x/y/scale etc properties.\n *\n * This outputs with a default order of transforms/scales/rotations, this can be customised by\n * providing a transformTemplate function.\n */\nexport function buildTransform(latestValues, transform, transformTemplate) {\n // The transform string we're going to build into.\n let transformString = \"\";\n /**\n * Loop over all possible transforms in order, adding the ones that\n * are present to the transform string.\n */\n for (let i = 0; i < numTransforms; i++) {\n const key = transformPropOrder[i];\n const value = latestValues[key];\n if (value === undefined)\n continue;\n const valueAsType = transformTemplate &&\n (transform[key] = getValueAsType(value, numberValueTypes[key]));\n if (!isDefaultTransform(key, value)) {\n transformString +=\n transformFunction(key, value, valueAsType || undefined) + \" \";\n }\n }\n // `pathRotation` composes onto `rotate` as a separate additive term so\n // the user's `rotate` is never clobbered. Deliberately not a slot in\n // `transformPropOrder`.\n const pathRotation = latestValues.pathRotation;\n if (pathRotation) {\n transformString += transformFunction(\"rotate\", pathRotation);\n }\n transformString = transformString.trim();\n // If we have a custom `transform` template, pass our transform values and\n // generated transformString to that before returning\n return transformTemplate\n ? transformTemplate(transform, transformString)\n : transformString || \"none\";\n}\n//# sourceMappingURL=build-transform.js.map","import { transformGroups } from \"../../animation/waapi/transforms/groups\";\nimport { isCSSVar } from \"../../render/dom/is-css-var\";\nimport { readTransformValue } from \"../../render/dom/parse-transform\";\nimport { transformPropOrder, transformProps, } from \"../../render/utils/keys-transform\";\nimport { isHTMLElement } from \"../../utils/is-html-element\";\nimport { isSVGElement } from \"../../utils/is-svg-element\";\nimport { MotionValue } from \"../../value\";\nimport { numberValueTypes } from \"../../value/types/maps/number\";\nimport { getValueAsType } from \"../../value/types/utils/get-as-type\";\nimport { createSelectorEffect } from \"../utils/create-dom-effect\";\nimport { createEffect } from \"../utils/create-effect\";\nimport { buildTransform } from \"./transform\";\nexport const originProps = new Set([\"originX\", \"originY\", \"originZ\"]);\n/**\n * A bound value in its default unit, e.g. `originX: 50` -> `\"50%\"`.\n */\nconst styleValue = (state, key) => getValueAsType(state.get(key)?.get(), numberValueTypes[key]);\nexport const addStyleValue = (element, state, key, value) => {\n let render = undefined;\n let computed = undefined;\n if (transformProps.has(key)) {\n if (key !== \"pathRotation\") {\n const keys = (state.transformKeys ?? (state.transformKeys = []));\n (state.transformValues ?? (state.transformValues = {}))[key] = value;\n if (!keys.includes(key)) {\n keys.push(key);\n keys.sort((a, b) => transformPropOrder.indexOf(a) -\n transformPropOrder.indexOf(b));\n }\n }\n if (!state.get(\"transform\")) {\n // If this is an HTML element, we need to set the transform-box to fill-box\n // to normalise the transform relative to the element's bounding box\n if (!isHTMLElement(element) && !state.get(\"transformBox\")) {\n addStyleValue(element, state, \"transformBox\", new MotionValue(\"fill-box\"));\n }\n state.set(\"transform\", new MotionValue(\"none\"), () => {\n transformGroups.get(element)?.check();\n element.style.transform = buildTransform(state);\n });\n }\n computed = state.get(\"transform\");\n }\n else if (originProps.has(key)) {\n if (!state.get(\"transformOrigin\")) {\n state.set(\"transformOrigin\", new MotionValue(\"\"), () => {\n const originX = styleValue(state, \"originX\") ?? \"50%\";\n const originY = styleValue(state, \"originY\") ?? \"50%\";\n const originZ = styleValue(state, \"originZ\") ?? 0;\n element.style.transformOrigin = `${originX} ${originY} ${originZ}`;\n });\n }\n computed = state.get(\"transformOrigin\");\n }\n else if (isCSSVar(key)) {\n render = () => {\n element.style.setProperty(key, value.getCurrent());\n };\n }\n else {\n render = () => {\n element.style[key] = getValueAsType(value.getCurrent(), numberValueTypes[key]);\n };\n }\n return state.set(key, value, render, computed);\n};\nconst isStyleSubject = (subject) => isHTMLElement(subject) || isSVGElement(subject);\n/**\n * Reads the current value of a style from the element, as the initial\n * keyframe when `animate()` targets an element via this effect. Transforms\n * are parsed out of the computed matrix; everything else is the computed\n * style. Units aren't converted to match the target keyframes. A style\n * the browser can't report is 0, as a VisualElement reports it.\n */\nexport const readStyleValue = (element, key) => {\n if (transformProps.has(key)) {\n return readTransformValue(element, key);\n }\n const computedStyle = getComputedStyle(element);\n const value = isCSSVar(key)\n ? computedStyle.getPropertyValue(key)\n : computedStyle[key];\n return (typeof value === \"string\" && value.trim()) || 0;\n};\n/**\n * The per-element effect `animate()` binds through, so HTML values share\n * state with a direct `styleEffect()` call. The exported `styleEffect`\n * is this wrapped to also accept selectors.\n */\nexport const styleSubjectEffect = /*@__PURE__*/ createEffect(addStyleValue, {\n test: isStyleSubject,\n read: readStyleValue,\n});\nexport const styleEffect = \n/*@__PURE__*/ createSelectorEffect(styleSubjectEffect);\n//# sourceMappingURL=index.js.map","import { isDefaultTransform, transformFunction, } from \"../../render/html/utils/build-transform\";\nexport function buildTransform(state) {\n let transform = \"\";\n const { transformKeys: keys = [], transformValues: values = {} } = state;\n /**\n * Loop over the bound transforms in order, adding the ones that\n * aren't at their default value to the transform string.\n */\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = values[key].getCurrent();\n if (value === undefined)\n continue;\n if (!isDefaultTransform(key, value)) {\n transform += (transform && \" \") + transformFunction(key, value);\n }\n }\n // See build-transform.ts: additive `rotate()` so user `rotate` isn't\n // clobbered. Not a `transformPropOrder` slot.\n const pathRotation = state.get(\"pathRotation\")?.get();\n if (pathRotation) {\n transform +=\n (transform && \" \") + transformFunction(\"rotate\", pathRotation);\n }\n return transform || \"none\";\n}\n//# sourceMappingURL=transform.js.map","export function camelToDash(str) {\n return str.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);\n}\n//# sourceMappingURL=camel-to-dash.js.map","import { buildHTMLStyles } from \"../../html/utils/build-styles\";\nimport { buildSVGPath } from \"./path\";\n/**\n * Values rendered via style rather than as attributes. This must include\n * every value WAAPI can accelerate, as WAAPI writes its final value to\n * style, which would otherwise override later attribute writes.\n */\nexport const cssStyleProperties = [\n \"transform\",\n \"opacity\",\n \"clipPath\",\n \"filter\",\n \"offsetDistance\",\n \"offsetPath\",\n \"offsetRotate\",\n \"offsetAnchor\",\n];\n/**\n * Build SVG visual attributes, like cx and style.transform\n */\nexport function buildSVGAttrs(state, { attrX, attrY, attrScale, pathLength, pathSpacing = 1, pathOffset = 0, \n// This is object creation, which we try to avoid per-frame.\n...latest }, isSVGTag, transformTemplate, styleProp) {\n buildHTMLStyles(state, latest, transformTemplate);\n /**\n * For svg tags we just want to make sure viewBox is animatable and treat all the styles\n * as normal HTML tags.\n */\n if (isSVGTag) {\n if (state.style.viewBox) {\n state.attrs.viewBox = state.style.viewBox;\n }\n return;\n }\n state.attrs = state.style;\n state.style = {};\n const { attrs, style } = state;\n for (const key of cssStyleProperties) {\n if (attrs[key] !== undefined) {\n style[key] = attrs[key];\n delete attrs[key];\n }\n }\n if (style.transform || attrs.transformOrigin) {\n style.transformOrigin = attrs.transformOrigin ?? \"50% 50%\";\n delete attrs.transformOrigin;\n }\n if (style.transform) {\n /**\n * SVG's element transform-origin uses its own median as a reference.\n * Therefore, transformBox becomes a fill-box\n */\n style.transformBox = styleProp?.transformBox ?? \"fill-box\";\n delete attrs.transformBox;\n }\n // Render attrX/attrY/attrScale as attributes\n if (attrX !== undefined)\n attrs.x = attrX;\n if (attrY !== undefined)\n attrs.y = attrY;\n if (attrScale !== undefined)\n attrs.scale = attrScale;\n // Build SVG path if one has been defined\n if (pathLength !== undefined) {\n buildSVGPath(attrs, pathLength, pathSpacing, pathOffset, false);\n }\n}\n//# sourceMappingURL=build-attrs.js.map","import { camelToDash } from \"../../render/dom/utils/camel-to-dash\";\nimport { numberValueTypes } from \"../../value/types/maps/number\";\nimport { getValueAsType } from \"../../value/types/utils/get-as-type\";\nimport { createSelectorEffect } from \"../utils/create-dom-effect\";\nimport { createEffect } from \"../utils/create-effect\";\nfunction canSetAsProperty(element, name) {\n if (!(name in element))\n return false;\n const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(element), name) ||\n Object.getOwnPropertyDescriptor(element, name);\n // Check if it has a setter\n return descriptor && typeof descriptor.set === \"function\";\n}\n/**\n * `name` is the attribute written when it differs from the key the value\n * is stored under, e.g. `attrX` -> `x`. Numbers take the attribute's\n * default unit (`x: 100` -> `\"100px\"`), as they do when key and name match.\n */\nexport const addAttrValue = (element, state, key, value, name = key) => {\n const isProp = canSetAsProperty(element, name);\n if (!isProp && (name.startsWith(\"data\") || name.startsWith(\"aria\"))) {\n name = camelToDash(name);\n }\n const type = numberValueTypes[key] || numberValueTypes[name];\n /**\n * Set attribute directly via property if available\n */\n const render = isProp\n ? () => {\n ;\n element[name] = getValueAsType(value.get(), numberValueTypes[key]);\n }\n : () => {\n const v = getValueAsType(value.get(), type);\n if (v === null || v === undefined) {\n element.removeAttribute(name);\n }\n else {\n element.setAttribute(name, String(v));\n }\n };\n return state.set(key, value, render);\n};\nexport const attrEffect = /*@__PURE__*/ createSelectorEffect(\n/*@__PURE__*/ createEffect(addAttrValue));\n//# sourceMappingURL=index.js.map","import { frame } from \"../../frameloop\";\nimport { isCSSVar } from \"../../render/dom/is-css-var\";\nimport { camelToDash } from \"../../render/dom/utils/camel-to-dash\";\nimport { cssStyleProperties } from \"../../render/svg/utils/build-attrs\";\nimport { transformProps } from \"../../render/utils/keys-transform\";\nimport { isSVGElement } from \"../../utils/is-svg-element\";\nimport { MotionValue } from \"../../value\";\nimport { numberValueTypes } from \"../../value/types/maps/number\";\nimport { addAttrValue } from \"../attr\";\nimport { addStyleValue, originProps, readStyleValue } from \"../style\";\nimport { createSelectorEffect } from \"../utils/create-dom-effect\";\nimport { createEffect } from \"../utils/create-effect\";\nfunction addSVGPathValue(element, state, key, value) {\n frame.render(() => element.setAttribute(\"pathLength\", \"1\"));\n if (key === \"pathOffset\") {\n return state.set(key, value, () => {\n // Use unitless value to avoid Safari zoom bug\n const offset = value.get();\n element.setAttribute(\"stroke-dashoffset\", `${-offset}`);\n });\n }\n else {\n if (!state.get(\"stroke-dasharray\")) {\n state.set(\"stroke-dasharray\", new MotionValue(\"1 1\"), () => {\n const pathLength = state.get(\"pathLength\")?.get() ?? 1;\n const pathSpacing = state.get(\"pathSpacing\")?.get();\n // Use unitless values to avoid Safari zoom bug\n element.setAttribute(\"stroke-dasharray\", `${pathLength} ${pathSpacing ?? 1 - Number(pathLength)}`);\n });\n }\n return state.set(key, value, undefined, state.get(\"stroke-dasharray\"));\n }\n}\nexport const addSVGValue = (element, state, key, value) => {\n if (key.startsWith(\"path\") && !transformProps.has(key)) {\n return addSVGPathValue(element, state, key, value);\n }\n else if (key.startsWith(\"attr\")) {\n return addAttrValue(element, state, key, value, convertAttrKey(key));\n }\n else if (key === \"d\") {\n /**\n * `d` is a CSS property in Chrome and Firefox, but only as\n * `path(...)`, so path data goes to the attribute, taken out of\n * `path(...)` if it's written that way. Path data itself has no\n * quotes or brackets.\n */\n return state.set(key, value, () => {\n const d = value.get()?.replace(/path\\(|[\"')]/g, \"\");\n d === undefined\n ? element.removeAttribute(key)\n : element.setAttribute(key, d);\n });\n }\n /**\n * Transforms and origins aren't CSS properties (bar `x`/`y` in some\n * browsers), so check them by name rather than `key in element.style`.\n */\n const handler = transformProps.has(key) ||\n originProps.has(key) ||\n isCSSVar(key) ||\n key in element.style\n ? addStyleValue\n : addAttrValue;\n return handler(element, state, key, value);\n};\n/**\n * Reads the current value of `key` from an SVG element as the origin of\n * an animation, as the SVG VisualElement does: transforms start from\n * their defaults, CSS variables and the few CSS-only properties come from\n * computed style, falling back to the attribute when that's empty (e.g.\n * the element isn't rendered), and everything else is read from the\n * attribute, dash-cased (`strokeWidth` -> `stroke-width`) or, failing\n * that, as written (`baseFrequency`).\n */\nexport const readSVGValue = (element, key) => {\n if (transformProps.has(key)) {\n return numberValueTypes[key]?.default || 0;\n }\n if (isCSSVar(key) || cssStyleProperties.includes(key)) {\n return (readStyleValue(element, key) ||\n element.getAttribute(camelToDash(key)) ||\n 0);\n }\n key = convertAttrKey(key);\n return (element.getAttribute(camelToDash(key)) ??\n element.getAttribute(key) ??\n undefined);\n};\n/**\n * The per-element effect `animate()` binds through, so SVG values share\n * state with a direct `svgEffect()` call.\n */\nexport const svgSubjectEffect = /*@__PURE__*/ createEffect(addSVGValue, {\n test: isSVGElement,\n read: readSVGValue,\n});\nexport const svgEffect = /*@__PURE__*/ createSelectorEffect(svgSubjectEffect);\nfunction convertAttrKey(key) {\n return key.replace(/^attr([A-Z])/, (_, firstChar) => firstChar.toLowerCase());\n}\n//# sourceMappingURL=index.js.map","export const visualElementStore = new WeakMap();\n//# sourceMappingURL=store.js.map","/*\n Value in range from progress\n\n Given a lower limit and an upper limit, we return the value within\n that range as expressed by progress (usually a number from 0 to 1)\n\n So progress = 0.5 would change\n\n from -------- to\n\n to\n\n from ---- to\n\n E.g. from = 10, to = 20, progress = 0.5 => 15\n\n @param [number]: Lower limit of range\n @param [number]: Upper limit of range\n @param [number]: The progress between lower and upper limits expressed 0-1\n @return [number]: Value as calculated from progress within range (not limited within range)\n*/\nexport const mixNumber = (from, to, progress) => {\n return from + (to - from) * progress;\n};\n//# sourceMappingURL=number.js.map","export const isDragging = {\n x: false,\n y: false,\n};\nexport function isDragActive() {\n return isDragging.x || isDragging.y;\n}\n//# sourceMappingURL=is-active.js.map","import { calcLength } from \"../../../projection/geometry/delta-calc\";\nimport { mixNumber } from \"../../../utils/mix/number\";\nimport { progress as calcProgress, clamp, } from \"motion-utils\";\n/**\n * Apply constraints to a point. These constraints are both physical along an\n * axis, and an elastic factor that determines how much to constrain the point\n * by if it does lie outside the defined parameters.\n */\nexport function applyConstraints(point, { min, max }, elastic) {\n if (min !== undefined && point < min) {\n // If we have a min point defined, and this is outside of that, constrain\n point = elastic\n ? mixNumber(min, point, elastic.min)\n : Math.max(point, min);\n }\n else if (max !== undefined && point > max) {\n // If we have a max point defined, and this is outside of that, constrain\n point = elastic\n ? mixNumber(max, point, elastic.max)\n : Math.min(point, max);\n }\n return point;\n}\n/**\n * Calculates a min projection point based on a pointer, pointer progress\n * within the drag target, and constraints.\n *\n * For instance if an element was 100px width, we were dragging from 0.25\n * along this axis, the pointer is at 200px, and there were no constraints,\n * we would calculate a min projection point of 175px.\n */\nexport function calcConstrainedMinPoint(point, length, progress, constraints, elastic) {\n // Calculate a min point for this axis and apply it to the current pointer\n const min = point - length * progress;\n return constraints ? applyConstraints(min, constraints, elastic) : min;\n}\n/**\n * Calculate constraints in terms of the viewport when defined relatively to the\n * measured axis. This is measured from the nearest edge, so a max constraint of 200\n * on an axis with a max value of 300 would return a constraint of 500 - axis length\n */\nexport function calcRelativeAxisConstraints(axis, min, max) {\n return {\n min: min !== undefined ? axis.min + min : undefined,\n max: max !== undefined\n ? axis.max + max - (axis.max - axis.min)\n : undefined,\n };\n}\n/**\n * Calculate constraints in terms of the viewport when\n * defined relatively to the measured bounding box.\n */\nexport function calcRelativeConstraints(layoutBox, { top, left, bottom, right }) {\n return {\n x: calcRelativeAxisConstraints(layoutBox.x, left, right),\n y: calcRelativeAxisConstraints(layoutBox.y, top, bottom),\n };\n}\n/**\n * Calculate viewport constraints when defined as another viewport-relative axis\n */\nexport function calcViewportAxisConstraints(layoutAxis, constraintsAxis) {\n let min = constraintsAxis.min - layoutAxis.min;\n let max = constraintsAxis.max - layoutAxis.max;\n // If the constraints axis is actually smaller than the layout axis then we can\n // flip the constraints\n if (constraintsAxis.max - constraintsAxis.min <\n layoutAxis.max - layoutAxis.min) {\n ;\n [min, max] = [max, min];\n }\n return { min, max };\n}\n/**\n * Calculate viewport constraints when defined as another viewport-relative box\n */\nexport function calcViewportConstraints(layoutBox, constraintsBox) {\n return {\n x: calcViewportAxisConstraints(layoutBox.x, constraintsBox.x),\n y: calcViewportAxisConstraints(layoutBox.y, constraintsBox.y),\n };\n}\n/**\n * Calculate a transform origin relative to the source axis, between 0-1, that results\n * in an aesthetically pleasing scale/transform needed to project from source to target.\n */\nexport function calcOrigin(source, target) {\n let origin = 0.5;\n const sourceLength = calcLength(source);\n const targetLength = calcLength(target);\n if (targetLength > sourceLength) {\n origin = calcProgress(target.min, target.max - sourceLength, source.min);\n }\n else if (sourceLength > targetLength) {\n origin = calcProgress(source.min, source.max - targetLength, target.min);\n }\n return clamp(0, 1, origin);\n}\n/**\n * Calculate the relative progress of one constraints box relative to another.\n * Imagine a page scroll bar. At the top, this would return 0, at the bottom, 1.\n * Anywhere in-between, a value between 0 and 1.\n *\n * This also handles flipped constraints, for instance a draggable container within\n * a smaller viewport like a scrollable view.\n */\nexport function calcProgressWithinConstraints(layoutBox, constraintsBox) {\n return {\n x: calcOrigin(layoutBox.x, constraintsBox.x),\n y: calcOrigin(layoutBox.y, constraintsBox.y),\n };\n}\n/**\n * Calculate the an axis position based on two axes and a progress value.\n */\nexport function calcPositionFromProgress(axis, constraints, progress) {\n const axisLength = axis.max - axis.min;\n const min = mixNumber(constraints.min, constraints.max - axisLength, progress);\n return { min, max: min + axisLength };\n}\n/**\n * Rebase the calculated viewport constraints relative to the layout.min point.\n */\nexport function rebaseAxisConstraints(layout, constraints) {\n const relativeConstraints = {};\n if (constraints.min !== undefined) {\n relativeConstraints.min = constraints.min - layout.min;\n }\n if (constraints.max !== undefined) {\n relativeConstraints.max = constraints.max - layout.min;\n }\n return relativeConstraints;\n}\nexport const defaultElastic = 0.35;\n/**\n * Accepts a dragElastic prop and returns resolved elastic values for each axis.\n */\nexport function resolveDragElastic(dragElastic = defaultElastic) {\n if (dragElastic === false) {\n dragElastic = 0;\n }\n else if (dragElastic === true) {\n dragElastic = defaultElastic;\n }\n return {\n x: resolveAxisElastic(dragElastic, \"left\", \"right\"),\n y: resolveAxisElastic(dragElastic, \"top\", \"bottom\"),\n };\n}\nexport function resolveAxisElastic(dragElastic, minLabel, maxLabel) {\n return {\n min: resolvePointElastic(dragElastic, minLabel),\n max: resolvePointElastic(dragElastic, maxLabel),\n };\n}\nexport function resolvePointElastic(dragElastic, label) {\n return typeof dragElastic === \"number\"\n ? dragElastic\n : dragElastic[label] || 0;\n}\n//# sourceMappingURL=constraints.js.map","import { invariant } from \"motion-utils\";\nimport { animateMotionValue } from \"../../animation/interfaces/motion-value\";\nimport { getVariableValue } from \"../../animation/utils/css-variables-conversion\";\nimport { isCSSVariableToken } from \"../../animation/utils/is-css-variable\";\nimport { addDomEvent } from \"../../events/add-dom-event\";\nimport { addPointerEvent } from \"../../events/add-pointer-event\";\nimport { frame } from \"../../frameloop/frame\";\nimport { convertBoundingBoxToBox, convertBoxToBoundingBox, } from \"../../projection/geometry/conversion\";\nimport { calcLength } from \"../../projection/geometry/delta-calc\";\nimport { createBox } from \"../../projection/geometry/models\";\nimport { eachAxis } from \"../../projection/utils/each-axis\";\nimport { measurePageBox } from \"../../projection/utils/measure\";\nimport { resize } from \"../../resize\";\nimport { mixNumber } from \"../../utils/mix/number\";\nimport { percent, px } from \"../../value/types/numbers/units\";\nimport { addValueToWillChange } from \"../../value/will-change/add-will-change\";\nimport { PanSession } from \"../pan/PanSession\";\nimport { isElementTextInput } from \"../press/utils/is-keyboard-accessible\";\nimport { setDragLock } from \"./state/set-active\";\nimport { applyConstraints, calcOrigin, calcRelativeConstraints, calcViewportConstraints, defaultElastic, rebaseAxisConstraints, resolveDragElastic, } from \"./utils/constraints\";\n/**\n * Re-read the scroll of the projection's ancestors, and return that of the\n * `layoutScroll` ones as a key that changes when any of them scroll.\n *\n * Clear the cached scroll first so `updateScroll` bypasses its\n * per-animationId cache and re-reads the live value.\n */\nfunction measureScroll(projection) {\n let key = \"\";\n for (const node of projection.path) {\n node.scroll = undefined;\n node.updateScroll();\n const { scroll } = node;\n if (node !== projection.root && scroll) {\n key += scroll.offset.x + \",\" + scroll.offset.y + \",\";\n }\n }\n return key;\n}\nexport const elementDragControls = new WeakMap();\nexport class VisualElementDragControls {\n constructor(visualElement, readProps = () => visualElement.getProps()) {\n this.openDragLock = null;\n this.isDragging = false;\n this.currentDirection = null;\n /**\n * Where the drag started, which pointer offsets are added to. Public\n * so pinch() can restart a drag from where it leaves the element.\n */\n this.originPoint = { x: 0, y: 0 };\n /**\n * The permitted boundaries of travel, in pixels.\n */\n this.constraints = false;\n this.hasMutatedConstraints = false;\n /**\n * The per-axis resolved elastic values.\n */\n this.elastic = createBox();\n /**\n * The latest pointer event. Used as fallback when the `cancel` and `stop` functions are called without arguments.\n */\n this.latestPointerEvent = null;\n /**\n * The latest pan info. Used as fallback when the `cancel` and `stop` functions are called without arguments.\n */\n this.latestPanInfo = null;\n this.visualElement = visualElement;\n this.readProps = readProps;\n }\n start(originEvent, options = {}) {\n /**\n * Don't start dragging if this component is exiting\n */\n if (this.visualElement.presenceContext?.isPresent === false)\n return;\n const onSessionStart = (event) => {\n if (options.snapToCursor)\n this.snapToCursor(event);\n this.stopAnimation();\n };\n const onStart = (event, info) => {\n // Attempt to grab the global drag gesture lock - maybe make this part of PanSession\n const { drag, dragConstraints, dragPropagation, onDragStart } = this.getProps();\n if (drag && !dragPropagation) {\n this.openDragLock?.();\n this.openDragLock = setDragLock(drag);\n // If we don 't have the lock, don't start dragging\n if (!this.openDragLock)\n return;\n }\n this.latestPointerEvent = event;\n this.latestPanInfo = info;\n this.isDragging = true;\n this.currentDirection = null;\n this.resolveConstraints();\n const { projection } = this.visualElement;\n if (projection) {\n projection.isAnimationBlocked = true;\n projection.target = undefined;\n }\n /**\n * Record gesture origin and pointer offset\n */\n eachAxis((axis) => {\n let current = this.getAxisMotionValue(axis).get() || 0;\n /**\n * If the MotionValue is a CSS variable, like \"var(--y)\",\n * resolve it so it can be converted to px below.\n */\n if (isCSSVariableToken(current)) {\n current =\n getVariableValue(current, this.visualElement.current) || 0;\n }\n /**\n * If the MotionValue is a px or percentage value convert to px\n */\n if (px.test(current)) {\n current = parseFloat(current);\n }\n else if (percent.test(current)) {\n const measuredAxis = projection?.layout?.layoutBox[axis];\n if (measuredAxis) {\n current =\n calcLength(measuredAxis) *\n (parseFloat(current) / 100);\n }\n }\n this.originPoint[axis] = current;\n });\n this.point =\n typeof dragConstraints === \"function\" && dragConstraints(this);\n // Fire onDragStart event\n if (onDragStart) {\n frame.update(() => onDragStart(event, info), false, true);\n }\n addValueToWillChange(this.visualElement, \"transform\");\n this.visualElement.animationState?.setActive(\"whileDrag\", true);\n };\n const onMove = (event, info) => {\n this.latestPointerEvent = event;\n this.latestPanInfo = info;\n const { dragPropagation, dragDirectionLock, onDirectionLock, onDrag, } = this.getProps();\n // If we didn't successfully receive the gesture lock, early return.\n if (!dragPropagation && !this.openDragLock)\n return;\n const { offset } = info;\n // Attempt to detect drag direction if directionLock is true\n if (dragDirectionLock && this.currentDirection === null) {\n this.currentDirection = getCurrentDirection(offset);\n /**\n * Wait for more movement until a direction is set. Once\n * it is, apply this move too: it can be the last before\n * release when the browser coalesces a fast gesture.\n */\n if (this.currentDirection === null)\n return;\n onDirectionLock && onDirectionLock(this.currentDirection);\n }\n // Update each point with the latest position\n this.updateAxis(\"x\", offset);\n this.updateAxis(\"y\", offset);\n this.point && this.point.move();\n /**\n * Ideally we would leave the renderer to fire naturally at the end of\n * this frame but if the element is about to change layout as the result\n * of a re-render we want to ensure the browser can read the latest\n * bounding box to ensure the pointer and element don't fall out of sync.\n */\n this.visualElement.render();\n /**\n * This must fire after the render call as it might trigger a state\n * change which itself might trigger a layout update.\n */\n if (onDrag) {\n frame.update(() => onDrag(event, info), false, true);\n }\n };\n const onSessionEnd = (event, info) => {\n this.latestPointerEvent = event;\n this.latestPanInfo = info;\n this.stop(event, info);\n this.latestPointerEvent = null;\n this.latestPanInfo = null;\n };\n const resumeAnimation = () => {\n const { dragSnapToOrigin: snap } = this.getProps();\n if (snap || this.constraints || this.point) {\n this.startAnimation({ x: 0, y: 0 });\n }\n };\n const { dragSnapToOrigin } = this.getProps();\n this.panSession = new PanSession(originEvent, {\n onSessionStart,\n onStart,\n onMove,\n onSessionEnd,\n resumeAnimation,\n }, {\n ...options,\n transformPagePoint: this.visualElement.getTransformPagePoint(),\n dragSnapToOrigin,\n contextWindow: this.visualElement.current?.ownerDocument.defaultView,\n element: this.visualElement.current,\n });\n }\n /**\n * @param dragAxes - The axes to animate on release, if not the `drag`\n * prop's, e.g. when drag was disabled mid-gesture.\n */\n stop(event, panInfo, dragAxes) {\n const finalEvent = event || this.latestPointerEvent;\n const finalPanInfo = panInfo || this.latestPanInfo;\n const isDragging = this.isDragging;\n this.cancel();\n if (!isDragging || !finalPanInfo || !finalEvent)\n return;\n const { velocity } = finalPanInfo;\n this.startAnimation(velocity, dragAxes);\n const { onDragEnd } = this.getProps();\n if (onDragEnd) {\n frame.postRender(() => onDragEnd(finalEvent, finalPanInfo));\n }\n }\n cancel() {\n this.isDragging = false;\n const { projection, animationState } = this.visualElement;\n if (projection) {\n projection.isAnimationBlocked = false;\n }\n this.endPanSession();\n if (!this.getProps().dragPropagation && this.openDragLock) {\n this.openDragLock();\n this.openDragLock = null;\n }\n animationState?.setActive(\"whileDrag\", false);\n }\n /**\n * Clean up the pan session without modifying other drag state.\n * This is used during unmount to ensure event listeners are removed\n * without affecting projection animations or drag locks.\n */\n endPanSession() {\n this.panSession?.end();\n this.panSession = undefined;\n }\n updateAxis(axis, offset) {\n /**\n * Read drag per axis: a callback fired while updating the x axis\n * can synchronously re-render with new props.\n */\n const { drag } = this.readProps();\n // If we're not dragging this axis, do an early return.\n if (!offset || !shouldDrag(axis, drag, this.currentDirection))\n return;\n const axisValue = this.getAxisMotionValue(axis);\n let next = this.originPoint[axis] + offset[axis];\n // Apply constraints\n const constraints = this.constraints && this.constraints[axis];\n if (constraints) {\n next = applyConstraints(next, constraints, this.elastic[axis]);\n }\n this.point ? (this.point[axis] = next) : axisValue.set(next);\n }\n resolveConstraints() {\n const { dragConstraints, dragElastic } = this.getProps();\n const { projection } = this.visualElement;\n const layout = projection && (projection.layout || projection.measure(false));\n const prevConstraints = this.constraints;\n if (isElementConstraints(dragConstraints)) {\n /**\n * Ref constraints are measured with the layout. Scrolling a\n * `layoutScroll` ancestor since can move the element relative\n * to them without a layout measurement, so measure them again\n * (#2024). Otherwise keep them: they and the layout can both\n * have moved on the page since, e.g. when content above grows.\n */\n if (!this.constraints ||\n this.scroll !== measureScroll(projection)) {\n this.constraints = this.resolveRefConstraints();\n }\n }\n else {\n if (dragConstraints &&\n layout &&\n typeof dragConstraints === \"object\") {\n this.constraints = calcRelativeConstraints(layout.layoutBox, dragConstraints);\n }\n else {\n this.constraints = false;\n }\n }\n this.elastic = resolveDragElastic(dragElastic);\n /**\n * If we're outputting to external MotionValues, we want to rebase the measured constraints\n * from viewport-relative to component-relative. This only applies to relative (non-ref)\n * constraints, as ref-based constraints from calcViewportConstraints are already in the\n * correct coordinate space for the motion value transform offset.\n */\n if (prevConstraints !== this.constraints &&\n !isElementConstraints(dragConstraints) &&\n layout &&\n this.constraints &&\n !this.hasMutatedConstraints) {\n eachAxis((axis) => {\n if (this.constraints !== false &&\n this.getAxisMotionValue(axis)) {\n this.constraints[axis] = rebaseAxisConstraints(layout.layoutBox[axis], this.constraints[axis]);\n }\n });\n }\n }\n resolveRefConstraints() {\n const { dragConstraints: constraints, onMeasureDragConstraints } = this.getProps();\n if (!isElementConstraints(constraints))\n return false;\n const constraintsElement = resolveConstraintsElement(constraints);\n process.env.NODE_ENV !== \"production\" &&\n invariant(!!constraintsElement, \"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.\", \"drag-constraints-ref\");\n const { projection } = this.visualElement;\n // TODO\n if (!projection || !projection.layout)\n return false;\n /**\n * Refresh the scroll offsets of the root and `layoutScroll`\n * ancestors so the constraint's viewport box translates to the\n * layout's coordinates. The scroll captured when the layout was\n * measured can be stale if they've scrolled since — e.g. via the\n * browser restoring scroll on refresh, or an ancestor layout effect\n * running after this element's mount (#2829).\n */\n this.scroll = measureScroll(projection);\n const constraintsBox = measurePageBox(constraintsElement, projection.root, this.visualElement.getTransformPagePoint());\n /**\n * layoutBox removes the scroll of `layoutScroll` ancestors, so\n * remove it from the constraints box too.\n */\n let measuredConstraints = calcViewportConstraints(projection.layout.layoutBox, projection.removeElementScroll(constraintsBox));\n /**\n * If there's an onMeasureDragConstraints listener we call it and\n * if different constraints are returned, set constraints to that\n */\n if (onMeasureDragConstraints) {\n const userConstraints = onMeasureDragConstraints(convertBoxToBoundingBox(measuredConstraints));\n this.hasMutatedConstraints = !!userConstraints;\n if (userConstraints) {\n measuredConstraints = convertBoundingBoxToBox(userConstraints);\n }\n }\n return measuredConstraints;\n }\n startAnimation(velocity, dragAxes) {\n const { drag, dragMomentum, dragElastic, dragTransition, dragSnapToOrigin, onDragTransitionEnd, } = this.getProps();\n /**\n * Overdamp the boundary spring if `dragElastic` is disabled. There's still a frame\n * of spring animations so we should look into adding a disable spring option to `inertia`.\n * We could do something here where we affect the `bounceStiffness` and `bounceDamping`\n * using the value of `dragElastic`.\n */\n const options = {\n bounceStiffness: dragElastic ? 200 : 1000000,\n bounceDamping: dragElastic ? 40 : 10000000,\n timeConstant: 750,\n restDelta: 1,\n restSpeed: 10,\n ...dragTransition,\n };\n const axisVelocity = (axis) => dragMomentum &&\n !(this.point && dragSnapToOrigin) &&\n shouldDrag(axis, dragAxes || drag, this.currentDirection)\n ? velocity[axis]\n : 0;\n if (this.point && !dragSnapToOrigin) {\n return this.point\n .release({ x: axisVelocity(\"x\"), y: axisVelocity(\"y\") }, options)\n .then(onDragTransitionEnd);\n }\n const constraints = this.constraints || {};\n const momentumAnimations = eachAxis((axis) => {\n if (!shouldDrag(axis, dragAxes || drag, this.currentDirection)) {\n return;\n }\n let transition = constraints[axis] || {};\n if (dragSnapToOrigin === true ||\n dragSnapToOrigin === axis)\n transition = { min: 0, max: 0 };\n const inertia = {\n type: \"inertia\",\n velocity: axisVelocity(axis),\n ...options,\n ...transition,\n };\n // If we're not animating on an externally-provided `MotionValue` we can use the\n // component's animation controls which will handle interactions with whileHover (etc),\n // otherwise we just have to animate the `MotionValue` itself.\n return this.startAxisValueAnimation(axis, inertia);\n });\n // Run all animations and then resolve the new drag constraints.\n return Promise.all(momentumAnimations).then(onDragTransitionEnd);\n }\n startAxisValueAnimation(axis, transition) {\n const axisValue = this.getAxisMotionValue(axis);\n addValueToWillChange(this.visualElement, axis);\n return axisValue.start(animateMotionValue(axis, axisValue, 0, transition, this.visualElement, false));\n }\n stopAnimation() {\n eachAxis((axis) => this.getAxisMotionValue(axis).stop());\n }\n /**\n * Drag works differently depending on which props are provided.\n *\n * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.\n * - Otherwise, we apply the delta to the x/y motion values.\n */\n getAxisMotionValue(axis) {\n const dragKey = `_drag${axis.toUpperCase()}`;\n const props = this.readProps();\n const externalMotionValue = props[dragKey];\n return externalMotionValue\n ? externalMotionValue\n : this.visualElement.getValue(axis, this.visualElement.latestValues[axis] ?? 0);\n }\n /**\n * Measure the live box - projection.layout may or may not include the\n * drag transform, depending on when it was measured.\n */\n snapToCursor({ clientX, clientY }) {\n const { drag } = this.getProps();\n const point = { x: clientX, y: clientY };\n const cursor = this.visualElement.getTransformPagePoint()?.(point) || point;\n const box = this.visualElement.measureViewportBox();\n eachAxis((axis) => {\n if (!shouldDrag(axis, drag, this.currentDirection))\n return;\n const axisValue = this.getAxisMotionValue(axis);\n const { min, max } = box[axis];\n axisValue.set((axisValue.get() || 0) + cursor[axis] - mixNumber(min, max, 0.5));\n });\n }\n /**\n * When the viewport resizes we want to check if the measured constraints\n * have changed and, if so, reposition the element within those new constraints\n * relative to where it was before the resize.\n */\n scalePositionWithinConstraints() {\n if (!this.visualElement.current)\n return;\n const { drag, dragConstraints } = this.getProps();\n const { projection } = this.visualElement;\n if (!isElementConstraints(dragConstraints) ||\n !projection ||\n !this.constraints)\n return;\n /**\n * Stop current animations as there can be visual glitching if we try to do\n * this mid-animation\n */\n this.stopAnimation();\n /**\n * Record the relative position of the dragged element relative to the\n * constraints box and save as a progress value.\n */\n const constraints = this.constraints;\n const boxProgress = { x: 0, y: 0 };\n eachAxis((axis) => {\n const latest = this.getAxisMotionValue(axis).get();\n boxProgress[axis] = calcOrigin({ min: latest, max: latest }, constraints[axis]);\n });\n /**\n * Update the layout of this element and resolve the latest drag constraints\n */\n const { transformTemplate } = this.visualElement.getProps();\n this.visualElement.current.style.transform = transformTemplate\n ? transformTemplate({}, \"\")\n : \"none\";\n projection.root?.updateScroll();\n projection.updateLayout();\n /**\n * Reset constraints so resolveConstraints() will recalculate them\n * with the freshly measured layout rather than returning the cached value.\n */\n this.constraints = false;\n this.resolveConstraints();\n /**\n * For each axis, calculate the current progress of the layout axis\n * within the new constraints.\n */\n eachAxis((axis) => {\n const axisValue = this.getAxisMotionValue(axis);\n /**\n * An element resting at its origin has no offset to preserve,\n * and re-projecting 0 into the new constraints would move it.\n */\n if (!shouldDrag(axis, drag, null) || !axisValue.get())\n return;\n /**\n * Calculate a new transform based on the previous box progress\n */\n const { min, max } = this.constraints[axis];\n axisValue.set(mixNumber(min, max, boxProgress[axis]));\n });\n /**\n * Flush the updated transform to the DOM synchronously to prevent\n * a visual flash at the element's CSS layout position (0,0) when\n * the transform was stripped for measurement.\n */\n this.visualElement.render();\n }\n addListeners() {\n if (!this.visualElement.current)\n return;\n elementDragControls.set(this.visualElement, this);\n const element = this.visualElement.current;\n /**\n * Attach a pointerdown event listener on this DOM element to initiate drag tracking.\n */\n const stopPointerListener = addPointerEvent(element, \"pointerdown\", (event) => {\n const { drag, dragListener = true } = this.getProps();\n const target = event.target;\n /**\n * Only block drag if clicking on a text input child element\n * (input, textarea, select, contenteditable) where users might\n * want to select text or interact with the control.\n *\n * Buttons and links don't block drag since they don't have\n * click-and-move actions of their own.\n */\n const isClickingTextInputChild = target !== element && isElementTextInput(target);\n if (drag && dragListener && !isClickingTextInputChild) {\n this.start(event);\n }\n });\n /**\n * If using ref-based constraints, observe both the draggable element\n * and the constraint container for size changes via ResizeObserver.\n * Setup is deferred because dragConstraints.current is null when\n * addListeners first runs (React hasn't committed the ref yet).\n */\n let stopResizeObservers;\n const measureDragConstraints = () => {\n const { dragConstraints } = this.getProps();\n const constraintsElement = isElementConstraints(dragConstraints) &&\n resolveConstraintsElement(dragConstraints);\n if (constraintsElement) {\n this.constraints = this.resolveRefConstraints();\n if (!stopResizeObservers) {\n stopResizeObservers = startResizeObservers(element, constraintsElement, () => this.scalePositionWithinConstraints());\n }\n }\n };\n const { projection } = this.visualElement;\n const stopMeasureLayoutListener = projection.addEventListener(\"measure\", measureDragConstraints);\n if (!projection.layout) {\n projection.root?.updateScroll();\n projection.updateLayout();\n }\n frame.read(measureDragConstraints);\n /**\n * Attach a window resize listener to scale the draggable target within its defined\n * constraints as the window resizes.\n */\n const stopResizeListener = addDomEvent(window, \"resize\", () => this.scalePositionWithinConstraints());\n /**\n * If the element's layout changes, calculate the delta and apply that to\n * the drag gesture's origin point.\n */\n const stopLayoutUpdateListener = projection.addEventListener(\"didUpdate\", (({ delta, hasLayoutChanged }) => {\n if (this.isDragging && hasLayoutChanged) {\n eachAxis((axis) => {\n /**\n * Only compensate axes this gesture drags. A\n * non-drag axis follows its layout instead, as\n * nothing would ever move it back (e.g. snapping\n * to origin only animates drag axes).\n */\n if (!shouldDrag(axis, this.getProps().drag, this.currentDirection))\n return;\n const motionValue = this.getAxisMotionValue(axis);\n this.originPoint[axis] += delta[axis].translate;\n motionValue.set(motionValue.get() + delta[axis].translate);\n });\n this.visualElement.render();\n }\n }));\n return () => {\n stopResizeListener();\n stopPointerListener();\n stopMeasureLayoutListener();\n stopLayoutUpdateListener();\n stopResizeObservers?.();\n };\n }\n getProps() {\n const props = this.readProps();\n const { dragElastic = defaultElastic, dragMomentum = true } = props;\n return { ...props, dragElastic, dragMomentum };\n }\n}\n/**\n * `dragConstraints` can be an element, or a ref (`{ current }`) to one.\n */\nfunction isElementConstraints(constraints) {\n return (!!constraints &&\n typeof constraints === \"object\" &&\n (\"current\" in constraints || \"nodeType\" in constraints));\n}\nconst resolveConstraintsElement = (constraints) => \"current\" in constraints ? constraints.current : constraints;\nfunction skipFirstCall(callback) {\n let isFirst = true;\n return () => {\n if (isFirst) {\n isFirst = false;\n return;\n }\n callback();\n };\n}\nfunction startResizeObservers(element, constraintsElement, onResize) {\n const stopElement = resize(element, skipFirstCall(onResize));\n const stopContainer = resize(constraintsElement, skipFirstCall(onResize));\n return () => {\n stopElement();\n stopContainer();\n };\n}\nfunction shouldDrag(direction, drag, currentDirection) {\n return ((drag === true || drag === direction) &&\n (currentDirection === null || currentDirection === direction));\n}\n/**\n * Based on an x/y offset determine the current drag direction. If both axis' offsets are lower\n * than the provided threshold, return `null`.\n *\n * @param offset - The x/y offset from origin.\n * @param lockThreshold - (Optional) - the minimum absolute offset before we can determine a drag direction.\n */\nfunction getCurrentDirection(offset, lockThreshold = 10) {\n let direction = null;\n if (Math.abs(offset.y) > lockThreshold) {\n direction = \"y\";\n }\n else if (Math.abs(offset.x) > lockThreshold) {\n direction = \"x\";\n }\n return direction;\n}\nexport function expectsResolvedDragConstraints({ dragConstraints, onMeasureDragConstraints, }) {\n return isElementConstraints(dragConstraints) && !!onMeasureDragConstraints;\n}\n//# sourceMappingURL=VisualElementDragControls.js.map","import { clamp } from \"motion-utils\";\nimport { spring } from \"../../animation/generators/spring\";\nimport { readStyleValue, styleSubjectEffect } from \"../../effects/style\";\nimport { svgSubjectEffect } from \"../../effects/svg\";\nimport { cancelFrame, frame } from \"../../frameloop\";\nimport { time } from \"../../frameloop/sync-time\";\nimport { visualElementStore } from \"../../render/store\";\nimport { activeScope, addToScope } from \"../../scope/active\";\nimport { isSVGElement } from \"../../utils/is-svg-element\";\nimport { mixNumber } from \"../../utils/mix/number\";\nimport { resolveElements, } from \"../../utils/resolve-elements\";\nimport { motionValue } from \"../../value\";\nimport { setDragLock } from \"../drag/state/set-active\";\nimport { applyConstraints, defaultElastic } from \"../drag/utils/constraints\";\nimport { elementDragControls } from \"../drag/VisualElementDragControls\";\n/**\n * A trackpad pinch arrives as a stream of `wheel` events with no end\n * event, so it ends once none have arrived for this long.\n */\nconst wheelTimeout = 150;\n/**\n * Convert an `x`/`y` set in other units (e.g. `\"-50%\"` to centre an\n * element) to pixels, so the gesture can add to it.\n */\nconst toPixels = (value, size) => {\n const latest = value.get();\n if (typeof latest === \"string\") {\n value.set(parseFloat(latest) * (latest.endsWith(\"%\") ? size / 100 : 1));\n }\n};\nconst limitsOf = (option) => typeof option === \"object\" ? option : {};\n/**\n * Resolve `elastic` to a resistance for each side, as for `dragElastic`.\n */\nconst resolveElastic = (elastic = defaultElastic) => {\n const side = (value) => value === true ? defaultElastic : +(value || 0);\n return typeof elastic === \"object\"\n ? { min: side(elastic.min), max: side(elastic.max) }\n : { min: side(elastic), max: side(elastic) };\n};\n/**\n * Whether the gesture writes `x`/`y`: to follow the focal point, or to\n * keep an `origin` on the element in place.\n */\nconst writesXY = ({ pan, origin }) => pan !== false || !!origin;\nconst clampTo = (value, { min = -Infinity, max = Infinity }) => clamp(min, max, value);\n/**\n * The raw gesture value that elastic shows as `value`. A pinch that starts\n * while a value is still past its limit (like during a spring back) carries\n * on from it, rather than jumping.\n */\nconst unconstrain = (value, option, resistance) => {\n const limit = clampTo(value, limitsOf(option));\n const elastic = resistance[value < limit ? \"min\" : \"max\"];\n return elastic ? limit + (value - limit) / elastic : value;\n};\n/**\n * Listen for pinch gestures on `element`: two touches (or pens), a trackpad\n * pinch (`wheel` with `ctrlKey`, as Chrome, Edge and Firefox report it),\n * and Safari's `gesture*` events.\n *\n * `getValues` is called each time a gesture starts, in the frame's read\n * step, for the scale/rotate/x/y values to write to. It runs alongside the\n * element measurement so neither forces a layout.\n *\n * `getOptions` is read whenever it's needed, so options can change while\n * listening. Return `false` to disable the gesture, which also ends one in\n * progress.\n *\n * `onPinchStart` is called once as each gesture starts, with the gesture's\n * info as a third argument. It can return the gesture's handlers, as for\n * `pinch()`.\n */\nexport function addPinchListeners(element, getValues, getEnabledOptions, onPinchStart) {\n const pointers = new Map();\n /**\n * The gesture as last reported: focal point, log of a distance and an\n * angle. Only changes in distance and angle matter, so trackpad and\n * Safari input write a virtual distance (the scale) here. Logs keep\n * a long trackpad pinch from overflowing.\n */\n const current = { x: 0, y: 0, l: 0, a: 0 };\n const start = { ...current };\n const prev = { ...current };\n let source;\n let lastEvent;\n let values;\n let originX = 0;\n let originY = 0;\n let width = 0;\n let height = 0;\n let lastX = 0;\n let lastY = 0;\n let hasMoved = false;\n let wheelTime = 0;\n let handlers = {};\n let unlock;\n /**\n * The gesture's scale and rotation before limits and elastic apply.\n */\n let rawScale = 1;\n let rawRotate = 0;\n let stopSnap = () => { };\n /**\n * The latest enabled options, so a gesture disabled mid-way can still\n * report its end.\n */\n let options = {};\n const getOptions = () => (options = getEnabledOptions() || options);\n const info = () => ({\n point: { x: current.x, y: current.y },\n offset: { x: current.x - start.x, y: current.y - start.y },\n scale: Math.exp(current.l - start.l),\n rotate: current.a - start.a,\n });\n /**\n * Read the element's box and values, and find its layout origin: its\n * centre without `x`/`y`. Scale and rotate are applied around the\n * centre (the default transform origin), so they don't move it.\n */\n const measure = () => {\n const box = element.getBoundingClientRect();\n const { left, top } = box;\n const { scale, rotate, elastic } = getOptions();\n const [s, r, x, y] = (values = getValues());\n const resistance = resolveElastic(elastic);\n /**\n * Stop animations on values this gesture writes, and leave the\n * rest running.\n */\n scale !== false && s.stop();\n rotate !== false && r.stop();\n rawScale = unconstrain(s.get(), scale, resistance);\n rawRotate = unconstrain(r.get(), rotate, resistance);\n width = element.offsetWidth ?? box.width;\n height = element.offsetHeight ?? box.height;\n if (writesXY(options)) {\n x.stop();\n y.stop();\n toPixels(x, width);\n toPixels(y, height);\n }\n lastX = x.get();\n lastY = y.get();\n originX = left + box.width / 2 - lastX;\n originY = top + box.height / 2 - lastY;\n };\n /**\n * The point scale and rotation pivot around, in client coordinates:\n * the focal point, or `origin` on the element at scale `s`, rotation\n * `r` and offset `x`/`y`.\n */\n const pivot = (focal, s, r, x, y) => {\n const { origin } = options;\n if (typeof origin !== \"object\")\n return focal;\n const a = (r * Math.PI) / 180;\n const u = (origin.x - 0.5) * width * s;\n const v = (origin.y - 0.5) * height * s;\n return {\n x: originX + x + Math.cos(a) * u - Math.sin(a) * v,\n y: originY + y + Math.sin(a) * u + Math.cos(a) * v,\n };\n };\n const dragControls = () => elementDragControls.get(visualElementStore.get(element));\n /**\n * On release, spring scale and rotation back inside their limits (or\n * to a `snap` angle), keeping the focal point in place, or everything\n * back to its origin with `snapToOrigin`.\n */\n const snap = () => {\n const { scale: scaleOption, rotate: rotateOption, snapToOrigin, transition, } = options;\n const [scale, rotate, x, y] = values;\n const s0 = scale.get();\n const r0 = rotate.get();\n const x0 = x.get();\n const y0 = y.get();\n const { snap: step } = limitsOf(rotateOption);\n let s1 = clampTo(s0, limitsOf(scaleOption));\n /**\n * Snap to the step nearest where the release velocity would carry\n * the rotation, found as inertia finds its target (with a lower power\n * than inertia's 0.8).\n */\n let r1 = clampTo(step\n ? Math.round((r0 + 0.2 * rotate.getVelocity()) / step) * step\n : r0, limitsOf(rotateOption));\n if (snapToOrigin) {\n s1 = 1;\n // The nearest upright angle, so it turns the shortest way\n r1 = Math.round(r0 / 360) * 360;\n }\n /**\n * Keep the focal point in place, unless the element doesn't move\n * with it, or a drag carries on and owns x/y.\n */\n const moves = writesXY(options) && !dragControls()?.isDragging;\n const p0 = pivot(current, s0, r0, x0, y0);\n const vx = originX + x0 - p0.x;\n const vy = originY + y0 - p0.y;\n /**\n * Scale, rotation and x/y at progress `p` of the snap, keeping the\n * focal point in place.\n */\n const at = (p) => {\n const k = mixNumber(s0, s1, p);\n const r = mixNumber(r0, r1, p);\n const angle = ((r - r0) * Math.PI) / 180;\n const cos = (Math.cos(angle) * k) / s0;\n const sin = (Math.sin(angle) * k) / s0;\n return [\n k,\n r,\n x0 + cos * vx - sin * vy - vx,\n y0 + sin * vx + cos * vy - vy,\n ];\n };\n if (!s0 ||\n (s1 === s0 && r1 === r0 && !(snapToOrigin && moves && (x0 || y0)))) {\n return;\n }\n const generator = spring({\n keyframes: [0, 1],\n stiffness: 200,\n damping: 40,\n ...transition,\n });\n const startTime = time.now();\n /**\n * Drive the values from one spring, from 0 to 1, so they stay in\n * step and the focal point stays in place.\n */\n const tick = () => {\n const { value: p, done } = generator.next(time.now() - startTime);\n if (done)\n stopSnap();\n const [k, r, fx, fy] = at(p);\n scaleOption !== false && scale.set(k);\n rotateOption !== false && rotate.set(r);\n // A drag that starts mid-snap owns x/y from then on.\n if (moves && !dragControls()?.isDragging) {\n x.set(snapToOrigin ? mixNumber(x0, 0, p) : fx);\n y.set(snapToOrigin ? mixNumber(y0, 0, p) : fy);\n }\n };\n stopSnap = () => cancelFrame(tick);\n frame.update(tick, true);\n };\n /**\n * Apply the change in the gesture since the last frame as an\n * incremental scale and rotation around the previous focal point,\n * plus the focal point's movement.\n */\n const apply = () => {\n if (!values || !hasMoved)\n return;\n hasMoved = false;\n const { rotate: rotateOption, scale: scaleOption, pan, elastic, } = getOptions();\n const [scale, rotate, x, y] = values;\n const resistance = resolveElastic(elastic);\n const latest = scale.get();\n const drag = dragControls();\n const isDragging = drag?.isDragging;\n if (!isDragging) {\n lastX = x.get();\n lastY = y.get();\n }\n const p = pivot(prev, latest, rotate.get(), lastX, lastY);\n let theta = 0;\n let k = 1;\n /**\n * Apply limits and elastic to the gesture's raw scale and rotation.\n * At a hard limit, the raw value stops too, so moving back responds\n * straight away.\n */\n const constrain = (raw, option) => {\n const limits = limitsOf(option);\n const limit = clampTo(raw, limits);\n return resistance[raw < limit ? \"min\" : \"max\"]\n ? [applyConstraints(raw, limits, resistance), raw]\n : [limit, limit];\n };\n if (scaleOption !== false && latest) {\n const [next, raw] = constrain(clamp(1e-9, 1e9, rawScale * Math.exp(current.l - prev.l)), scaleOption);\n rawScale = raw;\n k = next / latest;\n scale.set(next);\n }\n if (rotateOption !== false) {\n const [next, raw] = constrain(rawRotate + current.a - prev.a, rotateOption);\n rawRotate = raw;\n theta = next - rotate.get();\n if (theta)\n rotate.set(next);\n }\n if (writesXY(options)) {\n /**\n * Pinch owns x/y while it runs, so stop any animation started\n * on them since (like a drag's snap back) taking over after.\n */\n x.stop();\n y.stop();\n /**\n * If drag() or the drag prop is dragging this element with one\n * of the touches, it has set x/y this frame to where it started\n * plus the touch's offset. Carry on from our own values instead,\n * and restart the drag from them and the touch's latest point.\n * That way it continues from wherever the pinch leaves the\n * element, and its release velocity only counts movement after\n * the pinch, so a zoom doesn't end in a fling.\n */\n const angle = (theta * Math.PI) / 180;\n const cos = Math.cos(angle) * k;\n const sin = Math.sin(angle) * k;\n const dx = p.x - originX - lastX;\n const dy = p.y - originY - lastY;\n const panX = pan !== false ? current.x - prev.x : 0;\n const panY = pan !== false ? current.y - prev.y : 0;\n /**\n * Move the centre so the pivot, scaled and rotated around the\n * centre, stays in place, plus the focal point's movement.\n */\n lastX += dx + panX - (cos * dx - sin * dy);\n lastY += dy + panY - (sin * dx + cos * dy);\n if (isDragging) {\n const history = drag.panSession.history;\n history.splice(0, history.length - 1);\n /**\n * Date the point long ago, so drag only measures release\n * velocity from moves after the pinch. A move that drag\n * processes as the touch lifts is part of the pinch.\n */\n history[0].timestamp = -Infinity;\n drag.originPoint.x = lastX;\n drag.originPoint.y = lastY;\n }\n x.set(lastX);\n y.set(lastY);\n }\n Object.assign(prev, current);\n handlers.onPinch?.(lastEvent, info());\n };\n /**\n * Runs after the update step, where drag sets x/y, so it has the final\n * say on them each frame.\n */\n const update = () => {\n if (!getEnabledOptions())\n return end(lastEvent);\n apply();\n if (source === \"wheel\" && time.now() - wheelTime > wheelTimeout) {\n end(lastEvent);\n }\n };\n const begin = (event, from) => {\n if (!getEnabledOptions())\n return;\n stopSnap();\n source = from;\n lastEvent = event;\n hasMoved = false;\n values = undefined;\n handlers = {};\n Object.assign(start, current);\n Object.assign(prev, current);\n frame.read(measure);\n frame.preRender(update, true);\n const result = onPinchStart(element, event, info());\n handlers =\n typeof result === \"function\" ? { onComplete: result } : result || {};\n };\n const end = (event) => {\n if (!source)\n return;\n cancelFrame(measure);\n cancelFrame(update);\n if (getEnabledOptions()) {\n apply();\n values && snap();\n }\n source = undefined;\n handlers.onComplete?.(event, info());\n };\n const moved = (event) => {\n lastEvent = event;\n hasMoved = true;\n };\n const readPointers = () => {\n const [a, b] = pointers.values();\n const angle = (Math.atan2(b.y - a.y, b.x - a.x) * 180) / Math.PI;\n const delta = angle - current.a;\n current.x = (a.x + b.x) / 2;\n current.y = (a.y + b.y) / 2;\n current.l = Math.log(Math.hypot(b.x - a.x, b.y - a.y) || 1);\n /**\n * Take the shortest way round, so rotation keeps counting past\n * 180deg rather than flipping to -180deg.\n */\n current.a += delta - 360 * Math.round(delta / 360);\n };\n const setPointer = (event) => pointers.set(event.pointerId, { x: event.clientX, y: event.clientY });\n const onPointerMove = (event) => {\n if (!pointers.has(event.pointerId))\n return;\n setPointer(event);\n if (source === \"pointer\") {\n readPointers();\n moved(event);\n }\n };\n const onPointerUp = (event) => {\n if (!pointers.delete(event.pointerId))\n return;\n if (source === \"pointer\")\n end(event);\n if (!pointers.size) {\n toggleWindowListeners();\n release();\n }\n };\n /**\n * Once a touch is down on the element, listen on the window too, so\n * the second touch can land beside it (for instance on a small image).\n */\n const onPointerDown = (event) => {\n if (source ||\n pointers.size > 1 ||\n pointers.has(event.pointerId) ||\n event.pointerType === \"mouse\") {\n return;\n }\n if (!pointers.size)\n toggleWindowListeners(true);\n setPointer(event);\n if (pointers.size === 2) {\n readPointers();\n begin(event, \"pointer\");\n /**\n * Unless this element drags, hold the drag lock until every\n * touch lifts. A press on it then ends as a cancel, rather than\n * a tap, and a draggable parent doesn't drag.\n */\n if (source &&\n !unlock &&\n !elementDragControls.get(visualElementStore.get(element))) {\n unlock = setDragLock(true);\n }\n }\n };\n /**\n * Release the drag lock a frame later, so a press ending on this same\n * pointerup still sees it.\n */\n const release = () => {\n const done = unlock;\n unlock = undefined;\n done && frame.postRender(done);\n };\n const toggleWindowListeners = (add) => {\n const method = add ? \"addEventListener\" : \"removeEventListener\";\n window[method](\"pointerdown\", onPointerDown);\n window[method](\"pointermove\", onPointerMove);\n window[method](\"pointerup\", onPointerUp);\n window[method](\"pointercancel\", onPointerUp);\n };\n const onWheel = (event) => {\n if (!event.ctrlKey || (source && source !== \"wheel\"))\n return;\n current.x = event.clientX;\n current.y = event.clientY;\n if (!source) {\n current.l = 0;\n begin(event, \"wheel\");\n if (!source)\n return;\n }\n event.preventDefault();\n /**\n * Lines (Firefox's mouse wheel) to pixels, and cap each event so a\n * mouse wheel notch with ctrl held (about 100px) zooms a step.\n */\n current.l -=\n clamp(-50, 50, event.deltaY * (event.deltaMode ? 16 : 1)) / 100;\n wheelTime = time.now();\n moved(event);\n };\n /**\n * Safari reports trackpad pinches as `gesture*` events. iOS Safari\n * fires them for touches too, alongside the pointer events we track.\n */\n const onGesture = (event) => {\n if (!pointers.size && (!source || source === \"gesture\")) {\n const { scale, rotation, clientX, clientY } = event;\n current.x = clientX;\n current.y = clientY;\n current.l = Math.log(scale);\n current.a = rotation;\n if (source) {\n moved(event);\n if (event.type === \"gestureend\")\n end(event);\n }\n else if (event.type === \"gesturestart\") {\n begin(event, \"gesture\");\n }\n }\n if (source)\n event.preventDefault();\n };\n const listeners = {\n pointerdown: onPointerDown,\n wheel: onWheel,\n gesturestart: onGesture,\n gesturechange: onGesture,\n gestureend: onGesture,\n };\n for (const name in listeners) {\n element.addEventListener(name, listeners[name], { passive: false });\n }\n return () => {\n for (const name in listeners) {\n element.removeEventListener(name, listeners[name]);\n }\n toggleWindowListeners();\n end(lastEvent);\n stopSnap();\n pointers.clear();\n release();\n };\n}\nconst valueKeys = [\"scale\", \"rotate\", \"x\", \"y\"];\n/**\n * The element's scale/rotate/x/y motion values: those of its\n * VisualElement if it has one (it's a <motion.*> component, or drag() or\n * animateLayout() own it), otherwise those animate() binds to it, created\n * from its current style if this is the first time.\n */\nconst getElementValues = (element) => {\n const visualElement = visualElementStore.get(element);\n const effect = isSVGElement(element) ? svgSubjectEffect : styleSubjectEffect;\n return valueKeys.map((key) => {\n if (visualElement) {\n return visualElement.getValue(key, key === \"scale\" ? 1 : 0);\n }\n let value = effect.get(element, key);\n if (!value) {\n value = motionValue(readStyleValue(element, key));\n effect(element, { [key]: value });\n }\n return value;\n });\n};\nexport function pinch(elementOrSelector, startOrOptions, options = {}) {\n let onPinchStart = () => { };\n if (typeof startOrOptions === \"function\") {\n onPinchStart = startOrOptions;\n }\n else if (startOrOptions) {\n options = startOrOptions;\n }\n const scope = activeScope.current;\n /**\n * Run the start callback and the handlers it returns in the active\n * scope, so work they start is collected. A returned function is\n * bound by `scope.bind` itself.\n */\n if (scope) {\n const start = scope.bind(onPinchStart);\n onPinchStart = (element, event) => {\n const result = start(element, event);\n if (typeof result !== \"object\")\n return result;\n const handlers = {};\n for (const key in result) {\n const name = key;\n const handler = result[name];\n handlers[name] = handler && scope.bind(handler);\n }\n return handlers;\n };\n }\n const cleanups = resolveElements(elementOrSelector).map((element) => {\n scope?.track(element);\n const { style } = element;\n const touchAction = style.touchAction;\n style.touchAction = \"none\";\n const remove = addPinchListeners(element, () => getElementValues(element), () => options, onPinchStart);\n return () => {\n remove();\n style.touchAction = touchAction;\n };\n });\n return addToScope(() => cleanups.forEach((cleanup) => cleanup()));\n}\n//# sourceMappingURL=index.js.map","import { isDragging } from \"./is-active\";\nexport function setDragLock(axis) {\n if (axis === \"x\" || axis === \"y\") {\n if (isDragging[axis]) {\n return null;\n }\n else {\n isDragging[axis] = true;\n return () => {\n isDragging[axis] = false;\n };\n }\n }\n else {\n if (isDragging.x || isDragging.y) {\n return null;\n }\n else {\n isDragging.x = isDragging.y = true;\n return () => {\n isDragging.x = isDragging.y = false;\n };\n }\n }\n}\n//# sourceMappingURL=set-active.js.map","import { activeScope } from \"../scope/active\";\nexport function resolveElements(elementOrSelector, scope, selectorCache) {\n if (elementOrSelector == null) {\n return [];\n }\n if (elementOrSelector instanceof EventTarget) {\n return [elementOrSelector];\n }\n else if (typeof elementOrSelector === \"string\") {\n const root = scope\n ? scope.current\n : activeScope.current?.root || document;\n const elements = selectorCache?.[elementOrSelector] ??\n root.querySelectorAll(elementOrSelector);\n return elements ? Array.from(elements) : [];\n }\n return Array.from(elementOrSelector).filter((element) => element != null);\n}\n//# sourceMappingURL=resolve-elements.js.map"],"names":["clamp","min","max","v","MotionGlobalConfig","isObject","value","SubscriptionManager","constructor","this","subscriptions","add","handler","arr","item","indexOf","push","remove","index","splice","removeItem","notify","a","b","c","numSubscriptions","length","i","getSize","clear","secondsToMilliseconds","seconds","millisecondsToSeconds","milliseconds","maxGeneratorDuration","calcGeneratorDuration","generator","timeStep","maxDuration","keyframes","duration","state","next","done","Infinity","bounceToDampingRatio","bounce","Math","overdampedFreqScale","dampingRatio","criticalFreqTime","root","sqrt","slow","fast","target","exp","approximateRoot","freqTime","calcAngularFreq","undampedFreq","rootIterations","envelope","derivative","initialGuess","result","safeMin","isValidPhysics","canBeZero","resolvePhysics","getSpringOptions","options","validStiffness","stiffness","validDamping","damping","validMass","mass","springOptions","isResolvedFromDuration","isTimeDefined","undefined","visualDuration","PI","Object","assign","exponentialDecay","delta","e","f","g","criticalFreq","findSpring","springGenerator","optionsOrVisualDuration","origin","inheritVelocity","velocity","undampedAngularFreq","decay","s","restSpeed","restDelta","setRestThresholds","isGranularScale","abs","resolveSpring","resolveVelocity","update","angularFreq","A","sinC","cosC","t","env","sin","cos","sample","C","dampedAngularFreq","limit","decayAt","rate","S","F","P","calculatedDuration","retarget","newVelocity","current","currentVelocity","toString","easingDuration","easing","resolution","points","numPoints","round","substring","generateLinearEasing","progress","spring","applyToOptions","generatorOptions","scale","createGenerator","k","type","ease","createGeneratorEasing","transformGroups","WeakMap","isCSSVar","name","startsWith","radToDeg","rad","rotate","angle","atan2","rebaseAngle","matrix2dParsers","x","y","translateX","translateY","scaleX","scaleY","scaleZ","rotateZ","skewX","atan","skewY","skew","hypot","matrix3dParsers","z","translateZ","rotateX","rotateY","defaultTransformValue","includes","readTransformValue","instance","transform","getComputedStyle","match","valueParser","values","split","map","parseFloat","parseValueFromTransform","transformPropOrder","transformProps","Set","isHTMLElement","element","isSVGElement","stepsOrder","createRenderBatcher","scheduleNextBatch","allowKeepAlive","timestamp","isProcessing","runNextFrame","useDefaultElapsed","flagRunNextFrame","steps","reduce","acc","key","running","thisFrame","nextFrame","flushNextFrame","toKeepAlive","latestFrameData","triggerCallback","callback","has","step","schedule","keepAlive","immediate","addToCurrentFrame","queue","delete","cancel","process","frameData","prevFrame","forEach","createRenderStep","setup","read","resolveKeyframes","preUpdate","preRender","render","postRender","processBatch","useManualTiming","performance","now","frame","cancelFrame","requestAnimationFrame","any","clearTime","time","set","newTime","queueMicrotask","MotionValue","init","canTrackVelocity","events","updateAndNotify","currentTime","updatedAt","setPrevFrameValue","prev","setCurrent","dirty","dependents","dependent","hasAnimated","owner","isNaN","prevFrameValue","prevUpdatedAt","onChange","subscription","on","eventName","_a","onChangeSubscribe","change","changeSubscriber","stopIfUnobserved","stop","clearListeners","eventManagers","attach","passiveEffect","stopPassiveEffect","setWithVelocity","jump","endAnimation","addDependent","removeDependent","get","sampled","animation","liveValue","getCurrent","getPrevious","getVelocity","frameDuration","start","startAnimation","Promise","resolve","run","onComplete","isComplete","animationComplete","animationStart","animationCancel","isAnimating","destroy","number","test","parse","alpha","default","int","createUnitType","unit","endsWith","degrees","percent","px","progressPercentage","transformValueTypes","pathRotation","distance","perspective","transformPerspective","opacity","originX","originY","originZ","numberValueTypes","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius","width","maxWidth","height","maxHeight","top","right","bottom","left","inset","insetBlock","insetBlockStart","insetBlockEnd","insetInline","insetInlineStart","insetInlineEnd","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","paddingBlock","paddingBlockStart","paddingBlockEnd","paddingInline","paddingInlineStart","paddingInlineEnd","margin","marginTop","marginRight","marginBottom","marginLeft","marginBlock","marginBlockStart","marginBlockEnd","marginInline","marginInlineStart","marginInlineEnd","fontSize","backgroundPositionX","backgroundPositionY","zIndex","fillOpacity","strokeOpacity","numOctaves","getValueAsType","activeScope","MotionValueState","Map","pending","numPending","flush","computed","onRemove","entry","cancelOnChange","release","transformKeys","transformValues","createEffect","addValue","stateCache","subject","translateAlias","openers","transformFunction","valueAsType","isDefaultTransform","originProps","styleValue","addStyleValue","keys","sort","check","style","buildTransform","transformOrigin","setProperty","readStyleValue","computedStyle","getPropertyValue","trim","styleSubjectEffect","camelToDash","str","replace","toLowerCase","cssStyleProperties","addAttrValue","isProp","descriptor","getOwnPropertyDescriptor","getPrototypeOf","canSetAsProperty","removeAttribute","setAttribute","String","svgSubjectEffect","offset","pathLength","pathSpacing","Number","addSVGPathValue","convertAttrKey","d","getAttribute","_","firstChar","visualElementStore","mixNumber","from","to","isDragging","applyConstraints","point","elastic","elementDragControls","toPixels","size","latest","limitsOf","option","resolveElastic","side","writesXY","pan","clampTo","unconstrain","resistance","addPinchListeners","getValues","getEnabledOptions","onPinchStart","pointers","l","source","lastEvent","unlock","lastX","lastY","hasMoved","wheelTime","handlers","rawScale","rawRotate","stopSnap","getOptions","info","measure","box","getBoundingClientRect","r","offsetWidth","offsetHeight","pivot","focal","u","dragControls","snap","scaleOption","rotateOption","snapToOrigin","transition","s0","r0","x0","y0","s1","r1","moves","p0","vx","vy","startTime","tick","p","fx","fy","at","apply","drag","theta","constrain","raw","limits","dx","dy","panX","panY","history","panSession","originPoint","onPinch","end","begin","event","moved","readPointers","log","setPointer","pointerId","clientX","clientY","onPointerMove","onPointerUp","toggleWindowListeners","onPointerDown","pointerType","method","window","onGesture","rotation","preventDefault","listeners","pointerdown","wheel","ctrlKey","deltaY","deltaMode","gesturestart","gesturechange","gestureend","addEventListener","passive","removeEventListener","valueKeys","getElementValues","visualElement","effect","getValue","pinch","elementOrSelector","startOrOptions","scope","bind","cleanups","selectorCache","EventTarget","document","elements","querySelectorAll","Array","filter","resolveElements","track","touchAction","cleanup"],"mappings":"AAAA,MAAMA,EAAQ,CAACC,EAAKC,EAAKC,IACjBA,EAAID,EACGA,EACPC,EAAIF,EACGA,EACJE,ECLLC,EAAqB,CAAA,ECArBC,EAAYC,GAA2B,iBAAVA,GAAgC,OAAVA,ECEzD,MAAMC,EACF,WAAAC,GACIC,KAAKC,cAAgB,EACzB,CACA,GAAAC,CAAIC,GCNR,IAAuBC,EAAKC,EDQpB,OCReD,EDODJ,KAAKC,cCPCI,EDOcF,GCNZ,IAAtBC,EAAIE,QAAQD,IACZD,EAAIG,KAAKF,GDMF,IAAML,KAAKQ,OAAOL,EAC7B,CACA,MAAAK,CAAOL,ICNX,SAAoBC,EAAKC,GACrB,MAAMI,EAAQL,EAAIE,QAAQD,GACtBI,GAAQ,GACRL,EAAIM,OAAOD,EAAO,EAC1B,CDGQE,CAAWX,KAAKC,cAAeE,EACnC,CACA,MAAAS,CAAOC,EAAGC,EAAGC,GACT,MAAMC,EAAmBhB,KAAKC,cAAcgB,OAC5C,GAAKD,EAEL,GAAyB,IAArBA,EAIAhB,KAAKC,cAAc,GAAGY,EAAGC,EAAGC,QAG5B,IAAK,IAAIG,EAAI,EAAGA,EAAIF,EAAkBE,IAAK,CAKvC,MAAMf,EAAUH,KAAKC,cAAciB,GACnCf,GAAWA,EAAQU,EAAGC,EAAGC,EAC7B,CAER,CACA,OAAAI,GACI,OAAOnB,KAAKC,cAAcgB,MAC9B,CACA,KAAAG,GACI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