import { jsx as o, jsxs as f } from "react/jsx-runtime";
import { classNames as T } from "./index-classNames.js";
import { Modal as Y } from "./index-Modal.js";
import { ModalBody as x } from "./index-ModalBody.js";
import { ModalHeader as b } from "./index-ModalHeader.js";
import { Text as h, TextTypes as p, FontWeights as v } from "./index-Text.js";
import { useState as M, useEffect as L } from "react";
import { a as S } from "./index-react-spring_web.modern.js";
import k from "./index-InfoIconModal.module.scss.js";
import { useSpring as C } from "./index-react-spring_core.modern.js";
const q = (y) => {
  const {
    message: r,
    title: s,
    onOutsideClick: l,
    onTouchEnd: a,
    replacements: w,
    backgroundColor: g,
    hasPuller: E = !0
  } = y, [i, c] = M(0), [{
    y: m
  }, d] = C(() => ({
    y: 0,
    config: {
      tension: 300,
      friction: 20
    }
  }));
  return L(() => {
    const e = (n) => {
      n.preventDefault(), n.touches[0].clientY - i > 0 && (document.body.style.overflow = "hidden");
    }, t = () => {
      document.body.style.overflow = "auto";
    }, u = (n) => {
      c(n.touches[0].clientY);
    };
    return window.addEventListener("touchmove", e, {
      passive: !1
    }), window.addEventListener("touchend", t), window.addEventListener("touchstart", u), () => {
      window.removeEventListener("touchmove", e), window.removeEventListener("touchend", t), window.removeEventListener("touchstart", u), document.body.style.overflow = "auto";
    };
  }, [i]), o(S.div, {
    onTouchStart: (e) => {
      c(e.touches[0].clientY);
    },
    onTouchMove: (e) => {
      const t = e.touches[0].clientY - i;
      t > 0 ? d({
        y: t
      }) : d({
        y: 0
      });
    },
    onTouchEnd: (e) => {
      c(0), m.get() > 80 ? a && a(e) : d({
        y: 0
      });
    },
    style: {
      transform: m.to((e) => `translate3d(0, ${e}px, 0)`)
    },
    children: f(Y, {
      backgroundColor: g,
      testId: "modal-mobile-test-id",
      modalPosition: "bottom",
      fullscreen: !1,
      width: "100vw",
      onOutsideClick: (e) => {
        l && l(e);
      },
      children: [f(b, {
        children: [E && o("div", {
          className: T(k.infoIconModalPuller)
        }), typeof s == "string" ? o(h, {
          fontWeight: v.bold,
          type: p.heading3,
          color: "--n700",
          textAlign: "center",
          children: s
        }) : s]
      }), o(x, {
        children: typeof r == "string" ? o(h, {
          replacements: w,
          fontWeight: v.regular,
          type: p.text,
          color: "--n700",
          textAlign: "center",
          children: r
        }) : r
      })]
    })
  });
};
export {
  q as InfoIconModal
};
