/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@dudigital/react-native-zoomable-view@1.1.4/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),reactNative=require("react-native");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},extendStatics(e,t)};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function __extends(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}var __assign=function(){return __assign=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},__assign.apply(this,arguments)},initialState={lastZoomLevel:1,offsetX:0,offsetY:0,lastX:0,lastY:0,lastMovePinch:!1,originalWidth:null,originalHeight:null},ReactNativeZoomableView=function(e){function t(t){var o,n=this;return(n=e.call(this,t)||this).contextState={distanceLeft:0,distanceRight:0,distanceTop:0,distanceBottom:0},n.longPressTimeout=null,n.pinchZoomPosition=null,n._getBoxDimensions=function(e){var t=e.nativeEvent.layout;t.x,t.y;var o=t.height,i=t.width;n.setState({originalWidth:i,originalHeight:o})},n._handleStartShouldSetPanResponder=function(e,t){return n._doubleTapCheck(e,t),n.props.onStartShouldSetPanResponder&&n.props.onStartShouldSetPanResponder(e,t,n._getZoomableViewEventObject(),!1),n.props.captureEvent},n._handleMoveShouldSetPanResponder=function(e,t){var o=n.props.zoomEnabled&&(Math.abs(t.dx)>2||Math.abs(t.dy)>2||2===t.numberActiveTouches);return n.props.onMoveShouldSetPanResponder&&(o=n.props.onMoveShouldSetPanResponder(e,t,n._getZoomableViewEventObject(),o)),o},n._handlePanResponderGrant=function(e,t){if(n.isDistanceSet=!1,2===t.numberActiveTouches){var o=Math.abs(e.nativeEvent.touches[0].pageX-e.nativeEvent.touches[1].pageX),i=Math.abs(e.nativeEvent.touches[0].pageY-e.nativeEvent.touches[1].pageY),s=Math.sqrt(o*o+i*i);n.distance=s,n.isDistanceSet=!0}n.props.onLongPress&&(n.longPressTimeout=setTimeout((function(){n.props.onLongPress&&(n.props.onLongPress(e,t,n._getZoomableViewEventObject()),n.longPressTimeout=null)}),n.props.longPressDuration)),n.props.onPanResponderGrant&&n.props.onPanResponderGrant(e,t,n._getZoomableViewEventObject())},n._handlePanResponderEnd=function(e,t){n.setState({lastX:n.state.offsetX,lastY:n.state.offsetY,lastZoomLevel:n.state.zoomLevel}),n.longPressTimeout&&(clearTimeout(n.longPressTimeout),n.longPressTimeout=null),n.props.onPanResponderEnd&&n.props.onPanResponderEnd(e,t,n._getZoomableViewEventObject()),"pinch"===n.gestureType?(n.pinchZoomPosition=null,n.props.onZoomEnd&&n.props.onZoomEnd(e,t,n._getZoomableViewEventObject())):"shift"===n.gestureType&&n.props.onShiftingEnd&&n.props.onShiftingEnd(e,t,n._getZoomableViewEventObject()),n.gestureType=null},n._handlePanResponderMove=function(e,t){if(n.props.onPanResponderMove&&n.props.onPanResponderMove(e,t,n._getZoomableViewEventObject()))return!1;2===t.numberActiveTouches?(n.longPressTimeout&&(clearTimeout(n.longPressTimeout),n.longPressTimeout=null),n.isDistanceSet||n._handlePanResponderGrant(e,t),n.gestureType="pinch",n._handlePinching(e,t)):1===t.numberActiveTouches&&(n.longPressTimeout&&(Math.abs(t.dx)>5||Math.abs(t.dy)>5)&&(clearTimeout(n.longPressTimeout),n.longPressTimeout=null),"pinch"!==n.gestureType&&(n.gestureType="shift"),n._handleMovement(e,t))},n._handlePinching=function(e,t){var o=n.props,i=o.maxZoom,s=o.minZoom,a=o.zoomCenteringLevelDistance,r=o.pinchToZoomInSensitivity,l=o.pinchToZoomOutSensitivity,p=Math.abs(e.nativeEvent.touches[0].pageX-e.nativeEvent.touches[1].pageX),u=Math.abs(e.nativeEvent.touches[0].pageY-e.nativeEvent.touches[1].pageY),c=Math.sqrt(p*p+u*u);if(n.props.onZoomBefore&&n.props.onZoomBefore(e,t,n._getZoomableViewEventObject()))return!1;var f=c/n.distance,d=f<1?l:r,h=(f*n.state.lastZoomLevel+n.state.lastZoomLevel*d)/(d+1);if(null!==i&&h>i&&(h=i),h<s&&(h=s),null===n.pinchZoomPosition){var v=Math.min(e.nativeEvent.touches[0].pageX,e.nativeEvent.touches[1].pageX)+p/2,m=Math.min(e.nativeEvent.touches[0].pageY,e.nativeEvent.touches[1].pageY)+u/2;n.pinchZoomPosition=n._getOffsetAdjustedPosition(v,m)}var _=Math.abs(h-n.state.lastZoomLevel)/a,g=n.state.lastX+_*n.pinchZoomPosition.x,S=n.state.lastY+_*n.pinchZoomPosition.y,P=n._bindOffsetValuesToBorders({zoomLevel:h,lastMovePinch:!0,offsetX:g,offsetY:S},null);n.setState(P,(function(){n.props.onZoomAfter&&n.props.onZoomAfter(e,t,n._getZoomableViewEventObject())}))},n._handleMovement=function(e,t){var o=n.props.movementSensibility;if(!n.pinchZoomPosition){var i=n.state.lastX+t.dx/n.state.zoomLevel/o,s=n.state.lastY+t.dy/n.state.zoomLevel/o;n._setNewOffsetPosition(i,s)}},n._setNewOffsetPosition=function(e,t,o,i,s){void 0===o&&(o=!0),void 0===i&&(i=!1),void 0===s&&(s=null);var a=n.props,r=a.onShiftingBefore,l=a.onShiftingAfter;if(r&&r(null,null,n._getZoomableViewEventObject()))return!1;var p=n._bindOffsetValuesToBorders({lastMovePinch:!1,zoomLevel:n.state.zoomLevel,offsetX:e,offsetY:t},o);i&&(p.lastX=p.offsetX,p.lastY=p.offsetY),n.setState(p,(function(){if(s&&s(),l&&l(null,null,n._getZoomableViewEventObject()))return!1}))},n._doubleTapCheck=function(e,t){var o=(new Date).getTime();n.lastPressHolder&&o-n.lastPressHolder<n.props.doubleTapDelay?(delete n.lastPressHolder,n._handleDoubleTap(e,t)):n.lastPressHolder=o},n.gestureHandlers=reactNative.PanResponder.create({onStartShouldSetPanResponder:n._handleStartShouldSetPanResponder,onMoveShouldSetPanResponder:n._handleMoveShouldSetPanResponder,onPanResponderGrant:n._handlePanResponderGrant,onPanResponderMove:n._handlePanResponderMove,onPanResponderRelease:n._handlePanResponderEnd,onPanResponderTerminate:t.onPanResponderTerminate,onPanResponderTerminationRequest:null!==(o=t.onPanResponderTerminationRequest)&&void 0!==o?o:function(e){return!1},onShouldBlockNativeResponder:function(e){return!1}}),n.state=__assign(__assign({},initialState),{zoomLevel:t.initialZoom,lastZoomLevel:t.initialZoom||initialState.lastZoomLevel,offsetX:t.initialOffsetX,offsetY:t.initialOffsetY}),n.distance=150,n.isDistanceSet=!0,n.gestureType=null,n.contextState={distanceLeft:0,distanceRight:0,distanceTop:0,distanceBottom:0},n}return __extends(t,e),t.prototype.componentDidUpdate=function(e){var t=this.props,o=t.zoomEnabled,n=t.initialZoom;e.zoomEnabled&&!o&&this.setState(__assign({zoomLevel:n},initialState))},t.prototype._getZoomableViewEventObject=function(e){return void 0===e&&(e={}),__assign(__assign(__assign({},this.state),this.contextState),e)},t.prototype._getBoundOffsetValue=function(e,t,o,n,i){var s=o*(1-o/n)*(.5+.5/i),a=-1*(o+s-o),r=t-s,l=-1*(t+s);return this._setContextStateDistances(e,r,l),o>n?o/2-n/2/i:r>0?s:l>0?a:t},t.prototype._setContextStateDistances=function(e,t,o){if("x"===e)return this.contextState.distanceLeft=t,void(this.contextState.distanceRight=o);this.contextState.distanceTop=t,this.contextState.distanceBottom=o},t.prototype._bindOffsetValuesToBorders=function(e,t){if(void 0===t&&(t=null),!1===t||null===t&&!this.props.bindToBorders)return e;var o=this.state,n=o.originalWidth,i=o.originalHeight,s=n*e.zoomLevel,a=i*e.zoomLevel,r=this._getBoundOffsetValue("x",e.offsetX,n,s,e.zoomLevel);e.offsetX=r;var l=this._getBoundOffsetValue("y",e.offsetY,i,a,e.zoomLevel);return e.offsetY=l,e},t.prototype._handleDoubleTap=function(e,t){var o=this,n=this.props,i=n.onDoubleTapBefore,s=n.onDoubleTapAfter,a=n.doubleTapZoomToCenter;if(!(t.numberActiveTouches>1)&&this.props.zoomEnabled){i&&i(e,t,this._getZoomableViewEventObject());var r=this._getNextZoomStep(),l={x:e.nativeEvent.locationX,y:e.nativeEvent.locationY};a&&(l.x=0,l.y=0),this._zoomToLocation(l.x,l.y,r,!0,(function(){s&&s(e,t,o._getZoomableViewEventObject({zoomLevel:r}))}))}},t.prototype._getNextZoomStep=function(){var e=this.props,t=e.zoomStep,o=e.maxZoom,n=e.initialZoom,i=this.state.zoomLevel;if(i===o)return n;var s=i+i*t;return null!==o&&s>o?o:s},t.prototype._getOffsetAdjustedPosition=function(e,t){var o=this.state,n=o.originalWidth,i=o.originalHeight;return 0===e&&0===t?{x:0,y:0}:{x:n/2-e,y:i/2-t}},t.prototype._zoomToLocation=function(e,t,o,n,i){var s=this;void 0===n&&(n=!0),void 0===i&&(i=null);var a=this._getOffsetAdjustedPosition(e,t);this.props.onZoomBefore&&this.props.onZoomBefore(null,null,this._getZoomableViewEventObject());var r=this._bindOffsetValuesToBorders({zoomLevel:o,offsetX:a.x,offsetY:a.y,lastZoomLevel:o,lastX:a.x,lastY:a.y},n);this.setState(r,(function(){i&&i(),s.props.onZoomAfter&&s.props.onZoomAfter(null,null,s._getZoomableViewEventObject())}))},t.prototype.zoomTo=function(e,t){var o=this;return void 0===t&&(t=!0),new Promise((function(n){e>=o.props.maxZoom||e<=o.props.minZoom?n(!1):o._zoomToLocation(0,0,e,t,(function(){n(!0)}))}))},t.prototype.zoomBy=function(e,t){return void 0===e&&(e=null),void 0===t&&(t=!0),e||(e=this.props.zoomStep),this.zoomTo(this.state.zoomLevel+e,t)},t.prototype.moveTo=function(e,t,o){var n=this;void 0===o&&(o=!0);var i=this.state,s=i.zoomLevel,a=i.originalWidth,r=i.originalHeight,l=(e-a/2)/s,p=(t-r/2)/s;return new Promise((function(e){n._setNewOffsetPosition(-l,-p,o,!0,(function(){e()}))}))},t.prototype.moveBy=function(e,t,o){var n=this;void 0===o&&(o=!0);var i=this.state,s=i.zoomLevel,a=i.lastX,r=i.lastY,l=a-e/s,p=r-t/s;return new Promise((function(e){n._setNewOffsetPosition(l,p,o,!0,(function(){e()}))}))},t.prototype.render=function(){return React__default.default.createElement(reactNative.View,__assign({style:styles.container},this.gestureHandlers.panHandlers,{onLayout:this._getBoxDimensions}),React__default.default.createElement(reactNative.View,{style:[styles.wrapper,this.props.style,{transform:[{scale:this.state.zoomLevel},{scale:this.state.zoomLevel},{translateX:this.state.offsetX},{translateY:this.state.offsetY}]}]},this.props.children))},t.defaultProps={zoomEnabled:!0,initialZoom:1,initialOffsetX:0,initialOffsetY:0,maxZoom:1.5,minZoom:.5,pinchToZoomInSensitivity:3,pinchToZoomOutSensitivity:1,zoomCenteringLevelDistance:.5,movementSensibility:1.9,doubleTapDelay:300,bindToBorders:!0,zoomStep:.5,onLongPress:null,longPressDuration:700,captureEvent:!1},t}(React.Component),styles=reactNative.StyleSheet.create({wrapper:{flex:1,width:"100%",justifyContent:"center"},container:{flex:1,justifyContent:"center",alignItems:"center",position:"relative"}}),swipeDirections={SWIPE_UP:"SWIPE_UP",SWIPE_DOWN:"SWIPE_DOWN",SWIPE_LEFT:"SWIPE_LEFT",SWIPE_RIGHT:"SWIPE_RIGHT"},ReactNativeZoomableViewWithGestures=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._onShiftingEnd=function(e,o,n){if(t.props.onShiftingEnd&&t.props.onShiftingEnd(e,o,n),t._couldCallSwipeEvent(n)){var i=t._getSwipeDirection(o);t._triggerSwipeHandlers(i,o)}},t}return __extends(t,e),t.prototype._couldCallSwipeEvent=function(e){var t=this.props,o=t.onSwipe,n=t.onSwipeUp,i=t.onSwipeDown,s=t.onSwipeLeft,a=t.onSwipeRight,r=t.swipeMaxZoom,l=t.swipeMinZoom;return!(r&&e.zoomLevel>r)&&(!(l&&e.zoomLevel<l)&&(o&&n&&i&&s&&a))},t.prototype._validateSwipe=function(e){var t=this.props,o=t.onSwipeUp,n=t.onSwipeDown,i=t.onSwipeLeft,s=t.onSwipeRight,a=this._getSwipeDirection(e),r=swipeDirections.SWIPE_LEFT,l=swipeDirections.SWIPE_RIGHT,p=swipeDirections.SWIPE_UP,u=swipeDirections.SWIPE_DOWN;return o&&a===p||n&&a===u||i&&a===r||s&&a===l},t.prototype._triggerSwipeHandlers=function(e,t){var o=this.props,n=o.onSwipe,i=o.onSwipeUp,s=o.onSwipeDown,a=o.onSwipeLeft,r=o.onSwipeRight,l=swipeDirections.SWIPE_LEFT,p=swipeDirections.SWIPE_RIGHT,u=swipeDirections.SWIPE_UP,c=swipeDirections.SWIPE_DOWN;switch(n&&n(e,t),e){case l:a&&a(t);break;case p:r&&r(t);break;case u:i&&i(t);break;case c:s&&s(t)}},t.prototype._getSwipeDirection=function(e){var t=this.props.swipeLengthThreshold,o=swipeDirections.SWIPE_LEFT,n=swipeDirections.SWIPE_RIGHT,i=swipeDirections.SWIPE_UP,s=swipeDirections.SWIPE_DOWN,a=e.dx,r=e.dy;if(t){if(this._isValidHorizontalSwipe(e)){if(Math.abs(a)>t)return a>0?n:o}else if(this._isValidVerticalSwipe(e)&&Math.abs(r)>t)return r>0?s:i;return null}},t.prototype._isValidHorizontalSwipe=function(e){var t=e.vx,o=e.dy,n=this.props,i=n.swipeVelocityThreshold,s=n.swipeDirectionalThreshold;return this._isValidSwipe(t,i,o,s)},t.prototype._isValidVerticalSwipe=function(e){var t=e.vy,o=e.dx,n=this.props,i=n.swipeVelocityThreshold,s=n.swipeDirectionalThreshold;return this._isValidSwipe(t,i,o,s)},t.prototype._isValidSwipe=function(e,t,o,n){return Math.abs(e)>t&&Math.abs(o)<n},t.prototype.render=function(){return React__default.default.createElement(ReactNativeZoomableView,__assign({},this.props,{onShiftingEnd:this._onShiftingEnd}))},t}(React__default.default.Component);exports.ReactNativeZoomableView=ReactNativeZoomableView,exports.ReactNativeZoomableViewWithGestures=ReactNativeZoomableViewWithGestures;
//# sourceMappingURL=/sm/f4b8fe04e30e3aea8d02fdefe7e45c61ff220a43c0325add6f406b3c26d3cb8e.map