"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../../../../../../motion-dom/dist/es/utils/mix/number.mjs.js"),i=require("../../../../../../motion-dom/dist/es/projection/geometry/delta-calc.mjs.js"),e=require("../../../../../../motion-utils/dist/es/progress.mjs.js"),n=require("../../../../../../motion-utils/dist/es/clamp.mjs.js");function r(t,i,e){return{min:void 0!==i?t.min+i:void 0,max:void 0!==e?t.max+e-(t.max-t.min):void 0}}function o(t,i){let e=i.min-t.min,n=i.max-t.max;return i.max-i.min<t.max-t.min&&([e,n]=[n,e]),{min:e,max:n}}const s=.35;function m(t,i,e){return{min:a(t,i),max:a(t,e)}}function a(t,i){return"number"==typeof t?t:t[i]||0}exports.applyConstraints=function(i,e,n){let{min:r,max:o}=e;return void 0!==r&&i<r?i=n?t.mixNumber(r,i,n.min):Math.max(i,r):void 0!==o&&i>o&&(i=n?t.mixNumber(o,i,n.max):Math.min(i,o)),i},exports.calcOrigin=function(t,r){let o=.5;const s=i.calcLength(t),m=i.calcLength(r);return m>s?o=e.progress(r.min,r.max-s,t.min):s>m&&(o=e.progress(t.min,t.max-m,r.min)),n.clamp(0,1,o)},exports.calcRelativeAxisConstraints=r,exports.calcRelativeConstraints=function(t,i){let{top:e,left:n,bottom:o,right:s}=i;return{x:r(t.x,n,s),y:r(t.y,e,o)}},exports.calcViewportAxisConstraints=o,exports.calcViewportConstraints=function(t,i){return{x:o(t.x,i.x),y:o(t.y,i.y)}},exports.defaultElastic=s,exports.rebaseAxisConstraints=function(t,i){const e={};return void 0!==i.min&&(e.min=i.min-t.min),void 0!==i.max&&(e.max=i.max-t.min),e},exports.resolveAxisElastic=m,exports.resolveDragElastic=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s;return!1===t?t=0:!0===t&&(t=s),{x:m(t,"left","right"),y:m(t,"top","bottom")}},exports.resolvePointElastic=a;
//# sourceMappingURL=constraints.mjs.js.map
