'use client'
"use strict";
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: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__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: true }), mod);

// hooks/index.ts
var hooks_exports = {};
__export(hooks_exports, {
  Code: () => import_connect2.Code,
  ConnectError: () => import_connect2.ConnectError,
  FrontierServiceQueries: () => import_frontier.FrontierServiceQueries,
  create: () => import_protobuf.create,
  createConnectQueryKey: () => import_connect_query.createConnectQueryKey,
  handleConnectError: () => handleConnectError,
  useInfiniteQuery: () => import_connect_query.useInfiniteQuery,
  useMutation: () => import_connect_query.useMutation,
  useQuery: () => import_connect_query.useQuery,
  useQueryClient: () => import_react_query.useQueryClient,
  useTransport: () => import_connect_query.useTransport
});
module.exports = __toCommonJS(hooks_exports);
var import_connect_query = require("@connectrpc/connect-query");
var import_connect2 = require("@connectrpc/connect");

// utils/error.ts
var import_connect = require("@connectrpc/connect");
var DEFAULT_ERROR_MESSAGE = "Something went wrong";
function handleConnectError(error, handlers) {
  var _a;
  const connectError = error instanceof import_connect.ConnectError ? error : new import_connect.ConnectError(
    typeof error === "string" ? error : error instanceof Error ? error.message : DEFAULT_ERROR_MESSAGE
  );
  const defaultHandler = (_a = handlers == null ? void 0 : handlers.Default) != null ? _a : (err) => console.error(err.message);
  switch (connectError.code) {
    case import_connect.Code.AlreadyExists:
      (handlers == null ? void 0 : handlers.AlreadyExists) ? handlers.AlreadyExists(connectError) : defaultHandler(connectError);
      break;
    case import_connect.Code.InvalidArgument:
      (handlers == null ? void 0 : handlers.InvalidArgument) ? handlers.InvalidArgument(connectError) : defaultHandler(connectError);
      break;
    case import_connect.Code.PermissionDenied:
      (handlers == null ? void 0 : handlers.PermissionDenied) ? handlers.PermissionDenied(connectError) : defaultHandler(connectError);
      break;
    case import_connect.Code.NotFound:
      (handlers == null ? void 0 : handlers.NotFound) ? handlers.NotFound(connectError) : defaultHandler(connectError);
      break;
    case import_connect.Code.FailedPrecondition:
      (handlers == null ? void 0 : handlers.FailedPrecondition) ? handlers.FailedPrecondition(connectError) : defaultHandler(connectError);
      break;
    default:
      defaultHandler(connectError);
  }
}

// hooks/index.ts
var import_frontier = require("@raystack/proton/frontier");
var import_react_query = require("@tanstack/react-query");
var import_protobuf = require("@bufbuild/protobuf");
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  Code,
  ConnectError,
  FrontierServiceQueries,
  create,
  createConnectQueryKey,
  handleConnectError,
  useInfiniteQuery,
  useMutation,
  useQuery,
  useQueryClient,
  useTransport
});
