import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { ChevronUp } from "@truststack/icons-ui";
import { useRef, useState } from "react";
import { FlatList, SectionList } from "react-native";
import { AnimatePresence, View } from "tamagui";
import { Chip } from "./Chip.native.js";
function ScrollTo(param) {
  var {
      listRef,
      offset
    } = param,
    show = offset > 300;
  return /* @__PURE__ */_jsx(AnimatePresence, {
    children: show && /* @__PURE__ */_jsx(View, {
      position: "absolute",
      bottom: 10,
      zIndex: 999,
      animation: "bouncy",
      left: 0,
      right: 0,
      enterStyle: {
        opacity: 0,
        y: -10,
        scale: 0.9
      },
      exitStyle: {
        opacity: 0,
        y: 10,
        scale: 0.9
      },
      display: "flex",
      flexDirection: "row",
      justifyContent: "center",
      pointerEvents: "none",
      children: /* @__PURE__ */_jsxs(Chip, {
        pointerEvents: "auto",
        variant: "filter",
        onPress: function () {
          var _listRef_current, _listRef_current1;
          listRef.current instanceof FlatList && ((_listRef_current = listRef.current) === null || _listRef_current === void 0 || _listRef_current.scrollToOffset({
            offset: 0,
            animated: !0
          })), listRef.current instanceof SectionList && ((_listRef_current1 = listRef.current) === null || _listRef_current1 === void 0 || _listRef_current1.scrollToLocation({
            animated: !0,
            itemIndex: 0,
            sectionIndex: 0
          }));
        },
        children: [/* @__PURE__ */_jsx(Chip.Icon, {
          Icon: ChevronUp
        }), /* @__PURE__ */_jsx(Chip.Text, {
          children: "Scroll To Top"
        })]
      })
    })
  });
}
var useScrollTo = function () {
    var [offset, setOffset] = useState(0),
      listRef = useRef(null);
    return [listRef, offset, setOffset];
  },
  useScrollToSection = function () {
    var [offset, setOffset] = useState(0),
      listRef = useRef(null);
    return [listRef, offset, setOffset];
  };
export { ScrollTo, useScrollTo, useScrollToSection };
//# sourceMappingURL=ScrollTo.native.js.map
