package SGN::View::Mason::Commands;
use strict;
use vars qw($m $c);
#line 156 "/home/production/cxgn/sgn/mason/page/info_section.mas"

  use CXGN::Page::Widgets qw/collapser/;
  use HTML::Entities;

  no warnings 'redefine';
  sub anchor_name {
      local $_ = lc shift;
      s/<[^>]+>//g; # strip html tags
      s/\s+/_/g;    # whitespace to underscores
      s/\W//g;      # remove any weird chars
      return $_;
  }
HTML::Mason::Component::FileBased->new(
'code' => sub {
use utf8; local $SGN::View::Mason::Commands::m = $HTML::Mason::Commands::m;
HTML::Mason::Exception::Params->throw
    ( error =>
      "Odd number of parameters passed to component expecting name/value pairs"
    ) if @_ % 2;
my ( $title, $subtitle, $empty_message, $collapsible, $collapsed, $id, $is_empty, $is_subsection, $align, $contents, $hide_if_empty );
{
    my %pos;
    for ( my $x = 0; $x < @_; $x += 2 )
    {
        $pos{ $_[$x] } = $x + 1;
    }

    foreach my $arg ( qw( title ) )
    {
        HTML::Mason::Exception::Params->throw
            ( error => "no value sent for required parameter '$arg'" )
                unless exists $pos{$arg};
    }
#line 89 "/home/production/cxgn/sgn/mason/page/info_section.mas"
    $title = $_[ $pos{'title'} ];
#line 90 "/home/production/cxgn/sgn/mason/page/info_section.mas"
     $subtitle = exists $pos{'subtitle'} ? $_[ $pos{'subtitle'} ] :  "";
#line 91 "/home/production/cxgn/sgn/mason/page/info_section.mas"
     $empty_message = exists $pos{'empty_message'} ? $_[ $pos{'empty_message'} ] :  "None";
#line 92 "/home/production/cxgn/sgn/mason/page/info_section.mas"
     $collapsible = exists $pos{'collapsible'} ? $_[ $pos{'collapsible'} ] :  0;
#line 93 "/home/production/cxgn/sgn/mason/page/info_section.mas"
     $collapsed = exists $pos{'collapsed'} ? $_[ $pos{'collapsed'} ] :  0;
#line 94 "/home/production/cxgn/sgn/mason/page/info_section.mas"
     $id = exists $pos{'id'} ? $_[ $pos{'id'} ] :  "";
#line 95 "/home/production/cxgn/sgn/mason/page/info_section.mas"
     $is_empty = exists $pos{'is_empty'} ? $_[ $pos{'is_empty'} ] :  0;
#line 96 "/home/production/cxgn/sgn/mason/page/info_section.mas"
     $is_subsection = exists $pos{'is_subsection'} ? $_[ $pos{'is_subsection'} ] :  0;
#line 97 "/home/production/cxgn/sgn/mason/page/info_section.mas"
     $align = exists $pos{'align'} ? $_[ $pos{'align'} ] :  '';
#line 98 "/home/production/cxgn/sgn/mason/page/info_section.mas"
     $contents = exists $pos{'contents'} ? $_[ $pos{'contents'} ] :  '';
#line 99 "/home/production/cxgn/sgn/mason/page/info_section.mas"
     $hide_if_empty = exists $pos{'hide_if_empty'} ? $_[ $pos{'hide_if_empty'} ] :  0;
}
$m->debug_hook( $m->current_comp->path ) if ( HTML::Mason::Compiler::IN_PERL_DB() );

#line 87 "/home/production/cxgn/sgn/mason/page/info_section.mas"
$m->print( '
' );
#line 101 "/home/production/cxgn/sgn/mason/page/info_section.mas"
$m->print( '
' );
#line 102 "/home/production/cxgn/sgn/mason/page/info_section.mas"
 my $sub = $is_subsection ? 'sub_' : '';
$m->print( '
<a class="info_section_anchor' );
#line 104 "/home/production/cxgn/sgn/mason/page/info_section.mas"
$m->print(  $sub ? ' info_subsection_anchor' : ''  );
#line 104 "/home/production/cxgn/sgn/mason/page/info_section.mas"
$m->print( '" name="' );
#line 104 "/home/production/cxgn/sgn/mason/page/info_section.mas"
$m->print(  anchor_name( $title )  );
#line 104 "/home/production/cxgn/sgn/mason/page/info_section.mas"
$m->print( '"></a>

' );
#line 106 "/home/production/cxgn/sgn/mason/page/info_section.mas"


    $contents ||= $m->content || '';

    #if we have been given content, and we aren't told that this section
    #is supposed to be empty, print a full section
    if ( $contents =~ /\S/ && !$is_empty ) {
        $align &&= qq| style="text-align: $align|;
        $id ||= "sgnc" . int( rand(10000) );
        $contents = <<EOC;
<div class="${sub}infosectioncontent" $align>
$contents
</div>
EOC

        if ( $collapsible ) {
            ( $title, $contents ) = collapser(
                {
                    linktext            => $title,
                    hide_state_linktext => $title,
                    content             => $contents,
                    collapsed           => $collapsed,
                    id                  => $id,
                }
            );
        }
        $subtitle ||= '';
        my $title_bar = <<EOHTML;
<table cellspacing="0" cellpadding="0" class="${sub}infosectionhead" summary=""><tr><td class="${sub}infosectiontitle">$title</td><td class="${sub}infosectionsubtitle" role="button" tabindex="0">$subtitle&nbsp;</td></tr></table>
EOHTML
        print "$title_bar\n$contents\n";
    }

    #otherwise, if it's actually empty, just print a collapsed section
    #with the empty message
    elsif( $hide_if_empty ) {
        # print nothing
    }
    else {
        my $maybe_subtitle =
          $subtitle
          ? qq|<td class="${sub}infosectionsubtitle_empty" role="button" tabindex="0" align="right">$subtitle&nbsp;</td>|
          : '';
        print <<EOT;
<table cellspacing="0" cellpadding="0" class="${sub}infosectionhead_empty" summary=""><tr><td class="${sub}infosectiontitle_empty">$title</td><td class="${sub}infosection_emptymessage">$empty_message</td>$maybe_subtitle</tr></table>
EOT
    }

#line 155 "/home/production/cxgn/sgn/mason/page/info_section.mas"
$m->print( '
' );
;return;
},
'declared_args' => {
  '$align' => { default => ' \'\'' },
  '$collapsed' => { default => ' 0' },
  '$collapsible' => { default => ' 0' },
  '$contents' => { default => ' \'\'' },
  '$empty_message' => { default => ' "None"' },
  '$hide_if_empty' => { default => ' 0' },
  '$id' => { default => ' ""' },
  '$is_empty' => { default => ' 0' },
  '$is_subsection' => { default => ' 0' },
  '$subtitle' => { default => ' ""' },
  '$title' => { default => undef }
},
'load_time' => 1763079527,

)
;