var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
    for (var name in all) __defProp(target, name, {
      get: all[name],
      enumerable: !0
    });
  },
  __copyProps = (to, from, except, desc) => {
    if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
      get: () => from[key],
      enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
    });
    return to;
  };
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
  value: !0
}), mod);
var ScrollTo_exports = {};
__export(ScrollTo_exports, {
  ScrollTo: () => ScrollTo,
  useScrollTo: () => useScrollTo,
  useScrollToSection: () => useScrollToSection
});
module.exports = __toCommonJS(ScrollTo_exports);
var import_icons_ui = require("@truststack/icons-ui"),
  import_react = require("react"),
  import_react_native = require("react-native-web"),
  import_tamagui = require("tamagui"),
  import_Chip = require("./Chip.cjs"),
  import_jsx_runtime = require("react/jsx-runtime");
function ScrollTo({
  listRef,
  offset
}) {
  const show = offset > 300;
  return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.AnimatePresence, {
    children: show && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.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__ */(0, import_jsx_runtime.jsxs)(import_Chip.Chip, {
        pointerEvents: "auto",
        variant: "filter",
        onPress: () => {
          listRef.current instanceof import_react_native.FlatList && listRef.current?.scrollToOffset({
            offset: 0,
            animated: !0
          }), listRef.current instanceof import_react_native.SectionList && listRef.current?.scrollToLocation({
            animated: !0,
            itemIndex: 0,
            sectionIndex: 0
          });
        },
        children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Chip.Chip.Icon, {
          Icon: import_icons_ui.ChevronUp
        }), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_Chip.Chip.Text, {
          children: "Scroll To Top"
        })]
      })
    })
  });
}
const useScrollTo = () => {
    const [offset, setOffset] = (0, import_react.useState)(0);
    return [(0, import_react.useRef)(null), offset, setOffset];
  },
  useScrollToSection = () => {
    const [offset, setOffset] = (0, import_react.useState)(0);
    return [(0, import_react.useRef)(null), offset, setOffset];
  };