<&| /Widgets/TitleBox, title => loc("Recurrence"), class=>'ticket-info-repeat-recurrence',
   ($can_modify ? (title_href => $modify_url) : ()),
   ($can_modify && $modify_behavior =~ /^(link|click)$/ ?  (titleright_raw => $m->scomp('/Elements/InlineEditLink')) : ()),
   class => (join " ", 'ticket-info-repeat-recurrence', ($modify_behavior eq 'always' ? 'editing' : ())),
   data => { 'inline-edit-behavior' => $modify_behavior },
&>
% unless ($modify_behavior eq 'always') {
  <div class="inline-edit-display" hx-trigger="ticketRecurrenceChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/EditRecurrence?id=<% $TicketObj->id %>&ReadOnly=1">
    <& /Ticket/Elements/EditRecurrence, Ticket => $TicketObj, ReadOnly => 1 &>
  </div>
% }

% if ($modify_behavior ne 'hide') {
  <form hx-post="<% RT->Config->Get('WebPath') %>/Helpers/TicketUpdateRecurrence" hx-swap="none" class="inline-edit">
    <input type="hidden" class="hidden" name="id" value="<% $TicketObj->id %>" />
    <div hx-trigger="ticketRecurrenceChanged from:body" hx-get="<% RT->Config->Get('WebPath') %>/Views/Ticket/EditRecurrence?id=<% $TicketObj->id %>&InputIdPrefix=inline-edit-" hx-swap="innerHTML">
      <& /Ticket/Elements/EditRecurrence, Ticket => $TicketObj, InputIdPrefix => 'inline-edit-' &>
    </div>
    <& /Elements/Submit, Name => "SubmitRecurrence", Label => loc('Save'), FullWidth => 1 &>
  </form>
% }
</&>
<%args>
$TicketObj
</%args>
<%init>
my $can_modify = $TicketObj->CurrentUserHasRight('ModifyTicket');
my $cf = RT::CustomField->new($session{CurrentUser});
$cf->Load('Original Ticket');

return unless $cf->id && ( $cf->IsAdded(0) || $cf->IsAdded($TicketObj->Queue) );

my %inline_edit_behavior;
if ( RT->Config->Get('InlineEditPanelBehavior') ) {
    %inline_edit_behavior = %{ RT->Config->Get('InlineEditPanelBehavior')->{'RT::Ticket'} || {} };
}

my $modify_url = RT->Config->Get('WebPath')."/Ticket/ModifyRecurrence.html?id=".$TicketObj->Id;
my $modify_behavior
    = RT->Config->Get( 'InlineEdit', $session{CurrentUser} )
    ? ( $inline_edit_behavior{Recurrence} || $inline_edit_behavior{_default} || 'link' )
    : 'hide';
</%init>
