// Generated by BUCKLESCRIPT VERSION 3.0.0, PLEASE EDIT WITH CARE
'use strict';

var Js = require("bs-platform/lib/js/js.js");
var List = require("bs-platform/lib/js/list.js");
var Curry = require("bs-platform/lib/js/curry.js");
var Js_primitive = require("bs-platform/lib/js/js_primitive.js");
var Js_undefined = require("bs-platform/lib/js/js_undefined.js");
var ReactNative = require("react-native");
var AnimatedRe$BsReactNative = require("./animatedRe.js");

function callback(x, $$event, state) {
  return Curry._2(x, $$event.nativeEvent, /* record */[
              /* stateID */state.stateID,
              /* moveX */state.moveX,
              /* moveY */state.moveY,
              /* x0 */state.x0,
              /* y0 */state.y0,
              /* dx */state.dx,
              /* dy */state.dy,
              /* vx */state.vx,
              /* vy */state.vy,
              /* numberActiveTouches */state.numberActiveTouches
            ]);
}

function animatedEvent(l) {
  var config = List.fold_left((function (x, y) {
          var variant = y[0];
          if (variant !== 89) {
            if (variant >= 19713) {
              var value = y[1];
              return Object.assign(x, {
                          dx: AnimatedRe$BsReactNative.ValueXY[/* getX */15](value),
                          dy: AnimatedRe$BsReactNative.ValueXY[/* getY */16](value)
                        });
            } else {
              return Object.assign(x, {
                          dx: y[1]
                        });
            }
          } else {
            return Object.assign(x, {
                        dy: y[1]
                      });
          }
        }), { }, l);
  return AnimatedRe$BsReactNative.$$event(/* array */[
              null,
              config
            ], {
              useNativeDriver: Js.false_
            });
}

function create(onMoveShouldSetPanResponder, onMoveShouldSetPanResponderCapture, onStartShouldSetPanResponder, onStartShouldSetPanResponderCapture, onPanResponderReject, onPanResponderGrant, onPanResponderStart, onPanResponderEnd, onPanResponderRelease, onPanResponderMove, onPanResponderTerminate, onPanResponderTerminationRequest, onShouldBlockNativeResponder, _) {
  var tmp;
  if (onPanResponderMove) {
    var x = onPanResponderMove[0];
    tmp = x[0] >= 117802505 ? animatedEvent(x[1]) : x[1];
  } else {
    tmp = undefined;
  }
  return ReactNative.PanResponder.create({
              onMoveShouldSetPanResponder: Js_undefined.fromOption(onMoveShouldSetPanResponder),
              onMoveShouldSetPanResponderCapture: Js_undefined.fromOption(onMoveShouldSetPanResponderCapture),
              onStartShouldSetPanResponder: Js_undefined.fromOption(onStartShouldSetPanResponder),
              onStartShouldSetPanResponderCapture: Js_undefined.fromOption(onStartShouldSetPanResponderCapture),
              onPanResponderReject: Js_undefined.fromOption(onPanResponderReject),
              onPanResponderGrant: Js_undefined.fromOption(onPanResponderGrant),
              onPanResponderStart: Js_undefined.fromOption(onPanResponderStart),
              onPanResponderEnd: Js_undefined.fromOption(onPanResponderEnd),
              onPanResponderRelease: Js_undefined.fromOption(onPanResponderRelease),
              onPanResponderMove: tmp,
              onPanResponderTerminate: Js_undefined.fromOption(onPanResponderTerminate),
              onPanResponderTerminationRequest: Js_undefined.fromOption(onPanResponderTerminationRequest),
              onShouldBlockNativeResponder: Js_undefined.fromOption(onShouldBlockNativeResponder)
            });
}

function panHandlers(t) {
  var jsHandlers = t.panHandlers;
  return /* record */[
          /* onMoveShouldSetResponder */Js_primitive.undefined_to_opt(jsHandlers.onMoveShouldSetResponder),
          /* onMoveShouldSetResponderCapture */Js_primitive.undefined_to_opt(jsHandlers.onMoveShouldSetResponderCapture),
          /* onResponderGrant */Js_primitive.undefined_to_opt(jsHandlers.onResponderGrant),
          /* onResponderMove */Js_primitive.undefined_to_opt(jsHandlers.onResponderMove),
          /* onResponderReject */Js_primitive.undefined_to_opt(jsHandlers.onResponderReject),
          /* onResponderRelease */Js_primitive.undefined_to_opt(jsHandlers.onResponderRelease),
          /* onResponderTerminate */Js_primitive.undefined_to_opt(jsHandlers.onResponderTerminate),
          /* onResponderTerminationRequest */Js_primitive.undefined_to_opt(jsHandlers.onResponderTerminationRequest),
          /* onStartShouldSetResponder */Js_primitive.undefined_to_opt(jsHandlers.onStartShouldSetResponder),
          /* onStartShouldSetResponderCapture */Js_primitive.undefined_to_opt(jsHandlers.onStartShouldSetResponderCapture)
        ];
}

exports.callback = callback;
exports.create = create;
exports.panHandlers = panHandlers;
/* react-native Not a pure module */
