import { useQuery as n } from "@tanstack/react-query";
import { GetExecutionStatusResponse as s, OneClickService as o } from "@defuse-protocol/one-click-sdk-typescript";
import { logger as i } from "../logger.js";
const c = 3e3, l = /* @__PURE__ */ new Set([
  s.status.SUCCESS,
  s.status.FAILED,
  s.status.REFUNDED
]), w = ({
  depositAddress: r,
  depositMemo: a,
  disabled: u
} = {}) => n({
  queryKey: ["oneClickExecutionStatus", r],
  queryFn: async () => {
    if (!r)
      throw new Error(
        "Deposit address is required to fetch execution status"
      );
    let t;
    try {
      t = await o.getExecutionStatus(
        r,
        a
      );
    } catch (e) {
      throw i.error("Error polling 1Click execution status", e), e;
    }
    return {
      ...t,
      swapDetails: {
        ...t.swapDetails,
        amount: t.swapDetails.amountIn,
        amountUsd: t.swapDetails.amountInUsd
      }
    };
  },
  enabled: !u && !!r,
  refetchInterval: (t) => {
    const e = t.state.data?.status;
    return e && l.has(e) ? !1 : c;
  },
  gcTime: 0
});
export {
  w as useOneClickExecutionStatus
};
//# sourceMappingURL=useOneClickExecutionStatus.js.map
