<script lang="ts">
  import { options } from '$lib/Notification/options';
  import { addNotification } from '$lib/Notification/store';
  import { env } from '$env/dynamic/public';
  import locale from '$stores/locale';
  import SettingHint from '../SettingHint.svelte';
  import tooltip from '$lib/Tooltip/tooltip';

  export let user: { accessToken: string; refreshToken: string };
</script>

<button
  onclick={() => {
    addNotification(
      options({
        heading: 'RSS feed URL copied to clipboard'
      })
    );
    navigator.clipboard.writeText(
      `https://${
        env.PUBLIC_ANILIST_REDIRECT_URI?.includes('192.168') ? '192.168.1.60:5173' : 'due.moe'
      }/feeds/activity-notifications?token=${user.accessToken}&refresh=${user.refreshToken}`
    );
  }}
>
  {$locale().settings.rssFeeds.buttons.copyToClipboard}
</button>
Your AniList notifications RSS feed URL
<SettingHint lineBreak>
  This <a
    href={'#'}
    onclick={(e) => e.preventDefault()}
    target="_blank"
    title={$locale().settings.rssFeeds.tooltips.rss}
    use:tooltip
    data-tooltip-above>RSS</a
  >
  feed will return the currently logged in AniList user's notification feed for external consumption.
  <br />
  Do not share this link with <b>anyone</b>!
</SettingHint>
