"use strict";

import http from '../apiClient';
import { store } from '../../roomStore';
export async function getMyUser(options) {
  const token = options?.token || store.getState().chatSettingStore.user.token || '';
  const endpoint = options?.endpoint || '/users/my';
  const response = await http.get(endpoint, {
    headers: {
      Authorization: token
    }
  });
  if (response?.data?.user) {
    return response.data.user;
  }
  return response.data;
}
export function getDocuments(walletAddress) {
  const token = store.getState().chatSettingStore.user.token || '';
  return http.get(`/docs/${walletAddress}`, {
    headers: {
      Authorization: `Bearer ${token}`
    }
  });
}
export function getExportMyData() {
  const token = store.getState().chatSettingStore.user.token || '';
  return http.get('/users/exportData', {
    headers: {
      Authorization: token,
      responseType: 'arraybuffer'
    }
  });
}
export function deleteDocument(fileId) {
  const token = store.getState().chatSettingStore.user.token || '';
  return http.delete(`/files/${fileId}`, {
    headers: {
      Authorization: token
    }
  });
}
export function deleteMe() {
  return http.delete('/users');
}
export function updateMe(data) {
  return http.put('/users', data);
}
export async function updateProfile(fd) {
  const token = store.getState().chatSettingStore.user.token || '';
  try {
    const response = await http.put('/users', fd, {
      headers: {
        Authorization: token,
        'Content-Type': 'multipart/form-data'
      }
    });
    return response.data;
  } catch (error) {
    throw new Error('Error updating profile');
  }
}
//# sourceMappingURL=user.api.js.map