import {
  returnsQueryKeys
} from "./chunk-BMC2HG53.js";
import {
  ordersQueryKeys
} from "./chunk-R74OHYTB.js";
import {
  queryClient
} from "./chunk-RHKRREUU.js";
import {
  queryKeysFactory
} from "./chunk-ZA2KFUFR.js";
import {
  sdk
} from "./chunk-RIN4CBRB.js";

// src/hooks/api/claims.tsx
import {
  useMutation,
  useQuery
} from "@tanstack/react-query";
var CLAIMS_QUERY_KEY = "claims";
var claimsQueryKeys = queryKeysFactory(CLAIMS_QUERY_KEY);
var useClaim = (id, query, options) => {
  const { data, ...rest } = useQuery({
    queryFn: async () => sdk.admin.claims.$id.query({ $id: id, ...query }),
    queryKey: claimsQueryKeys.detail(id, query),
    ...options
  });
  return { ...data, ...rest };
};
var useClaims = (query, options) => {
  const { data, ...rest } = useQuery({
    queryFn: async () => sdk.admin.claims.query({ ...query }),
    queryKey: claimsQueryKeys.list(query),
    ...options
  });
  return { ...data, ...rest };
};
var useCreateClaim = (orderId, options) => {
  return useMutation({
    mutationFn: (payload) => sdk.admin.claims.mutate(payload),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      queryClient.invalidateQueries({
        queryKey: claimsQueryKeys.lists()
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useCancelClaim = (id, orderId, options) => {
  return useMutation({
    mutationFn: () => sdk.admin.claims.$id.cancel.mutate({ $id: id }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      queryClient.invalidateQueries({
        queryKey: claimsQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: claimsQueryKeys.lists()
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useAddClaimInboundItems = (id, orderId, options) => {
  return useMutation({
    mutationFn: (payload) => sdk.admin.claims.$id.inbound.items.mutate({ $id: id, ...payload }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useUpdateClaimInboundItem = (id, orderId, options) => {
  return useMutation({
    mutationFn: ({
      actionId,
      ...payload
    }) => {
      return sdk.admin.claims.$id.inbound.items.$actionId.mutate({
        $id: id,
        $actionId: actionId,
        ...payload
      });
    },
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useRemoveClaimInboundItem = (id, orderId, options) => {
  return useMutation({
    mutationFn: (actionId) => sdk.admin.claims.$id.inbound.items.$actionId.delete({
      $id: id,
      $actionId: actionId
    }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      queryClient.invalidateQueries({
        queryKey: returnsQueryKeys.details()
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useAddClaimInboundShipping = (id, orderId, options) => {
  return useMutation({
    mutationFn: (payload) => sdk.admin.claims.$id.inbound.shippingMethod.mutate({
      $id: id,
      ...payload
    }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useUpdateClaimInboundShipping = (id, orderId, options) => {
  return useMutation({
    mutationFn: ({
      actionId,
      ...payload
    }) => sdk.admin.claims.$id.inbound.shippingMethod.$actionId.mutate({
      $id: id,
      $actionId: actionId,
      ...payload
    }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useDeleteClaimInboundShipping = (id, orderId, options) => {
  return useMutation({
    mutationFn: (actionId) => sdk.admin.claims.$id.inbound.shippingMethod.$actionId.delete({
      $id: id,
      $actionId: actionId
    }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useAddClaimOutboundItems = (id, orderId, options) => {
  return useMutation({
    mutationFn: (payload) => sdk.admin.claims.$id.outbound.items.mutate({ $id: id, ...payload }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useUpdateClaimOutboundItems = (id, orderId, options) => {
  return useMutation({
    mutationFn: ({
      actionId,
      ...payload
    }) => {
      return sdk.admin.claims.$id.outbound.items.$actionId.mutate({
        $id: id,
        $actionId: actionId,
        ...payload
      });
    },
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useRemoveClaimOutboundItem = (id, orderId, options) => {
  return useMutation({
    mutationFn: (actionId) => sdk.admin.claims.$id.outbound.items.$actionId.delete({
      $id: id,
      $actionId: actionId
    }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useAddClaimOutboundShipping = (id, orderId, options) => {
  return useMutation({
    mutationFn: (payload) => sdk.admin.claims.$id.outbound.shippingMethod.mutate({
      $id: id,
      ...payload
    }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useUpdateClaimOutboundShipping = (id, orderId, options) => {
  return useMutation({
    mutationFn: ({
      actionId,
      ...payload
    }) => sdk.admin.claims.$id.outbound.shippingMethod.$actionId.mutate({
      $id: id,
      $actionId: actionId,
      ...payload
    }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useDeleteClaimOutboundShipping = (id, orderId, options) => {
  return useMutation({
    mutationFn: (actionId) => sdk.admin.claims.$id.outbound.shippingMethod.$actionId.delete({
      $id: id,
      $actionId: actionId
    }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useClaimConfirmRequest = (id, orderId, options) => {
  return useMutation({
    mutationFn: (payload) => sdk.admin.claims.$id.request.mutate({ $id: id, ...payload }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: returnsQueryKeys.all
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      queryClient.invalidateQueries({
        queryKey: claimsQueryKeys.lists()
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useCancelClaimRequest = (id, orderId, options) => {
  return useMutation({
    mutationFn: () => sdk.admin.claims.$id.request.delete({ $id: id }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      queryClient.invalidateQueries({
        queryKey: claimsQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: claimsQueryKeys.lists()
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};

export {
  useClaim,
  useClaims,
  useCreateClaim,
  useCancelClaim,
  useAddClaimInboundItems,
  useUpdateClaimInboundItem,
  useRemoveClaimInboundItem,
  useAddClaimInboundShipping,
  useUpdateClaimInboundShipping,
  useDeleteClaimInboundShipping,
  useAddClaimOutboundItems,
  useUpdateClaimOutboundItems,
  useRemoveClaimOutboundItem,
  useAddClaimOutboundShipping,
  useUpdateClaimOutboundShipping,
  useDeleteClaimOutboundShipping,
  useClaimConfirmRequest,
  useCancelClaimRequest
};
