import _extends from"@babel/runtime/helpers/extends";import _classCallCheck from"@babel/runtime/helpers/classCallCheck";import _createClass from"@babel/runtime/helpers/createClass";import _possibleConstructorReturn from"@babel/runtime/helpers/possibleConstructorReturn";import _getPrototypeOf from"@babel/runtime/helpers/getPrototypeOf";import _inherits from"@babel/runtime/helpers/inherits";var _jsxFileName="/home/circleci/repo/src/index.tsx";import React from'react';import{DeviceEventEmitter,findNodeHandle,NativeModules,Platform,requireNativeComponent}from'react-native';var RNPdfScanner=requireNativeComponent('RNPdfScanner');var ScannerManager=NativeModules.RNPdfScannerManager;var PdfScanner=function(_React$Component){_inherits(PdfScanner,_React$Component);function PdfScanner(){var _getPrototypeOf2;var _this;_classCallCheck(this,PdfScanner);for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_possibleConstructorReturn(this,(_getPrototypeOf2=_getPrototypeOf(PdfScanner)).call.apply(_getPrototypeOf2,[this].concat(args)));_this._scannerRef=null;_this._scannerHandle=null;_this._setReference=function(ref){if(ref){_this._scannerRef=ref;_this._scannerHandle=findNodeHandle(ref);}else{_this._scannerRef=null;_this._scannerHandle=null;}};return _this;}_createClass(PdfScanner,[{key:"sendOnDocumentScannedEvent",value:function sendOnDocumentScannedEvent(event){if(!this.props.onDocumentScanned)return null;return this.props.onDocumentScanned(event.nativeEvent);}},{key:"sendOnRectangleDetectEvent",value:function sendOnRectangleDetectEvent(event){if(!this.props.onRectangleDetect)return null;return this.props.onRectangleDetect(event.nativeEvent);}},{key:"getImageQuality",value:function getImageQuality(){if(!this.props.quality)return 0.8;if(this.props.quality>1)return 1;if(this.props.quality<0.1)return 0.1;return this.props.quality;}},{key:"componentDidMount",value:function componentDidMount(){if(Platform.OS==='android'){var _this$props=this.props,onDocumentScanned=_this$props.onDocumentScanned,onProcessing=_this$props.onProcessing;if(onDocumentScanned)DeviceEventEmitter.addListener('onDocumentScanned',onDocumentScanned);if(onProcessing)DeviceEventEmitter.addListener('onProcessingChange',onProcessing);}}},{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){if(Platform.OS==='android'){if(this.props.onDocumentScanned!==prevProps.onDocumentScanned){if(prevProps.onDocumentScanned)DeviceEventEmitter.removeListener('onDocumentScanned',prevProps.onDocumentScanned);if(this.props.onDocumentScanned)DeviceEventEmitter.addListener('onDocumentScanned',this.props.onDocumentScanned);}if(this.props.onProcessing!==prevProps.onProcessing){if(prevProps.onProcessing)DeviceEventEmitter.removeListener('onProcessingChange',prevProps.onProcessing);if(this.props.onProcessing)DeviceEventEmitter.addListener('onProcessingChange',this.props.onProcessing);}}}},{key:"componentWillUnmount",value:function componentWillUnmount(){if(Platform.OS==='android'){var _this$props2=this.props,onDocumentScanned=_this$props2.onDocumentScanned,onProcessing=_this$props2.onProcessing;if(onDocumentScanned)DeviceEventEmitter.removeListener('onDocumentScanned',onDocumentScanned);if(onProcessing)DeviceEventEmitter.removeListener('onProcessingChange',onProcessing);}}},{key:"capture",value:function capture(){if(this._scannerHandle){ScannerManager.capture(this._scannerHandle);}}},{key:"render",value:function render(){return React.createElement(RNPdfScanner,_extends({ref:this._setReference},this.props,{onDocumentScanned:this.sendOnDocumentScannedEvent.bind(this),onRectangleDetect:this.sendOnRectangleDetectEvent.bind(this),useFrontCam:this.props.useFrontCam||false,brightness:this.props.brightness||0,saturation:this.props.saturation||1,contrast:this.props.contrast||1,quality:this.getImageQuality(),detectionCountBeforeCapture:this.props.detectionCountBeforeCapture||5,durationBetweenCaptures:this.props.durationBetweenCaptures||0,detectionRefreshRateInMS:this.props.detectionRefreshRateInMS||50,__source:{fileName:_jsxFileName,lineNumber:132}}));}}]);return PdfScanner;}(React.Component);export default PdfScanner;
//# sourceMappingURL=index.js.map