import apiClient from "./api";

/**
 * Table state API: get/put/delete per-user state by tableKey.
 * PUT accepts optional AbortSignal to cancel in-flight requests.
 */
export const tableStateService = {
  get(tableKey) {
    return apiClient.get(`/table-states/${encodeURIComponent(tableKey)}`);
  },

  put(tableKey, state, { signal } = {}) {
    return apiClient.put(
      `/table-states/${encodeURIComponent(tableKey)}`,
      { state },
      { signal },
    );
  },

  delete(tableKey) {
    return apiClient.delete(`/table-states/${encodeURIComponent(tableKey)}`);
  },
};
