<commit_before>defmodule PanWeb.Live.Episode.Header do
  use Surface.LiveComponent
  alias PanWeb.{User, Episode}
  alias PanWeb.Surface.{PodcastButton, PersonaButton, EpisodeButton, Icon, LikeButton, Pill}
  alias PanWeb.Live.Episode.ClaimButton

  prop(current_user_id, :integer, required: true)
  prop(episode, :map, required: true)
  data(current_user, :map)

  def update(%{current_user_id: current_user_id} = assigns, socket) do
    socket =
      if current_user_id do
        assign(socket, assigns)
        |> assign(current_user: User.get_by_id_with_personas(current_user_id))
      else
        assign(socket, assigns)
      end

    {:ok, socket}
  end

  def update(assigns, socket), do: {:ok, assign(socket, assigns)}

  def render(assigns) do
    ~F"""
    <div>
      <h1 class="leading-10">
        <PodcastButton for={@episode.podcast} large />
        &nbsp; / &nbsp;
        <EpisodeButton for={@episode} large class="my-2" />
      </h1>

      <div class="flex flex-col md:flex-row my-4 space-y-4 md:space-y-0 md:space-x-4 md:divide-x md:divide-dotted md:divide-gray">
        {#if (@episode.description && @episode.description != @episode.shownotes) ||
              (@episode.summary && @episode.summary != @episode.description)}
          <div class="flex-1">
            {#if @episode.description && @episode.description != @episode.shownotes}
              <h2 class="text-2xl">Description</h2>
              <p>{@episode.description |> HtmlSanitizeEx.strip_tags}</p>
            {/if}

            {#if @episode.summary && @episode.summary != @episode.description}
              <h2 class="text-2xl">Summary</h2>
              <p>{raw(@episode.summary)}</p>
            {/if}
          </div>
        {/if}

        <dl class="flex-1 grid grid-cols-4 gap-x-4 gap-y-2">
          <dt class="justify-self-end font-medium">Subtitle</dt>
          <dd class="col-span-3">{@episode.subtitle}</dd>
          {#if @episode.payment_link_url}
            <dt class="justify-self-end font-medium">Support</dt>
            <dd class="col-span-3"><a href={@episode.payment_link_url}>{@episode.payment_link_title}</a></dd>
          {/if}
          <dt class="justify-self-end font-medium">Duration</dt>
          <dd class="col-span-3">{@episode.duration}</dd>
          {#if @episode.publishing_date}
            <dt class="text-right font-medium">Publishing date</dt>
            <dd class="col-span-3">{Calendar.strftime(@episode.publishing_date, "%x %H:%M")}</dd>
          {/if}
          {#if @episode.link}
            <dt class="justify-self-end font-medium">Link</dt>
            <dd class="col-span-3">
              <a class="text-link hover:text-link-dark"
                 href={@episode.link}>{@episode.link}</a>
            </dd>
          {/if}
          {#if @episode.deep_link}
            <dt class="justify-self-end font-medium">Deep link</dt><commit_msg>podcast/show :grid should stay on top and not be spread out, fixes #98<commit_after>defmodule PanWeb.Live.Episode.Header do
  use Surface.LiveComponent
  alias PanWeb.{User, Episode}
  alias PanWeb.Surface.{PodcastButton, PersonaButton, EpisodeButton, Icon, LikeButton, Pill}
  alias PanWeb.Live.Episode.ClaimButton

  prop(current_user_id, :integer, required: true)
  prop(episode, :map, required: true)
  data(current_user, :map)

  def update(%{current_user_id: current_user_id} = assigns, socket) do
    socket =
      if current_user_id do
        assign(socket, assigns)
        |> assign(current_user: User.get_by_id_with_personas(current_user_id))
      else
        assign(socket, assigns)
      end

    {:ok, socket}
  end

  def update(assigns, socket), do: {:ok, assign(socket, assigns)}

  def render(assigns) do
    ~F"""
    <div>
      <h1 class="leading-10">
        <PodcastButton for={@episode.podcast} large />
        &nbsp; / &nbsp;
        <EpisodeButton for={@episode} large class="my-2" />
      </h1>

      <div class="flex flex-col md:flex-row my-4 space-y-4 md:space-y-0 md:space-x-4 md:divide-x md:divide-dotted md:divide-gray">
        {#if (@episode.description && @episode.description != @episode.shownotes) ||
              (@episode.summary && @episode.summary != @episode.description)}
          <div class="flex-1">
            {#if @episode.description && @episode.description != @episode.shownotes}
              <h2 class="text-2xl">Description</h2>
              <p>{@episode.description |> HtmlSanitizeEx.strip_tags}</p>
            {/if}

            {#if @episode.summary && @episode.summary != @episode.description}
              <h2 class="text-2xl">Summary</h2>
              <p>{raw(@episode.summary)}</p>
            {/if}
          </div>
        {/if}

        <dl class="flex-1 grid content-start grid-cols-4 gap-x-4 gap-y-2">
          <dt class="justify-self-end font-medium">Subtitle</dt>
          <dd class="col-span-3">{@episode.subtitle}</dd>
          {#if @episode.payment_link_url}
            <dt class="justify-self-end font-medium">Support</dt>
            <dd class="col-span-3"><a href={@episode.payment_link_url}>{@episode.payment_link_title}</a></dd>
          {/if}
          <dt class="justify-self-end font-medium">Duration</dt>
          <dd class="col-span-3">{@episode.duration}</dd>
          {#if @episode.publishing_date}
            <dt class="text-right font-medium">Publishing date</dt>
            <dd class="col-span-3">{Calendar.strftime(@episode.publishing_date, "%x %H:%M")}</dd>
          {/if}
          {#if @episode.link}
            <dt class="justify-self-end font-medium">Link</dt>
            <dd class="col-span-3">
              <a class="text-link hover:text-link-dark"
                 href={@episode.link}>{@episode.link}</a>
            </dd>
          {/if}
          {#if @episode.deep_link}
            <dt class="justify-self-end font-medium">Deep link</dt>
{'fraction_non_alphanumeric': 0.16111395865368186, 'fraction_numerical': 0.008884332820775671, 'mean_word_length': 2.4886769964243145, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 93, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2344714', 'n_tokens_mistral': 2051, 'n_tokens_neox': 1952, 'n_words': 344}