import { ChevronUp } from "@truststack/icons-ui";
import { useRef, useState } from "react";
import { FlatList, SectionList } from "react-native-web";
import { AnimatePresence, View } from "tamagui";
import { Chip } from "./Chip";
import { jsx, jsxs } from "react/jsx-runtime";
function ScrollTo({ listRef, offset }) {
  const 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: () => {
            listRef.current instanceof FlatList && listRef.current?.scrollToOffset({
              offset: 0,
              animated: !0
            }), listRef.current instanceof SectionList && listRef.current?.scrollToLocation({
              animated: !0,
              itemIndex: 0,
              sectionIndex: 0
            });
          },
          children: [
            /* @__PURE__ */ jsx(Chip.Icon, { Icon: ChevronUp }),
            /* @__PURE__ */ jsx(Chip.Text, { children: "Scroll To Top" })
          ]
        }
      )
    }
  ) });
}
const useScrollTo = () => {
  const [offset, setOffset] = useState(0);
  return [useRef(null), offset, setOffset];
}, useScrollToSection = () => {
  const [offset, setOffset] = useState(0);
  return [useRef(null), offset, setOffset];
};
export {
  ScrollTo,
  useScrollTo,
  useScrollToSection
};
//# sourceMappingURL=ScrollTo.js.map
