import { useQuery } from '@tanstack/react-query';
import { ShareableLinkModel } from '../../social/types';
import { Client } from '@amityco/ts-sdk-react-native';
const REFERENCE_KEY = {
  [ShareableLinkModel.posts]: 'postId',
  [ShareableLinkModel.communities]: 'communityId',
  [ShareableLinkModel.users]: 'userId',
  [ShareableLinkModel.livestreams]: 'livestreamId'
};
export function useShareableLink() {
  const {
    data: config
  } = useQuery({
    queryKey: ['social-plus-uikit', 'shareable-link-config'],
    queryFn: () => Client === null || Client === void 0 ? void 0 : Client.getShareableLinkConfiguration(),
    enabled: !!Client,
    staleTime: Infinity
  });
  const getShareLink = (model, referenceId) => {
    var _config$patterns;
    if (!(config !== null && config !== void 0 && config.domain) || !(config !== null && config !== void 0 && (_config$patterns = config.patterns) !== null && _config$patterns !== void 0 && _config$patterns[model])) return null;
    return config.domain + config.patterns[model].replace(`{${REFERENCE_KEY[model]}}`, referenceId);
  };
  return {
    getShareLink
  };
}
//# sourceMappingURL=useShareableLink.js.map